2023-04-10 16:37:13 +05:30
|
|
|
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
|
// distributed with this work for additional information
|
|
|
|
|
// regarding copyright ownership. The SFC licenses this file
|
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
|
// "License"); you may not use this file except in compliance
|
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing,
|
|
|
|
|
// software distributed under the License is distributed on an
|
|
|
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
// KIND, either express or implied. See the License for the
|
|
|
|
|
// specific language governing permissions and limitations
|
|
|
|
|
// under the License.
|
|
|
|
|
|
2024-08-06 10:36:54 +05:30
|
|
|
const { PrimitiveType, NonPrimitiveType, RemoteType, SpecialNumberType } = require('./protocolType')
|
2023-04-10 16:37:13 +05:30
|
|
|
|
|
|
|
|
const TYPE_CONSTANT = 'type'
|
|
|
|
|
const VALUE_CONSTANT = 'value'
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents the types of remote reference.
|
|
|
|
|
* @enum {string}
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
const RemoteReferenceType = {
|
|
|
|
|
HANDLE: 'handle',
|
2023-12-07 15:24:46 +05:30
|
|
|
SHARED_ID: 'sharedId',
|
2023-04-10 16:37:13 +05:30
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents a local value with a specified type and optional value.
|
|
|
|
|
* @class
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-LocalValue
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
class LocalValue {
|
|
|
|
|
constructor(type, value = null) {
|
|
|
|
|
if (type === PrimitiveType.UNDEFINED || type === PrimitiveType.NULL) {
|
|
|
|
|
this.type = type
|
|
|
|
|
} else {
|
|
|
|
|
this.type = type
|
|
|
|
|
this.value = value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a string value.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} value - The string value to be stored in the LocalValue object.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createStringValue(value) {
|
|
|
|
|
return new LocalValue(PrimitiveType.STRING, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a number value.
|
|
|
|
|
*
|
|
|
|
|
* @param {number} value - The number value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createNumberValue(value) {
|
|
|
|
|
return new LocalValue(PrimitiveType.NUMBER, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a special number value.
|
|
|
|
|
*
|
|
|
|
|
* @param {number} value - The value of the special number.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createSpecialNumberValue(value) {
|
|
|
|
|
return new LocalValue(PrimitiveType.SPECIAL_NUMBER, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with an undefined value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createUndefinedValue() {
|
|
|
|
|
return new LocalValue(PrimitiveType.UNDEFINED)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a null value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createNullValue() {
|
|
|
|
|
return new LocalValue(PrimitiveType.NULL)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a boolean value.
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} value - The boolean value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createBooleanValue(value) {
|
|
|
|
|
return new LocalValue(PrimitiveType.BOOLEAN, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with a BigInt value.
|
|
|
|
|
*
|
|
|
|
|
* @param {BigInt} value - The BigInt value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createBigIntValue(value) {
|
|
|
|
|
return new LocalValue(PrimitiveType.BIGINT, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with an array.
|
|
|
|
|
*
|
|
|
|
|
* @param {Array} value - The array.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createArrayValue(value) {
|
|
|
|
|
return new LocalValue(NonPrimitiveType.ARRAY, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with date value.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} value - The date.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createDateValue(value) {
|
|
|
|
|
return new LocalValue(NonPrimitiveType.DATE, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object of map value.
|
|
|
|
|
* @param {Map} map - The map.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createMapValue(map) {
|
|
|
|
|
let value = []
|
|
|
|
|
Object.entries(map).forEach((entry) => {
|
|
|
|
|
value.push(entry)
|
|
|
|
|
})
|
|
|
|
|
return new LocalValue(NonPrimitiveType.MAP, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object from the passed object.
|
|
|
|
|
*
|
2024-11-08 12:45:42 -05:00
|
|
|
* @param {Object} object - The object.
|
2024-04-03 10:05:52 +05:30
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
|
|
|
|
static createObjectValue(object) {
|
2023-04-10 16:37:13 +05:30
|
|
|
let value = []
|
2024-04-03 10:05:52 +05:30
|
|
|
Object.entries(object).forEach((entry) => {
|
2023-04-10 16:37:13 +05:30
|
|
|
value.push(entry)
|
|
|
|
|
})
|
|
|
|
|
return new LocalValue(NonPrimitiveType.OBJECT, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object of regular expression value.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} value - The value of the regular expression.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createRegularExpressionValue(value) {
|
|
|
|
|
return new LocalValue(NonPrimitiveType.REGULAR_EXPRESSION, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with the specified value.
|
|
|
|
|
* @param {Set} value - The value to be set.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
static createSetValue(value) {
|
|
|
|
|
return new LocalValue(NonPrimitiveType.SET, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Creates a new LocalValue object with the given channel value
|
|
|
|
|
*
|
|
|
|
|
* @param {ChannelValue} value - The channel value.
|
|
|
|
|
* @returns {LocalValue} - The created LocalValue object.
|
|
|
|
|
*/
|
2023-12-18 16:29:00 +05:30
|
|
|
static createChannelValue(value) {
|
|
|
|
|
return new LocalValue(NonPrimitiveType.CHANNEL, value)
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 17:24:12 +05:30
|
|
|
static createReferenceValue(handle, sharedId) {
|
|
|
|
|
return new ReferenceValue(handle, sharedId)
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 10:36:54 +05:30
|
|
|
static getArgument(argument) {
|
|
|
|
|
let localValue = null
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
argument === SpecialNumberType.NAN ||
|
|
|
|
|
argument === SpecialNumberType.MINUS_ZERO ||
|
|
|
|
|
argument === SpecialNumberType.INFINITY ||
|
|
|
|
|
argument === SpecialNumberType.MINUS_INFINITY
|
|
|
|
|
) {
|
|
|
|
|
localValue = LocalValue.createSpecialNumberValue(argument)
|
|
|
|
|
return localValue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const type = typeof argument
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case PrimitiveType.STRING:
|
|
|
|
|
localValue = LocalValue.createStringValue(argument)
|
|
|
|
|
break
|
|
|
|
|
case PrimitiveType.NUMBER:
|
|
|
|
|
localValue = LocalValue.createNumberValue(argument)
|
|
|
|
|
break
|
|
|
|
|
case PrimitiveType.BOOLEAN:
|
|
|
|
|
localValue = LocalValue.createBooleanValue(argument)
|
|
|
|
|
break
|
|
|
|
|
case PrimitiveType.BIGINT:
|
|
|
|
|
localValue = LocalValue.createBigIntValue(argument.toString())
|
|
|
|
|
break
|
|
|
|
|
case PrimitiveType.UNDEFINED:
|
|
|
|
|
localValue = LocalValue.createUndefinedValue()
|
|
|
|
|
break
|
|
|
|
|
case NonPrimitiveType.OBJECT:
|
|
|
|
|
if (argument === null) {
|
|
|
|
|
localValue = LocalValue.createNullValue()
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
if (argument instanceof Date) {
|
|
|
|
|
localValue = LocalValue.createDateValue(argument)
|
|
|
|
|
} else if (argument instanceof Map) {
|
|
|
|
|
const map = []
|
|
|
|
|
|
|
|
|
|
argument.forEach((value, key) => {
|
|
|
|
|
let objectKey
|
|
|
|
|
if (typeof key === 'string') {
|
|
|
|
|
objectKey = key
|
|
|
|
|
} else {
|
|
|
|
|
objectKey = LocalValue.getArgument(key)
|
|
|
|
|
}
|
|
|
|
|
const objectValue = LocalValue.getArgument(value)
|
|
|
|
|
map.push([objectKey, objectValue])
|
|
|
|
|
})
|
|
|
|
|
localValue = new LocalValue(NonPrimitiveType.MAP, map)
|
|
|
|
|
} else if (argument instanceof Set) {
|
|
|
|
|
const set = []
|
|
|
|
|
argument.forEach((value) => {
|
|
|
|
|
set.push(LocalValue.getArgument(value))
|
|
|
|
|
})
|
|
|
|
|
localValue = LocalValue.createSetValue(set)
|
|
|
|
|
} else if (argument instanceof Array) {
|
|
|
|
|
const arr = []
|
|
|
|
|
argument.forEach((value) => {
|
|
|
|
|
arr.push(LocalValue.getArgument(value))
|
|
|
|
|
})
|
|
|
|
|
localValue = LocalValue.createArrayValue(arr)
|
|
|
|
|
} else if (argument instanceof RegExp) {
|
|
|
|
|
localValue = LocalValue.createRegularExpressionValue({
|
|
|
|
|
pattern: argument.source,
|
|
|
|
|
flags: argument.flags,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
let value = []
|
|
|
|
|
Object.entries(argument).forEach((entry) => {
|
|
|
|
|
value.push([LocalValue.getArgument(entry[0]), LocalValue.getArgument(entry[1])])
|
|
|
|
|
})
|
|
|
|
|
localValue = new LocalValue(NonPrimitiveType.OBJECT, value)
|
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return localValue
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 17:24:12 +05:30
|
|
|
asMap() {
|
2023-04-10 16:37:13 +05:30
|
|
|
let toReturn = {}
|
|
|
|
|
toReturn[TYPE_CONSTANT] = this.type
|
|
|
|
|
|
2024-02-07 16:07:24 +00:00
|
|
|
if (!(this.type === PrimitiveType.NULL || this.type === PrimitiveType.UNDEFINED)) {
|
2023-04-10 16:37:13 +05:30
|
|
|
toReturn[VALUE_CONSTANT] = this.value
|
|
|
|
|
}
|
|
|
|
|
return toReturn
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents a remote value.
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue.
|
|
|
|
|
* @class
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
class RemoteValue {
|
|
|
|
|
constructor(remoteValue) {
|
|
|
|
|
this.type = null
|
|
|
|
|
this.handle = null
|
|
|
|
|
this.internalId = null
|
|
|
|
|
this.value = null
|
|
|
|
|
this.sharedId = null
|
|
|
|
|
|
|
|
|
|
if ('type' in remoteValue) {
|
2023-07-11 20:42:39 +05:30
|
|
|
const typeString = remoteValue['type']
|
2023-04-10 16:37:13 +05:30
|
|
|
if (PrimitiveType.findByName(typeString) != null) {
|
|
|
|
|
this.type = PrimitiveType.findByName(typeString)
|
|
|
|
|
} else if (NonPrimitiveType.findByName(typeString) != null) {
|
|
|
|
|
this.type = NonPrimitiveType.findByName(typeString)
|
|
|
|
|
} else {
|
|
|
|
|
this.type = RemoteType.findByName(typeString)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('handle' in remoteValue) {
|
|
|
|
|
this.handle = remoteValue['handle']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('internalId' in remoteValue) {
|
|
|
|
|
this.internalId = remoteValue['internalId']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('value' in remoteValue) {
|
|
|
|
|
this.value = remoteValue['value']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('sharedId' in remoteValue) {
|
|
|
|
|
this.sharedId = remoteValue['sharedId']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.value != null) {
|
|
|
|
|
this.value = this.deserializeValue(this.value, this.type)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deserializeValue(value, type) {
|
2024-08-06 10:36:54 +05:30
|
|
|
if (type === NonPrimitiveType.OBJECT) {
|
2023-04-10 16:37:13 +05:30
|
|
|
return Object.fromEntries(value)
|
|
|
|
|
} else if (type === NonPrimitiveType.REGULAR_EXPRESSION) {
|
|
|
|
|
return new RegExpValue(value.pattern, value.flags)
|
|
|
|
|
}
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents a reference value in the protocol.
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-RemoteReference.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
class ReferenceValue {
|
2024-03-20 16:40:19 +05:30
|
|
|
#handle
|
|
|
|
|
#sharedId
|
2024-04-03 10:05:52 +05:30
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a new ReferenceValue object.
|
|
|
|
|
* @param {string} handle - The handle value.
|
|
|
|
|
* @param {string} sharedId - The shared ID value.
|
|
|
|
|
*/
|
2023-12-07 15:24:46 +05:30
|
|
|
constructor(handle, sharedId) {
|
2023-04-10 16:37:13 +05:30
|
|
|
if (handle === RemoteReferenceType.HANDLE) {
|
2024-03-20 16:40:19 +05:30
|
|
|
this.#handle = sharedId
|
|
|
|
|
} else if (handle === RemoteReferenceType.SHARED_ID) {
|
|
|
|
|
this.#sharedId = sharedId
|
2023-04-10 16:37:13 +05:30
|
|
|
} else {
|
2024-03-20 16:40:19 +05:30
|
|
|
this.#handle = handle
|
|
|
|
|
this.#sharedId = sharedId
|
2023-04-10 16:37:13 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asMap() {
|
|
|
|
|
const toReturn = {}
|
2024-03-20 16:40:19 +05:30
|
|
|
if (this.#handle != null) {
|
|
|
|
|
toReturn[RemoteReferenceType.HANDLE] = this.#handle
|
2023-04-10 16:37:13 +05:30
|
|
|
}
|
|
|
|
|
|
2024-03-20 16:40:19 +05:30
|
|
|
if (this.#sharedId != null) {
|
|
|
|
|
toReturn[RemoteReferenceType.SHARED_ID] = this.#sharedId
|
2023-04-10 16:37:13 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return toReturn
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents a regular expression value.
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-LocalValue.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
class RegExpValue {
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Constructs a new RegExpValue object.
|
|
|
|
|
* @param {string} pattern - The pattern of the regular expression.
|
|
|
|
|
* @param {string|null} [flags=null] - The flags of the regular expression.
|
|
|
|
|
*/
|
2023-04-10 16:37:13 +05:30
|
|
|
constructor(pattern, flags = null) {
|
|
|
|
|
this.pattern = pattern
|
|
|
|
|
this.flags = flags
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents serialization options.
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-SerializationOptions.
|
|
|
|
|
*/
|
2023-12-18 16:29:00 +05:30
|
|
|
class SerializationOptions {
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Constructs a new instance of SerializationOptions.
|
|
|
|
|
* @param {number} [maxDomDepth=0] - The maximum depth to serialize the DOM.
|
|
|
|
|
* @param {number|null} [maxObjectDepth=null] - The maximum depth to serialize objects.
|
|
|
|
|
* @param {'none'|'open'|'all'} [includeShadowTree='none'] - The inclusion level of the shadow tree.
|
|
|
|
|
* @throws {Error} If the `includeShadowTree` value is not one of 'none', 'open', or 'all'.
|
|
|
|
|
*/
|
2024-02-07 16:07:24 +00:00
|
|
|
constructor(maxDomDepth = 0, maxObjectDepth = null, includeShadowTree = 'none') {
|
2023-12-18 16:29:00 +05:30
|
|
|
this._maxDomDepth = maxDomDepth
|
|
|
|
|
this._maxObjectDepth = maxObjectDepth
|
|
|
|
|
|
|
|
|
|
if (['none', 'open', 'all'].includes(includeShadowTree)) {
|
2024-02-07 16:07:24 +00:00
|
|
|
throw Error(`Valid types are 'none', 'open', and 'all'. Received: ${includeShadowTree}`)
|
2023-12-18 16:29:00 +05:30
|
|
|
}
|
|
|
|
|
this._includeShadowTree = includeShadowTree
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-03 10:05:52 +05:30
|
|
|
/**
|
|
|
|
|
* Represents a channel value.
|
|
|
|
|
* Described in https://w3c.github.io/webdriver-bidi/#type-script-ChannelValue.
|
|
|
|
|
* @class
|
|
|
|
|
*/
|
2023-12-18 16:29:00 +05:30
|
|
|
class ChannelValue {
|
|
|
|
|
constructor(channel, options = undefined, resultOwnership = undefined) {
|
|
|
|
|
this.channel = channel
|
|
|
|
|
|
|
|
|
|
if (options !== undefined) {
|
|
|
|
|
if (options instanceof SerializationOptions) {
|
|
|
|
|
this.options = options
|
|
|
|
|
} else {
|
2024-02-07 16:07:24 +00:00
|
|
|
throw Error(`Pass in SerializationOptions object. Received: ${options} `)
|
2023-12-18 16:29:00 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-08 12:45:42 -05:00
|
|
|
if (resultOwnership !== undefined) {
|
2023-12-18 16:29:00 +05:30
|
|
|
if (['root', 'none'].includes(resultOwnership)) {
|
|
|
|
|
this.resultOwnership = resultOwnership
|
|
|
|
|
} else {
|
2024-02-07 16:07:24 +00:00
|
|
|
throw Error(`Valid types are 'root' and 'none. Received: ${resultOwnership}`)
|
2023-12-18 16:29:00 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 16:37:13 +05:30
|
|
|
module.exports = {
|
2023-12-18 16:29:00 +05:30
|
|
|
ChannelValue,
|
2023-04-10 16:37:13 +05:30
|
|
|
LocalValue,
|
|
|
|
|
RemoteValue,
|
|
|
|
|
ReferenceValue,
|
|
|
|
|
RemoteReferenceType,
|
|
|
|
|
RegExpValue,
|
2023-12-18 16:29:00 +05:30
|
|
|
SerializationOptions,
|
2023-04-10 16:37:13 +05:30
|
|
|
}
|