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
50831d53
Commit
50831d53
authored
Apr 19, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Apr 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for TS in boot script
parent
26a12c9f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
13 deletions
+10
-13
gulpfile.mjs
gulpfile.mjs
+1
-1
rollup-boot.config.mjs
rollup-boot.config.mjs
+2
-2
.babelrc
src/boot/.babelrc
+1
-0
browser-extension-utils.ts
src/boot/browser-extension-utils.ts
+6
-10
No files found.
gulpfile.mjs
View file @
50831d53
...
@@ -109,7 +109,7 @@ gulp.task('watch-boot-script', () => {
...
@@ -109,7 +109,7 @@ gulp.task('watch-boot-script', () => {
//
//
// We could alternatively use `watchJS` to rebuild the bundle, but we'd
// We could alternatively use `watchJS` to rebuild the bundle, but we'd
// need to make its logging less noisy first.
// need to make its logging less noisy first.
'src/boot/**/*.
js
'
,
'src/boot/**/*.
{js,ts,tsx}
'
,
],
],
{
delay
:
500
},
{
delay
:
500
},
gulp
.
task
(
'build-boot-script'
)
gulp
.
task
(
'build-boot-script'
)
...
...
rollup-boot.config.mjs
View file @
50831d53
...
@@ -64,11 +64,11 @@ export default {
...
@@ -64,11 +64,11 @@ export default {
// Rollup docs recommend against "inline", but for this tiny bundle it
// Rollup docs recommend against "inline", but for this tiny bundle it
// produces a prod bundle of the same size and dev bundle that has less cruft in it.
// produces a prod bundle of the same size and dev bundle that has less cruft in it.
babelHelpers
:
'inline'
,
babelHelpers
:
'inline'
,
exclude
:
'node_modules/**'
,
exclude
:
'node_modules/**'
,
extensions
:
[
'.js'
,
'.ts'
,
'.tsx'
]
}),
}),
json
(),
json
(),
nodeResolve
(),
nodeResolve
(
{
extensions
:
[
'.js'
,
'.ts'
,
'.tsx'
]
}
),
...
prodPlugins
,
...
prodPlugins
,
],
],
};
};
src/boot/.babelrc
View file @
50831d53
{
{
"presets": [
"presets": [
"@babel/preset-typescript",
["@babel/preset-env", {
["@babel/preset-env", {
"targets": {
"targets": {
"chrome": "40",
"chrome": "40",
...
...
src/boot/browser-extension-utils.
j
s
→
src/boot/browser-extension-utils.
t
s
View file @
50831d53
/**
/**
* Returns the extension ID which is running this script, or undefined if this
* Returns the extension ID which is running this script, or undefined if this
* script is not being run by the browser extension.
* script is not being run by the browser extension.
*
* @param {Window} window_
* @return {string | undefined}
*/
*/
export
function
getExtensionId
(
window_
=
window
)
{
export
function
getExtensionId
(
window_
:
Window
=
window
):
string
|
undefined
{
return
/** @type {any} */
(
window_
).
chrome
?.
runtime
?.
id
;
return
(
window_
as
any
).
chrome
?.
runtime
?.
id
;
}
}
/**
/**
* Verifies if there's a config script in the document that was generated by a
* Verifies if there's a config script in the document that was generated by a
* specific browser extension.
* specific browser extension.
*
* @param {string} extensionId
* @param {Document} document_
* @return {boolean}
*/
*/
export
function
hasExtensionConfig
(
extensionId
,
document_
=
document
)
{
export
function
hasExtensionConfig
(
extensionId
:
string
,
document_
:
Document
=
document
):
boolean
{
return
!!
document_
.
querySelector
(
return
!!
document_
.
querySelector
(
`script.js-hypothesis-config[data-extension-id=
${
extensionId
}
]`
`script.js-hypothesis-config[data-extension-id=
${
extensionId
}
]`
);
);
...
...
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