|
1 | 1 | import { |
2 | | - FetchEventCallback, |
3 | | - RuntimeContext, |
4 | | - RuntimeEnvironment, |
5 | | - createComponent, |
6 | | - createIntegration, |
7 | | -} from "@gitbook/runtime"; |
| 2 | + FetchEventCallback, |
| 3 | + RuntimeContext, |
| 4 | + RuntimeEnvironment, |
| 5 | + createComponent, |
| 6 | + createIntegration, |
| 7 | +} from '@gitbook/runtime'; |
8 | 8 |
|
9 | 9 | interface EmbedDoltHubSQLConfiguration {} |
10 | 10 |
|
11 | | -type EmbedDoltHubSQLRuntimeEnvironment = |
12 | | - RuntimeEnvironment<EmbedDoltHubSQLConfiguration>; |
13 | | -type EmbedDoltHubSQLRuntimeContext = |
14 | | - RuntimeContext<EmbedDoltHubSQLRuntimeEnvironment>; |
| 11 | +type EmbedDoltHubSQLRuntimeEnvironment = RuntimeEnvironment<EmbedDoltHubSQLConfiguration>; |
| 12 | +type EmbedDoltHubSQLRuntimeContext = RuntimeContext<EmbedDoltHubSQLRuntimeEnvironment>; |
15 | 13 |
|
16 | | -const handleFetchEvent: FetchEventCallback< |
17 | | - EmbedDoltHubSQLRuntimeContext |
18 | | -> = async (request, context) => { |
19 | | - // eslint-disable-next-line @typescript-eslint/no-unused-vars |
20 | | - const { api } = context; |
21 | | - const user = api.user.getAuthenticatedUser(); |
| 14 | +const handleFetchEvent: FetchEventCallback<EmbedDoltHubSQLRuntimeContext> = async (_, context) => { |
| 15 | + const { api } = context; |
| 16 | + const user = api.user.getAuthenticatedUser(); |
22 | 17 |
|
23 | | - return new Response(JSON.stringify(user)); |
| 18 | + return new Response(JSON.stringify(user)); |
24 | 19 | }; |
25 | 20 |
|
26 | 21 | /** |
27 | | - * Component to render the block when embeding an DoltHub URL. |
| 22 | + * Component to render the block when embedding an DoltHub URL. |
28 | 23 | */ |
29 | | -const embedBlock = createComponent<{ |
30 | | - url?: string; |
31 | | -}>({ |
32 | | - componentId: "embed", |
| 24 | +type Props = { |
| 25 | + url: string; |
| 26 | +}; |
| 27 | + |
| 28 | +const embedBlock = createComponent<Props>({ |
| 29 | + componentId: 'embed', |
33 | 30 |
|
34 | | - async action(element, action) { |
35 | | - switch (action.action) { |
36 | | - case "@link.unfurl": { |
37 | | - const { url } = action; |
| 31 | + async action(element, action) { |
| 32 | + // @ts-ignore |
| 33 | + switch (action.action) { |
| 34 | + case '@link.unfurl': { |
| 35 | + // @ts-ignore |
| 36 | + const { url } = action; |
38 | 37 |
|
39 | | - return { |
40 | | - props: { |
41 | | - url, |
42 | | - }, |
43 | | - }; |
44 | | - } |
45 | | - } |
| 38 | + return { |
| 39 | + props: { |
| 40 | + url, |
| 41 | + }, |
| 42 | + }; |
| 43 | + } |
| 44 | + } |
46 | 45 |
|
47 | | - return element; |
48 | | - }, |
| 46 | + return element; |
| 47 | + }, |
49 | 48 |
|
50 | | - async render(element, context) { |
51 | | - const { url } = element.props; |
52 | | - const aspectRatio = 16 / 9; |
53 | | - return ( |
54 | | - <block> |
55 | | - <webframe |
56 | | - source={{ |
57 | | - url: url, |
58 | | - }} |
59 | | - aspectRatio={aspectRatio} |
60 | | - /> |
61 | | - </block> |
62 | | - ); |
63 | | - }, |
| 49 | + async render(element) { |
| 50 | + const { url } = element.props; |
| 51 | + const aspectRatio = 16 / 9; |
| 52 | + return ( |
| 53 | + <block> |
| 54 | + <webframe |
| 55 | + source={{ |
| 56 | + url, |
| 57 | + }} |
| 58 | + aspectRatio={aspectRatio} |
| 59 | + /> |
| 60 | + </block> |
| 61 | + ); |
| 62 | + }, |
64 | 63 | }); |
65 | 64 |
|
66 | 65 | export default createIntegration<EmbedDoltHubSQLRuntimeContext>({ |
67 | | - fetch: handleFetchEvent, |
68 | | - components: [embedBlock], |
| 66 | + fetch: handleFetchEvent, |
| 67 | + components: [embedBlock], |
69 | 68 | }); |
0 commit comments