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
{
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'
;
import
{
computeAnchorPositions
}
from
'./util/buckets'
;
/**
type
HostRPC
=
PortRPC
<
HostToGuestEvent
,
GuestToHostEvent
>
;
* @typedef {import('../shared/messaging').PortRPC<HostToGuestEvent, GuestToHostEvent>} HostRPC
* @typedef {import('../types/annotator').Anchor} Anchor
export
type
BucketBarClientOptions
=
{
* @typedef {import('../types/annotator').AnchorPosition} AnchorPosition
contentContainer
:
Element
;
* @typedef {import('../types/annotator').Destroyable} Destroyable
hostRPC
:
HostRPC
;
* @typedef {import('../types/port-rpc-events').HostToGuestEvent} HostToGuestEvent
};
* @typedef {import('../types/port-rpc-events').GuestToHostEvent} GuestToHostEvent
*/
/**
/**
* Communicate to the host frame when:
* Communicate to the host frame when:
*
*
* 1. The set of anchors has been changed (due to annotations being added or removed)
* 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
* 2. The position of anchors relative to the viewport of the guest has changed
*
* @implements {Destroyable}
*/
*/
export
class
BucketBarClient
{
export
class
BucketBarClient
implements
Destroyable
{
/**
private
_hostRPC
:
HostRPC
;
* @param {object} options
private
_updatePending
:
boolean
;
* @param {Element} options.contentContainer - The scrollable container element for the
private
_anchors
:
Anchor
[];
* document content. All of the highlights that the bucket bar's buckets point
private
_listeners
:
ListenerCollection
;
* at should be contained within this element.
* @param {HostRPC} options.hostRPC
constructor
({
contentContainer
,
hostRPC
}:
BucketBarClientOptions
)
{
*/
constructor
({
contentContainer
,
hostRPC
})
{
this
.
_hostRPC
=
hostRPC
;
this
.
_hostRPC
=
hostRPC
;
this
.
_updatePending
=
false
;
this
.
_updatePending
=
false
;
/** @type {Anchor[]} */
this
.
_anchors
=
[];
this
.
_anchors
=
[];
this
.
_listeners
=
new
ListenerCollection
();
this
.
_listeners
=
new
ListenerCollection
();
...
@@ -50,10 +49,9 @@ export class BucketBarClient {
...
@@ -50,10 +49,9 @@ export class BucketBarClient {
* Updates are debounced to reduce the overhead of gathering and sending anchor
* Updates are debounced to reduce the overhead of gathering and sending anchor
* position data across frames.
* position data across frames.
*
*
* @param {Anchor[]} [anchors] - pass this option when anchors are added or
* @param anchors - pass this option when anchors are added or deleted
* deleted
*/
*/
update
(
anchors
)
{
update
(
anchors
?:
Anchor
[]
)
{
if
(
anchors
)
{
if
(
anchors
)
{
this
.
_anchors
=
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