project: Move to ESM Modules
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { EventInputType } from './constants'
|
||||
import type { EventInputType } from './constants'
|
||||
|
||||
export class BinaryInfo {
|
||||
protocolVersion = 5
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ import {
|
||||
FLAG_EXTENDED,
|
||||
FLAG_FIELD,
|
||||
FLAG_GLOBAL,
|
||||
Value,
|
||||
type Value,
|
||||
WEB_EVENTS,
|
||||
WEB_GLOBALS
|
||||
} from './constants'
|
||||
@@ -54,7 +54,7 @@ function encodeGlobalAttributes(binaryInfo: BinaryInfo, globals: { [key: string]
|
||||
}
|
||||
|
||||
function encodeEvents(binaryInfo: BinaryInfo) {
|
||||
for (const [name, { props, globals }] of binaryInfo.events.map(a => Object.entries(a)[0])) {
|
||||
for (const [name, { props, globals }] of binaryInfo.events.map(a => Object.entries(a)[0]!)) {
|
||||
encodeGlobalAttributes(binaryInfo, globals)
|
||||
const event = WEB_EVENTS.find(a => a.name === name)!
|
||||
|
||||
@@ -70,8 +70,8 @@ function encodeEvents(binaryInfo: BinaryInfo) {
|
||||
binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag))
|
||||
|
||||
for (let i = 0; i < props_.length; i++) {
|
||||
const [key, _value] = props_[i]
|
||||
const id = event.props[key][0]
|
||||
const [key, _value] = props_[i]!
|
||||
const id = event.props[key]?.[0]
|
||||
extended = i < props_.length - 1
|
||||
let value = _value
|
||||
if (typeof value === 'boolean') {
|
||||
@@ -79,7 +79,7 @@ function encodeEvents(binaryInfo: BinaryInfo) {
|
||||
}
|
||||
|
||||
const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED
|
||||
binaryInfo.buffer.push(serializeData(id, value, fieldFlag))
|
||||
binaryInfo.buffer.push(serializeData(id!, value, fieldFlag))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user