deepsea-components 5.18.4 → 5.18.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +23 -23
  2. package/dist/components/AutoFit.cjs +4 -4
  3. package/dist/components/AutoFit.d.ts +1 -1
  4. package/dist/components/AutoFit.js +1 -1
  5. package/dist/components/AutoScroll.cjs +4 -4
  6. package/dist/components/AutoScroll.d.ts +2 -2
  7. package/dist/components/AutoScroll.js +1 -1
  8. package/dist/components/AutoSizeTextarea.cjs +4 -4
  9. package/dist/components/AutoSizeTextarea.d.ts +1 -1
  10. package/dist/components/AutoSizeTextarea.js +1 -1
  11. package/dist/components/CircleText.cjs +4 -4
  12. package/dist/components/CircleText.d.ts +1 -1
  13. package/dist/components/CircleText.js +1 -1
  14. package/dist/components/CopyButton.cjs +6 -9
  15. package/dist/components/CopyButton.d.ts +3 -3
  16. package/dist/components/CopyButton.js +3 -3
  17. package/dist/components/DraggableGrid.cjs +3 -3
  18. package/dist/components/DraggableGrid.d.ts +2 -2
  19. package/dist/components/DraggableGrid.module.cjs +3 -3
  20. package/dist/components/DraggableGrid.module.js +1 -1
  21. package/dist/components/Echart.cjs +20 -20
  22. package/dist/components/Echart.d.ts +3 -3
  23. package/dist/components/Echart.js +1 -1
  24. package/dist/components/Flow.cjs +7 -7
  25. package/dist/components/Flow.d.ts +1 -1
  26. package/dist/components/Flow.js +1 -1
  27. package/dist/components/FormLabel.cjs +6 -6
  28. package/dist/components/FormLabel.d.ts +1 -1
  29. package/dist/components/FormLabel.js +1 -1
  30. package/dist/components/HlsPlayer.cjs +4 -4
  31. package/dist/components/HlsPlayer.d.ts +1 -1
  32. package/dist/components/HlsPlayer.js +1 -1
  33. package/dist/components/IconFileType.cjs +6 -6
  34. package/dist/components/IconFileType.d.ts +1 -1
  35. package/dist/components/InfiniteScroll.cjs +4 -4
  36. package/dist/components/InfiniteScroll.d.ts +1 -1
  37. package/dist/components/InfiniteScroll.js +1 -1
  38. package/dist/components/InputFile.cjs +4 -4
  39. package/dist/components/InputFile.d.ts +1 -1
  40. package/dist/components/InputFile.js +1 -1
  41. package/dist/components/InputFileButton.cjs +4 -4
  42. package/dist/components/InputFileButton.d.ts +2 -2
  43. package/dist/components/InputFileButton.js +1 -1
  44. package/dist/components/LoopSwiper.cjs +4 -4
  45. package/dist/components/LoopSwiper.d.ts +1 -1
  46. package/dist/components/LoopSwiper.js +1 -1
  47. package/dist/components/ReadExcel.cjs +4 -4
  48. package/dist/components/ReadExcel.d.ts +1 -1
  49. package/dist/components/ReadExcel.js +1 -1
  50. package/dist/components/ReadSheet.cjs +4 -4
  51. package/dist/components/ReadSheet.d.ts +2 -2
  52. package/dist/components/ReadSheet.js +1 -1
  53. package/dist/components/Ring.cjs +4 -4
  54. package/dist/components/Ring.d.ts +1 -1
  55. package/dist/components/Ring.js +1 -1
  56. package/dist/components/RtspPlayer.cjs +5 -5
  57. package/dist/components/RtspPlayer.d.ts +1 -1
  58. package/dist/components/RtspPlayer.js +2 -2
  59. package/dist/components/Scroll.cjs +38 -40
  60. package/dist/components/Scroll.d.ts +1 -1
  61. package/dist/components/Scroll.js +1 -1
  62. package/dist/components/ScrollMask.cjs +3 -3
  63. package/dist/components/ScrollMask.d.ts +1 -1
  64. package/dist/components/ScrollMask.module.cjs +3 -3
  65. package/dist/components/ScrollMask.module.js +1 -1
  66. package/dist/components/ScrollMask_module.css +3 -1
  67. package/dist/components/SectionRing.cjs +4 -4
  68. package/dist/components/SectionRing.d.ts +1 -1
  69. package/dist/components/SectionRing.js +1 -1
  70. package/dist/components/Skeleton.cjs +4 -4
  71. package/dist/components/Skeleton.d.ts +1 -1
  72. package/dist/components/Skeleton.js +1 -1
  73. package/dist/components/Title.cjs +4 -4
  74. package/dist/components/Title.d.ts +1 -1
  75. package/dist/components/Title.js +1 -1
  76. package/dist/components/TransitionBox.cjs +4 -4
  77. package/dist/components/TransitionBox.d.ts +1 -1
  78. package/dist/components/TransitionBox.js +1 -1
  79. package/dist/components/TransitionNum.cjs +4 -4
  80. package/dist/components/TransitionNum.d.ts +1 -1
  81. package/dist/components/TransitionNum.js +1 -1
  82. package/dist/components/Trapezium.cjs +4 -4
  83. package/dist/components/Trapezium.d.ts +1 -1
  84. package/dist/components/Trapezium.js +1 -1
  85. package/dist/components/Unify.cjs +4 -4
  86. package/dist/components/Unify.d.ts +1 -1
  87. package/dist/components/Unify.js +1 -1
  88. package/dist/components/WriteExcel.cjs +4 -4
  89. package/dist/components/WriteExcel.d.ts +1 -1
  90. package/dist/components/WriteExcel.js +1 -1
  91. package/dist/components/WriteSheet.cjs +4 -4
  92. package/dist/components/WriteSheet.d.ts +2 -2
  93. package/dist/components/WriteSheet.js +1 -1
  94. package/dist/components/rtspPlayer/reader.cjs +3 -3
  95. package/dist/index.cjs +162 -226
  96. package/dist/utils/getReactVersion.cjs +3 -3
  97. package/dist/utils/index.cjs +3 -3
  98. package/dist/utils/index.d.ts +1 -1
  99. package/package.json +7 -7
  100. package/src/components/AutoFit.tsx +3 -1
  101. package/src/components/AutoScroll.tsx +4 -3
  102. package/src/components/AutoSizeTextarea.tsx +1 -1
  103. package/src/components/CircleText.tsx +81 -81
  104. package/src/components/CopyButton.tsx +8 -3
  105. package/src/components/DraggableGrid.tsx +9 -2
  106. package/src/components/Echart.tsx +65 -62
  107. package/src/components/Flow.tsx +11 -1
  108. package/src/components/FormLabel.tsx +1 -1
  109. package/src/components/HlsPlayer.tsx +1 -1
  110. package/src/components/IconFileType.tsx +1 -1
  111. package/src/components/InfiniteScroll.tsx +15 -1
  112. package/src/components/InputFile.tsx +6 -1
  113. package/src/components/InputFileButton.tsx +18 -13
  114. package/src/components/LoopSwiper.tsx +2 -1
  115. package/src/components/ReadExcel.tsx +13 -13
  116. package/src/components/ReadSheet.tsx +2 -2
  117. package/src/components/Ring.tsx +1 -1
  118. package/src/components/RtspPlayer.tsx +3 -4
  119. package/src/components/Scroll.tsx +13 -1
  120. package/src/components/ScrollMask.module.css +87 -87
  121. package/src/components/ScrollMask.tsx +1 -1
  122. package/src/components/SectionRing.tsx +2 -2
  123. package/src/components/Skeleton.tsx +1 -1
  124. package/src/components/Title.tsx +4 -1
  125. package/src/components/TransitionBox.tsx +1 -1
  126. package/src/components/TransitionNum.tsx +1 -1
  127. package/src/components/Trapezium.tsx +1 -1
  128. package/src/components/Unify.tsx +13 -1
  129. package/src/components/WriteExcel.tsx +13 -13
  130. package/src/components/WriteSheet.tsx +4 -2
  131. package/src/components/rtspPlayer/reader.ts +8 -9
  132. package/src/utils/getReactVersion.ts +7 -7
  133. package/src/utils/index.ts +33 -33
  134. package/tsconfig.json +6 -8
