Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
32ddd01d
Commit
32ddd01d
authored
Mar 28, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate bucket-bar-client module to TypeScript
parent
a28acdfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
bucket-bar-client.ts
src/annotator/bucket-bar-client.ts
+21
-23
No files found.
src/annotator/bucket-bar-client.
j
s
→
src/annotator/bucket-bar-client.
t
s
View file @
32ddd01d
import
{
ListenerCollection
}
from
'../shared/listener-collection'
;
import
type
{
PortRPC
}
from
'../shared/messaging'
;
import
type
{
Anchor
,
Destroyable
}
from
'../types/annotator'
;
import
type
{
HostToGuestEvent
,
GuestToHostEvent
,
}
from
'../types/port-rpc-events'
;
import
{
computeAnchorPositions
}
from
'./util/buckets'
;
/**
* @typedef {import('../shared/messaging').PortRPC<HostToGuestEvent, GuestToHostEvent>} HostRPC
* @typedef {import('../types/annotator').Anchor} Anchor
* @typedef {import('../types/annotator').AnchorPosition} AnchorPosition
* @typedef {import('../types/annotator').Destroyable} Destroyable
* @typedef {import('../types/port-rpc-events').HostToGuestEvent} HostToGuestEvent
* @typedef {import('../types/port-rpc-events').GuestToHostEvent} GuestToHostEvent
*/
type
HostRPC
=
PortRPC
<
HostToGuestEvent
,
GuestToHostEvent
>
;
export
type
BucketBarClientOptions
=
{
contentContainer
:
Element
;
hostRPC
:
HostRPC
;
};
/**
* Communicate to the host frame when:
*
* 1. The set of anchors has been changed (due to annotations being added or removed)
* 2. The position of anchors relative to the viewport of the guest has changed
*
* @implements {Destroyable}
*/
export
class
BucketBarClient
{
/**
* @param {object} options
* @param {Element} options.contentContainer - The scrollable container element for the
* document content. All of the highlights that the bucket bar's buckets point
* at should be contained within this element.
* @param {HostRPC} options.hostRPC
*/
constructor
({
contentContainer
,
hostRPC
})
{
export
class
BucketBarClient
implements
Destroyable
{
private
_hostRPC
:
HostRPC
;
private
_updatePending
:
boolean
;
private
_anchors
:
Anchor
[];
private
_listeners
:
ListenerCollection
;
constructor
({
contentContainer
,
hostRPC
}:
BucketBarClientOptions
)
{
this
.
_hostRPC
=
hostRPC
;
this
.
_updatePending
=
false
;
/** @type {Anchor[]} */
this
.
_anchors
=
[];
this
.
_listeners
=
new
ListenerCollection
();
...
...
@@ -50,10 +49,9 @@ export class BucketBarClient {
* Updates are debounced to reduce the overhead of gathering and sending anchor
* position data across frames.
*
* @param {Anchor[]} [anchors] - pass this option when anchors are added or
* deleted
* @param anchors - pass this option when anchors are added or deleted
*/
update
(
anchors
)
{
update
(
anchors
?:
Anchor
[]
)
{
if
(
anchors
)
{
this
.
_anchors
=
anchors
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment