了解真实的crypto-js aes加密: brix/crypto-js#207 (comment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AAC raw frame data | |
let dts = this._timestampBase + ts; | |
// check large timestamp gap caused av drift | |
if (this._expectTsAudio === -1) { | |
this._expectTsAudio = dts; // set base ts | |
} | |
let generated = false; | |
const delta = dts - this._expectTsAudio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type by jcalz | |
type UnionToIntersection<U> = | |
(U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (v.getUint32(offset + lengthSize) === 1) { | |
const bytes = new Uint8Array( | |
arrayBuffer, | |
dataOffset + offset + 4, | |
naluSize | |
); | |
const nals = parseNal({ | |
codec: Codec.H264, | |
bytes | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Browser.firefox || this.options.isSDPOldFormat) { | |
try { | |
const obj = sdpTransform.parse(sdp); | |
// workaround: 火狐替换大于uint64的session_id(可能由老版本chrome或sdk发出) | |
obj.origin.sessionId = 1; | |
// workaround: 火狐datachannel新旧格式支持问题 | |
// workaround: 旧版本chrome同样不支持新的sdp格式,需要转换 | |
const isOld = !!obj.media[0].sctpmap; | |
if (this.options.isSDPOldFormat) { | |
if (!isOld) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useage: proxy curl www.google.com | |
proxy() { | |
http_proxy=127.0.0.1:1080 https_proxy=127.0.0.1:1080 $* | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useMemo, useState } from "react"; | |
const DARK_MODE_SCHEME = "(prefers-color-scheme: dark)"; | |
export function getIsDarkMode() { | |
return window.matchMedia(DARK_MODE_SCHEME).matches; | |
} | |
export function useDarkMode() { | |
const initValue = useMemo(getIsDarkMode, []); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
test: /\.js$/, | |
exclude: /node_modules\/(?!(MY-MODULE|ANOTHER-ONE)\/).*/, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropsWithChildren, useEffect, useState } from 'react'; | |
export default function NoSSRLoad<T extends React.ComponentType<PropsWithChildren<any>>>(loader: () => Promise<{ default: T }>) { | |
const NoSSRLoadWrap = (props) => { | |
const [Component, setComponent] = useState<T>(); | |
useEffect(() => { | |
// Don't use: loader().then((m) => setComponent(m.default)); | |
// When m.default is function, set state of a function will be treated as an updater function, just like setAge(age => age+1); | |
// That's not what you want. | |
loader().then((m) => setComponent(() => m.default)); |