Skip to content

Commit 7cab12b

Browse files
authored
Merge pull request #58 from takker99:export-scrapbox
feat: export `scrapox` and `cosense`
2 parents b745ee4 + 53304ce commit 7cab12b

File tree

6 files changed

+66
-47
lines changed

6 files changed

+66
-47
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
name: ci
22

3-
env:
4-
DENO_VERSION: 1.x
5-
63
on: [push, pull_request]
74

5+
env:
6+
DENO_VERSION: 2.x
7+
88
jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@master
13-
- name: Install Deno
14-
uses: denoland/setup-deno@v1
12+
- uses: actions/checkout@v4
13+
- uses: denoland/setup-deno@v2
1514
with:
1615
deno-version: ${{ env.DENO_VERSION }}
17-
- name: Check fmt & lint & type check & test
18-
run: deno task check:dry
16+
- name: Check all
17+
run: deno task check

.github/workflows/publish.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
name: publish
33

44
env:
5-
DENO_VERSION: 1.x
5+
DENO_VERSION: 2.x
66

77
on:
88
push:
99
tags:
10-
- '*'
10+
- "*"
1111

1212
permissions:
1313
contents: read
14-
id-token: write # The OIDC ID token is used for authentication with JSR.
15-
14+
id-token: write
1615

1716
jobs:
1817
publish:
1918
runs-on: ubuntu-latest
2019
steps:
2120
- uses: actions/checkout@v4
22-
- name: Install Deno
23-
uses: denoland/setup-deno@v1
21+
- uses: denoland/setup-deno@v2
2422
with:
2523
deno-version: ${{ env.DENO_VERSION }}
2624
- name: Publish on tag
27-
run: deno task publish
25+
run: deno run --allow-env --allow-run=deno --allow-read --allow-write=deno.jsonc jsr:@david/publish[email protected]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docs/
2+
coverage/

deno.jsonc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "@cosense/types",
33
"version": "0.0.0",
44
"tasks": {
5-
"check:dry": "deno fmt --check && deno lint && deno check --remote **/*.ts && deno test --parallel",
6-
"check": "deno fmt && deno lint && deno check --remote **/*.ts && deno test --parallel",
7-
"check:publish": "deno task check && deno publish --dry-run --allow-dirty",
8-
"publish": "deno run --allow-env --allow-run=deno --allow-read --allow-write=deno.jsonc jsr:@david/[email protected]"
5+
"fix": "deno fmt && deno lint --fix && deno test --allow-read --doc --parallel --shuffle && deno publish --dry-run --allow-dirty",
6+
"check": "deno fmt --check && deno lint && deno test --allow-read --doc --parallel --shuffle && deno publish --dry-run",
7+
"coverage": "deno test --allow-read=./ --parallel --shuffle --coverage && deno coverage --html",
8+
"doc": "deno doc --html rest.ts userscript.ts"
99
},
1010
"imports": {
1111
"@std/testing/types": "jsr:@std/testing@0/types"
@@ -20,5 +20,9 @@
2020
"dom.iterable",
2121
"esnext"
2222
]
23-
}
23+
},
24+
"exclude": [
25+
"coverage/",
26+
"docs/"
27+
]
2428
}

userscript.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,19 @@ export * from "./pageMenu.ts";
1010
export * from "./eventName.ts";
1111
export * from "./scrapbox.ts";
1212
export type { EventEmitter } from "./vendor/events.ts";
13+
import type { Scrapbox } from "./scrapbox.ts";
14+
15+
// The following assignments are a workaround for esbuild
16+
// Use IIFE to tree-shaking
17+
18+
/** `scrapbox` */
19+
export const scrapbox: Scrapbox = /* @__PURE__ */ (
20+
// deno-lint-ignore no-explicit-any
21+
() => (globalThis as any).scrapbox
22+
)();
23+
24+
/** an alias for {@linkcode scrapbox} */
25+
export const cosense: Scrapbox = /* @__PURE__ */ (
26+
// deno-lint-ignore no-explicit-any
27+
() => (globalThis as any).cosense
28+
)();

vendor/events.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface Abortable {
2323
* For `EventTarget`s this is the only way to get the event listeners for the
2424
* event target. This is useful for debugging and diagnostic purposes.
2525
*
26-
* ```js
26+
* ```js ignore
2727
* const { getEventListeners, EventEmitter } = require('events');
2828
*
2929
* {
@@ -48,7 +48,7 @@ export declare function getEventListeners(
4848
): Function[];
4949

5050
/**
51-
* ```js
51+
* ```js ignore
5252
* const { on, EventEmitter } = require('events');
5353
*
5454
* (async () => {
@@ -77,7 +77,7 @@ export declare function getEventListeners(
7777
*
7878
* An `AbortSignal` can be used to cancel waiting on events:
7979
*
80-
* ```js
80+
* ```js ignore
8181
* const { on, EventEmitter } = require('events');
8282
* const ac = new AbortController();
8383
*
@@ -120,7 +120,7 @@ export declare function on(
120120
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
121121
* semantics and does not listen to the `'error'` event.
122122
*
123-
* ```js
123+
* ```js ignore
124124
* const { once, EventEmitter } = require('events');
125125
*
126126
* async function run() {
@@ -152,7 +152,7 @@ export declare function on(
152152
* '`error'` event itself, then it is treated as any other kind of event without
153153
* special handling:
154154
*
155-
* ```js
155+
* ```js ignore
156156
* const { EventEmitter, once } = require('events');
157157
*
158158
* const ee = new EventEmitter();
@@ -168,7 +168,7 @@ export declare function on(
168168
*
169169
* An `AbortSignal` can be used to cancel waiting for the event:
170170
*
171-
* ```js
171+
* ```js ignore
172172
* const { EventEmitter, once } = require('events');
173173
*
174174
* const ee = new EventEmitter();
@@ -228,7 +228,7 @@ interface StaticEventEmitterOptions {
228228
/**
229229
* The `EventEmitter` class is defined and exposed by the `events` module:
230230
*
231-
* ```js
231+
* ```js ignore
232232
* const EventEmitter = require('events');
233233
* ```
234234
*
@@ -253,7 +253,7 @@ export declare class EventEmitter {
253253
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
254254
* times.
255255
*
256-
* ```js
256+
* ```js ignore
257257
* server.on('connection', (stream) => {
258258
* console.log('someone connected!');
259259
* });
@@ -264,7 +264,7 @@ export declare class EventEmitter {
264264
* By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
265265
* event listener to the beginning of the listeners array.
266266
*
267-
* ```js
267+
* ```js ignore
268268
* const myEE = new EventEmitter();
269269
* myEE.on('foo', () => console.log('a'));
270270
* myEE.prependListener('foo', () => console.log('b'));
@@ -282,7 +282,7 @@ export declare class EventEmitter {
282282
* Adds a **one-time**`listener` function for the event named `eventName`. The
283283
* next time `eventName` is triggered, this listener is removed and then invoked.
284284
*
285-
* ```js
285+
* ```js ignore
286286
* server.once('connection', (stream) => {
287287
* console.log('Ah, we have our first user!');
288288
* });
@@ -293,7 +293,7 @@ export declare class EventEmitter {
293293
* By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
294294
* event listener to the beginning of the listeners array.
295295
*
296-
* ```js
296+
* ```js ignore
297297
* const myEE = new EventEmitter();
298298
* myEE.once('foo', () => console.log('a'));
299299
* myEE.prependOnceListener('foo', () => console.log('b'));
@@ -310,7 +310,7 @@ export declare class EventEmitter {
310310
/**
311311
* Removes the specified `listener` from the listener array for the event named`eventName`.
312312
*
313-
* ```js
313+
* ```js ignore
314314
* const callback = (stream) => {
315315
* console.log('someone connected!');
316316
* };
@@ -328,7 +328,7 @@ export declare class EventEmitter {
328328
* time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and_before_ the last listener finishes execution will
329329
* not remove them from`emit()` in progress. Subsequent events behave as expected.
330330
*
331-
* ```js
331+
* ```js ignore
332332
* const myEmitter = new MyEmitter();
333333
*
334334
* const callbackA = () => {
@@ -368,7 +368,7 @@ export declare class EventEmitter {
368368
* event (as in the example below), `removeListener()` will remove the most
369369
* recently added instance. In the example the `once('ping')`listener is removed:
370370
*
371-
* ```js
371+
* ```js ignore
372372
* const ee = new EventEmitter();
373373
*
374374
* function pong() {
@@ -425,7 +425,7 @@ export declare class EventEmitter {
425425
/**
426426
* Returns a copy of the array of listeners for the event named `eventName`.
427427
*
428-
* ```js
428+
* ```js ignore
429429
* server.on('connection', (stream) => {
430430
* console.log('someone connected!');
431431
* });
@@ -440,7 +440,7 @@ export declare class EventEmitter {
440440
* Returns a copy of the array of listeners for the event named `eventName`,
441441
* including any wrappers (such as those created by `.once()`).
442442
*
443-
* ```js
443+
* ```js ignore
444444
* const emitter = new EventEmitter();
445445
* emitter.once('log', () => console.log('log once'));
446446
*
@@ -473,7 +473,7 @@ export declare class EventEmitter {
473473
*
474474
* Returns `true` if the event had listeners, `false` otherwise.
475475
*
476-
* ```js
476+
* ```js ignore
477477
* const EventEmitter = require('events');
478478
* const myEmitter = new EventEmitter();
479479
*
@@ -520,7 +520,7 @@ export declare class EventEmitter {
520520
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
521521
* times.
522522
*
523-
* ```js
523+
* ```js ignore
524524
* server.prependListener('connection', (stream) => {
525525
* console.log('someone connected!');
526526
* });
@@ -539,7 +539,7 @@ export declare class EventEmitter {
539539
* Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
540540
* listener is removed, and then invoked.
541541
*
542-
* ```js
542+
* ```js ignore
543543
* server.prependOnceListener('connection', (stream) => {
544544
* console.log('Ah, we have our first user!');
545545
* });
@@ -558,7 +558,7 @@ export declare class EventEmitter {
558558
* Returns an array listing the events for which the emitter has registered
559559
* listeners. The values in the array are strings or `Symbol`s.
560560
*
561-
* ```js
561+
* ```js ignore
562562
* const EventEmitter = require('events');
563563
* const myEE = new EventEmitter();
564564
* myEE.on('foo', () => {});
@@ -584,7 +584,7 @@ export declare class EventEmitter {
584584
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
585585
* semantics and does not listen to the `'error'` event.
586586
*
587-
* ```js
587+
* ```js ignore
588588
* const { once, EventEmitter } = require('events');
589589
*
590590
* async function run() {
@@ -616,7 +616,7 @@ export declare class EventEmitter {
616616
* '`error'` event itself, then it is treated as any other kind of event without
617617
* special handling:
618618
*
619-
* ```js
619+
* ```js ignore
620620
* const { EventEmitter, once } = require('events');
621621
*
622622
* const ee = new EventEmitter();
@@ -632,7 +632,7 @@ export declare class EventEmitter {
632632
*
633633
* An `AbortSignal` can be used to cancel waiting for the event:
634634
*
635-
* ```js
635+
* ```js ignore
636636
* const { EventEmitter, once } = require('events');
637637
*
638638
* const ee = new EventEmitter();
@@ -668,7 +668,7 @@ export declare class EventEmitter {
668668
options?: StaticEventEmitterOptions,
669669
): Promise<any[]>;
670670
/**
671-
* ```js
671+
* ```js ignore
672672
* const { on, EventEmitter } = require('events');
673673
*
674674
* (async () => {
@@ -697,7 +697,7 @@ export declare class EventEmitter {
697697
*
698698
* An `AbortSignal` can be used to cancel waiting on events:
699699
*
700-
* ```js
700+
* ```js ignore
701701
* const { on, EventEmitter } = require('events');
702702
* const ac = new AbortController();
703703
*
@@ -729,7 +729,7 @@ export declare class EventEmitter {
729729
/**
730730
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
731731
*
732-
* ```js
732+
* ```js ignore
733733
* const { EventEmitter, listenerCount } = require('events');
734734
* const myEmitter = new EventEmitter();
735735
* myEmitter.on('event', () => {});
@@ -756,7 +756,7 @@ export declare class EventEmitter {
756756
* For `EventTarget`s this is the only way to get the event listeners for the
757757
* event target. This is useful for debugging and diagnostic purposes.
758758
*
759-
* ```js
759+
* ```js ignore
760760
* const { getEventListeners, EventEmitter } = require('events');
761761
*
762762
* {

0 commit comments

Comments
 (0)