@@ -1,13 +1,13 @@
1
- "use client"
2
-
3
- import { ReadSheet, ReadSheetProps } from "./ReadSheet"
4
-
5
- /**
6
- * @deprecated 请使用 ReadSheetProps 代替
7
- */
8
- export type ReadExcelProps = ReadSheetProps
9
-
10
- /**
11
- * @deprecated 请使用 ReadSheet 代替
12
- */
13
- export const ReadExcel = ReadSheet
1
+ "use client"
2
+
3
+ import { type ReadSheetProps, ReadSheet } from "./ReadSheet"
4
+
5
+ /**
6
+ * @deprecated 请使用 ReadSheetProps 代替
7
+ */
8
+ export type ReadExcelProps = ReadSheetProps
9
+
10
+ /**
11
+ * @deprecated 请使用 ReadSheet 代替
12
+ */
13
+ export const ReadExcel = ReadSheet
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
- import { readSheet, WorkBookData, WorkSheetData } from "deepsea-tools"
3
+ import { type WorkBookData, type WorkSheetData, readSheet } from "deepsea-tools"
4
4
 
5
- import { InputFile, InputFileProps } from "./InputFile"
5
+ import { type InputFileProps, InputFile } from "./InputFile"
6
6
 
7
7
  export interface ReadSheetProps<Sheet = WorkSheetData> extends Omit<InputFileProps<false, "arrayBuffer">, "multiple" | "accept" | "type" | "onValueChange"> {
8
8
  onValueChange?: (data: WorkBookData<Sheet>) => void
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { forwardRef, HTMLAttributes } from "react"
3
+ import { type HTMLAttributes, forwardRef } from "react"
4
4
 
5
5
  export interface RingProps extends HTMLAttributes<HTMLDivElement> {
6
6
  outerWidth: number
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { ComponentProps, FC, useEffect, useImperativeHandle, useRef } from "react"
3
+ import { type ComponentProps, type FC, useEffect, useImperativeHandle, useRef } from "react"
4
4
 
5
5
  import { MediaMTXWebRTCReader } from "@/components/rtspPlayer/reader"
6
6
 
@@ -15,9 +15,7 @@ export interface RtspPlayerProps extends Omit<ComponentProps<"video">, "src" | "
15
15
  function getWhepUrl(src: string) {
16
16
  const url = new URL(src, window.location.href)
17
17
 
18
- if (url.protocol !== "http:" && url.protocol !== "https:") {
19
- throw new Error("RtspPlayer expects a MediaMTX HTTP(S) playback URL, not an RTSP URL")
20
- }
18
+ if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("RtspPlayer expects a MediaMTX HTTP(S) playback URL, not an RTSP URL")
21
19
 
22
20
  const pathname = url.pathname.replace(/\/+$/, "")
23
21
  url.pathname = pathname.endsWith("/whep") ? pathname : `${pathname}/whep`
@@ -60,6 +58,7 @@ export const RtspPlayer: FC<RtspPlayerProps> = ({ ref, src, user, pass, token, o
60
58
 
61
59
  let closed = false
62
60
  const fallbackStream = new MediaStream()
61
+
63
62
  const reader = new MediaMTXWebRTCReader({
64
63
  url: whepUrl,
65
64
  user,
@@ -1,6 +1,16 @@
1
1
  "use client"
2
2
 
3
- import { ComponentProps, CSSProperties, FC, ForwardedRef, useEffect, useEffectEvent, useImperativeHandle, useLayoutEffect, useRef } from "react"
3
+ import {
4
+ type ComponentProps,
5
+ type CSSProperties,
6
+ type FC,
7
+ type ForwardedRef,
8
+ useEffect,
9
+ useEffectEvent,
10
+ useImperativeHandle,
11
+ useLayoutEffect,
12
+ useRef,
13
+ } from "react"
4
14
 
5
15
  import { css } from "@emotion/css"
6
16
  import { clsx } from "deepsea-tools"
@@ -48,7 +58,9 @@ export const Scroll: FC<ScrollProps> = ({
48
58
 
49
59
  useLayoutEffect(() => {
50
60
  bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
61
+
51
62
  return () => bar.current?.destroy()
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
52
64
  }, [])
53
65
 
54
66
  useImperativeHandle(ref, () => ele.current!, [])
@@ -1,87 +1,87 @@
1
- .scroll-mask {
2
- position: sticky;
3
- z-index: 10;
4
- pointer-events: none;
5
- }
6
-
7
- .top-scroll-mask {
8
- width: 100%;
9
- height: 0;
10
- top: 0;
11
- right: 0;
12
- bottom: 100%;
13
- left: 0;
14
- }
15
-
16
- .scroll-mask-content {
17
- position: absolute;
18
- background-image: linear-gradient(
19
- to var(--scroll-mask-direction),
20
- var(--scroll-mask-color-from, rgba(0, 0, 0, 0.1)),
21
- var(--scroll-mask-color-to, rgba(0, 0, 0, 0))
22
- );
23
- clip-path: var(--scroll-mask-clip-path, none);
24
- }
25
-
26
- .top-scroll-mask-content {
27
- width: 100%;
28
- height: var(--scroll-mask-size, 8px);
29
- top: 0;
30
- right: 50%;
31
- transform: translateX(50%);
32
- --scroll-mask-direction: bottom;
33
- }
34
-
35
- .bottom-scroll-mask {
36
- width: 100%;
37
- height: 0;
38
- top: 100%;
39
- right: 0;
40
- bottom: 0;
41
- left: 0;
42
- }
43
-
44
- .bottom-scroll-mask-content {
45
- width: 100%;
46
- height: var(--scroll-mask-size, 8px);
47
- bottom: 0;
48
- left: 50%;
49
- transform: translateX(-50%);
50
- --scroll-mask-direction: top;
51
- }
52
-
53
- .left-scroll-mask {
54
- width: 0;
55
- height: 100%;
56
- top: 0;
57
- right: 100%;
58
- bottom: 0;
59
- left: 0;
60
- }
61
-
62
- .left-scroll-mask-content {
63
- width: var(--scroll-mask-size, 8px);
64
- height: 100%;
65
- left: 0;
66
- top: 50%;
67
- transform: translateY(-50%);
68
- --scroll-mask-direction: right;
69
- }
70
-
71
- .right-scroll-mask {
72
- width: 0;
73
- height: 100%;
74
- top: 0;
75
- right: 0;
76
- bottom: 0;
77
- left: 100%;
78
- }
79
-
80
- .right-scroll-mask-content {
81
- width: var(--scroll-mask-size, 8px);
82
- height: 100%;
83
- right: 0;
84
- bottom: 50%;
85
- transform: translateY(50%);
86
- --scroll-mask-direction: left;
87
- }
1
+ .scroll-mask {
2
+ position: sticky;
3
+ z-index: 10;
4
+ pointer-events: none;
5
+ }
6
+
7
+ .top-scroll-mask {
8
+ width: 100%;
9
+ height: 0;
10
+ top: 0;
11
+ right: 0;
12
+ bottom: 100%;
13
+ left: 0;
14
+ }
15
+
16
+ .scroll-mask-content {
17
+ position: absolute;
18
+ background-image: linear-gradient(
19
+ to var(--scroll-mask-direction),
20
+ var(--scroll-mask-color-from, rgba(0, 0, 0, 0.1)),
21
+ var(--scroll-mask-color-to, rgba(0, 0, 0, 0))
22
+ );
23
+ clip-path: var(--scroll-mask-clip-path, none);
24
+ }
25
+
26
+ .top-scroll-mask-content {
27
+ width: 100%;
28
+ height: var(--scroll-mask-size, 8px);
29
+ top: 0;
30
+ right: 50%;
31
+ transform: translateX(50%);
32
+ --scroll-mask-direction: bottom;
33
+ }
34
+
35
+ .bottom-scroll-mask {
36
+ width: 100%;
37
+ height: 0;
38
+ top: 100%;
39
+ right: 0;
40
+ bottom: 0;
41
+ left: 0;
42
+ }
43
+
44
+ .bottom-scroll-mask-content {
45
+ width: 100%;
46
+ height: var(--scroll-mask-size, 8px);
47
+ bottom: 0;
48
+ left: 50%;
49
+ transform: translateX(-50%);
50
+ --scroll-mask-direction: top;
51
+ }
52
+
53
+ .left-scroll-mask {
54
+ width: 0;
55
+ height: 100%;
56
+ top: 0;
57
+ right: 100%;
58
+ bottom: 0;
59
+ left: 0;
60
+ }
61
+
62
+ .left-scroll-mask-content {
63
+ width: var(--scroll-mask-size, 8px);
64
+ height: 100%;
65
+ left: 0;
66
+ top: 50%;
67
+ transform: translateY(-50%);
68
+ --scroll-mask-direction: right;
69
+ }
70
+
71
+ .right-scroll-mask {
72
+ width: 0;
73
+ height: 100%;
74
+ top: 0;
75
+ right: 0;
76
+ bottom: 0;
77
+ left: 100%;
78
+ }
79
+
80
+ .right-scroll-mask-content {
81
+ width: var(--scroll-mask-size, 8px);
82
+ height: 100%;
83
+ right: 0;
84
+ bottom: 50%;
85
+ transform: translateY(50%);
86
+ --scroll-mask-direction: left;
87
+ }
@@ -1,4 +1,4 @@
1
- import { ComponentProps, CSSProperties, FC, useRef } from "react"
1
+ import { type ComponentProps, type CSSProperties, type FC, useRef } from "react"
2
2
 
3
3
  import { clsx, isNonNullable } from "deepsea-tools"
4
4
  import { useSize } from "soda-hooks"
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
- import { forwardRef, HTMLAttributes } from "react"
3
+ import { type HTMLAttributes, forwardRef } from "react"
4
4
 
5
- import { drawArc, DrawArcOptions } from "deepsea-tools"
5
+ import { type DrawArcOptions, drawArc } from "deepsea-tools"
6
6
 
7
7
  export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
8
8
  outerRadius: number
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { forwardRef, HTMLAttributes } from "react"
3
+ import { type HTMLAttributes, forwardRef } from "react"
4
4
 
5
5
  import { css } from "@emotion/css"
6
6
  import { clsx } from "deepsea-tools"
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { ComponentProps, FC, useImperativeHandle, useLayoutEffect, useRef } from "react"
3
+ import { type ComponentProps, type FC, useImperativeHandle, useLayoutEffect, useRef } from "react"
4
4
  import { createPortal } from "react-dom"
5
5
  import { renderToString } from "react-dom/server"
6
6
 
@@ -15,10 +15,13 @@ export const Title: FC<ComponentProps<"title">> = ({ ref, children, ...rest }) =
15
15
 
16
16
  if (major >= 19) return <title ref={ref} {...rest} children={children} />
17
17
 
18
+ // eslint-disable-next-line react-hooks/rules-of-hooks
18
19
  const ele = useRef<HTMLTitleElement>(null)
19
20
 
21
+ // eslint-disable-next-line react-hooks/rules-of-hooks, react-hooks/exhaustive-deps, react-hooks/refs
20
22
  useImperativeHandle(ref, () => ele.current as HTMLTitleElement, [ele.current])
21
23
 
24
+ // eslint-disable-next-line react-hooks/rules-of-hooks
22
25
  useLayoutEffect(() => {
23
26
  const title = document.head.querySelector("title")
24
27
  if (title === ele.current) return
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { CSSProperties, FC, forwardRef, HTMLAttributes, useEffect, useRef, useState } from "react"
3
+ import { type CSSProperties, type FC, type HTMLAttributes, forwardRef, useEffect, useRef, useState } from "react"
4
4
 
5
5
  import { useSize } from "soda-hooks"
6
6
 
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { ForwardedRef, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useRef } from "react"
3
+ import { type ForwardedRef, type HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
4
4
 
5
5
  import { setFrameInterval } from "deepsea-tools"
6
6
 
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { forwardRef, HTMLAttributes } from "react"
3
+ import { type HTMLAttributes, forwardRef } from "react"
4
4
 
5
5
  import { css } from "@emotion/css"
6
6
  import { clsx } from "deepsea-tools"
@@ -1,6 +1,18 @@
1
1
  "use client"
2
2
 
3
- import { ComponentProps, createContext, createElement, CSSProperties, FC, JSX, JSXElementConstructor, ReactNode, useContext } from "react"
3
+ /* eslint-disable no-restricted-syntax */
4
+
5
+ import {
6
+ type ComponentProps,
7
+ type CSSProperties,
8
+ type FC,
9
+ type JSX,
10
+ type JSXElementConstructor,
11
+ type ReactNode,
12
+ createContext,
13
+ createElement,
14
+ useContext,
15
+ } from "react"
4
16
 
5
17
  import { clsx } from "deepsea-tools"
6
18
 
@@ -1,13 +1,13 @@
1
- "use client"
2
-
3
- import { WriteSheet, WriteSheetProps } from "./WriteSheet"
4
-
5
- /**
6
- * @deprecated 请使用 WriteSheetProps 代替
7
- */
8
- export type WriteExcelProps = WriteSheetProps
9
-
10
- /**
11
- * @deprecated 请使用 WriteSheet 代替
12
- */
13
- export const WriteExcel = WriteSheet
1
+ "use client"
2
+
3
+ import { type WriteSheetProps, WriteSheet } from "./WriteSheet"
4
+
5
+ /**
6
+ * @deprecated 请使用 WriteSheetProps 代替
7
+ */
8
+ export type WriteExcelProps = WriteSheetProps
9
+
10
+ /**
11
+ * @deprecated 请使用 WriteSheet 代替
12
+ */
13
+ export const WriteExcel = WriteSheet
@@ -1,8 +1,10 @@
1
1
  "use client"
2
2
 
3
- import { ComponentProps, createElement, JSX, JSXElementConstructor, MouseEvent as ReactMouseEvent } from "react"
3
+ /* eslint-disable no-restricted-syntax */
4
4
 
5
- import { writeSheet, WriteSheetParams } from "deepsea-tools"
5
+ import { type ComponentProps, type JSX, type JSXElementConstructor, type MouseEvent as ReactMouseEvent, createElement } from "react"
6
+
7
+ import { type WriteSheetParams, writeSheet } from "deepsea-tools"
6
8
 
7
9
  export type WriteSheetProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "button"> = Omit<ComponentProps<AS>, "as" | "excel"> & {
8
10
  as?: AS
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-restricted-syntax */
2
+
1
3
  /*
2
4
  * Derived from MediaMTX reader.js:
3
5
  * https://github.com/bluenviron/mediamtx/blob/main/internal/servers/webrtc/reader.js
@@ -84,12 +86,14 @@ export class MediaMTXWebRTCReader {
84
86
  let payloadType = ""
85
87
 
86
88
  pc.addTransceiver(mediaType, { direction: "recvonly" })
89
+
87
90
  pc.createOffer()
88
91
  .then(offer => {
89
92
  if (offer.sdp === undefined) throw new Error("SDP not present")
90
93
  if (offer.sdp.includes(` ${codec}`)) throw new Error("already present")
91
94
 
92
95
  const sections = offer.sdp.split(`m=${mediaType}`)
96
+
93
97
  const payloadTypes = sections
94
98
  .slice(1)
95
99
  .map(section => section.split("\r\n")[0].split(" ").slice(3))
@@ -126,8 +130,7 @@ export class MediaMTXWebRTCReader {
126
130
  `a=rtpmap:${payloadType} ${codec}\r\n` +
127
131
  (fmtp !== undefined ? `a=fmtp:${payloadType} ${fmtp}\r\n` : ""),
128
132
  }),
129
- ),
130
- )
133
+ ))
131
134
  .then(() => resolve(true))
132
135
  .catch(() => resolve(false))
133
136
  .finally(() => pc.close())
@@ -294,6 +297,7 @@ export class MediaMTXWebRTCReader {
294
297
 
295
298
  private static editOffer(sdp: string, nonAdvertisedCodecs: string[]) {
296
299
  const sections = sdp.split("m=")
300
+
297
301
  const payloadTypes = sections
298
302
  .slice(1)
299
303
  .map(section => section.split("\r\n")[0].split(" ").slice(3))
@@ -371,16 +375,11 @@ export class MediaMTXWebRTCReader {
371
375
 
372
376
  private getNonAdvertisedCodecs() {
373
377
  Promise.all(
374
- [
375
- ["pcma/8000/2"],
376
- ["multiopus/48000/6", "channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2"],
377
- ["L16/48000/2"],
378
- ].map(codec =>
378
+ [["pcma/8000/2"], ["multiopus/48000/6", "channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2"], ["L16/48000/2"]].map(codec =>
379
379
  MediaMTXWebRTCReader.supportsNonAdvertisedCodec(codec[0], codec[1]).then(isSupported => {
380
380
  if (!isSupported) return false
381
381
  return codec[0]
382
- }),
383
- ),
382
+ })),
384
383
  )
385
384
  .then(codecs => codecs.filter((codec): codec is string => codec !== false))
386
385
  .then(codecs => {
@@ -1,7 +1,7 @@
1
- import { version } from "react"
2
-
3
- const reg = /(\d+)\.(\d+)\.(\d+)/
4
-
5
- export function getReactVersion() {
6
- return version.match(reg)!.slice(1).map(Number)
7
- }
1
+ import { version } from "react"
2
+
3
+ const reg = /(\d+)\.(\d+)\.(\d+)/
4
+
5
+ export function getReactVersion() {
6
+ return version.match(reg)!.slice(1).map(Number)
7
+ }
@@ -1,33 +1,33 @@
1
- import { CSSProperties } from "react"
2
-
3
- export type CSSVariableName = `--${string}`
4
-
5
- export type CSSVariableValue = string | number | undefined
6
-
7
- export interface StyleWithCSSVariable extends CSSProperties {
8
- [X: CSSVariableName]: CSSVariableValue
9
- }
10
-
11
- const cssVariableReg = /[A-Z]/
12
-
13
- function addCSSVariableLine(match: string): string {
14
- return `-${match}`
15
- }
16
-
17
- export function transformCSSVariableName(name: string): CSSVariableName {
18
- return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`
19
- }
20
-
21
- export function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {
22
- return Object.assign(
23
- Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {
24
- acc[transformCSSVariableName(key)] = value
25
- return acc
26
- }, {}),
27
- style2,
28
- )
29
- }
30
-
31
- export function px(value: string | number | undefined): string | undefined {
32
- return typeof value === "number" ? `${value}px` : value
33
- }
1
+ import type { CSSProperties } from "react"
2
+
3
+ export type CSSVariableName = `--${string}`
4
+
5
+ export type CSSVariableValue = string | number | undefined
6
+
7
+ export interface StyleWithCSSVariable extends CSSProperties {
8
+ [X: CSSVariableName]: CSSVariableValue
9
+ }
10
+
11
+ const cssVariableReg = /[A-Z]/
12
+
13
+ function addCSSVariableLine(match: string): string {
14
+ return `-${match}`
15
+ }
16
+
17
+ export function transformCSSVariableName(name: string): CSSVariableName {
18
+ return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`
19
+ }
20
+
21
+ export function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {
22
+ return Object.assign(
23
+ Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {
24
+ acc[transformCSSVariableName(key)] = value
25
+ return acc
26
+ }, {}),
27
+ style2,
28
+ )
29
+ }
30
+
31
+ export function px(value: string | number | undefined): string | undefined {
32
+ return typeof value === "number" ? `${value}px` : value
33
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "rootDir": "src",
3
4
  "strict": true,
4
5
  "declaration": true,
5
6
  "skipLibCheck": true,
@@ -7,14 +8,11 @@
7
8
  "target": "ESNext",
8
9
  "module": "ESNext",
9
10
  "moduleResolution": "Bundler",
11
+ "types": ["node", "react", "react-dom"],
12
+ "verbatimModuleSyntax": true,
10
13
  "paths": {
11
- "@/*": [
12
- "./src/*"
13
- ]
14
+ "@/*": ["./src/*"]
14
15
  }
15
16
  },
16
- "include": [
17
- "src",
18
- "types.d.ts"
19
- ]
20
- }
17
+ "include": ["src", "types.d.ts"]
18
+ }