Skip to content

Commit

Permalink
Merge branch 'develop' into feat/loadable-modules2
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 21, 2025
2 parents 4fff80d + 4c297bc commit 980e427
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 189 deletions.
2 changes: 1 addition & 1 deletion bundled-modules
Submodule bundled-modules updated 49 files
+1 −1 .github/ISSUE_TEMPLATE/config.yml
+0 −47 .github/ISSUE_TEMPLATE/module_upgrade.yaml
+3 −3 figure53-qlab-advance/.build-info
+5 −2 figure53-qlab-advance/companion/HELP.md
+1 −1 figure53-qlab-advance/companion/manifest.json
+1 −1 figure53-qlab-advance/main.js
+1 −1 figure53-qlab-advance/package.json
+4 −0 fivem-console/.build-info
+5 −0 fivem-console/companion/HELP.md
+1 −0 fivem-console/companion/manifest.json
+1 −0 fivem-console/main.js
+1 −0 fivem-console/package.json
+4 −0 libreoffice-impress/.build-info
+49 −0 libreoffice-impress/companion/HELP.md
+1 −0 libreoffice-impress/companion/manifest.json
+1 −0 libreoffice-impress/main.js
+1 −0 libreoffice-impress/package.json
+3 −3 osee-gostream/.build-info
+1 −1 osee-gostream/companion/manifest.json
+1 −1 osee-gostream/main.js
+1 −1 osee-gostream/package.json
+4 −0 philips-sicp/.build-info
+81 −0 philips-sicp/companion/HELP.md
+1 −0 philips-sicp/companion/manifest.json
+1 −0 philips-sicp/main.js
+1 −0 philips-sicp/package.json
+3 −3 roland-p20hd/.build-info
+57 −53 roland-p20hd/companion/HELP.md
+1 −1 roland-p20hd/companion/manifest.json
+1 −2 roland-p20hd/main.js
+0 −6 roland-p20hd/main.js.LICENSE.txt
+1 −1 roland-p20hd/package.json
+3 −3 singularlive-studio/.build-info
+1 −1 singularlive-studio/companion/manifest.json
+1 −1 singularlive-studio/main.js
+1 −1 singularlive-studio/package.json
+3 −3 socialstream-ninja/.build-info
+1 −1 socialstream-ninja/companion/manifest.json
+1 −1 socialstream-ninja/main.js
+1 −1 socialstream-ninja/package.json
+3 −3 studiocoast-vmix/.build-info
+1 −1 studiocoast-vmix/companion/manifest.json
+1 −1 studiocoast-vmix/main.js
+1 −1 studiocoast-vmix/package.json
+3 −3 zoom-osc-iso/.build-info
+129 −88 zoom-osc-iso/companion/HELP.md
+1 −1 zoom-osc-iso/companion/manifest.json
+1 −1 zoom-osc-iso/main.js
+1 −1 zoom-osc-iso/package.json
22 changes: 10 additions & 12 deletions companion/lib/Controls/ControlTypes/Button/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,19 @@ export abstract class ButtonControlBase<TJson, TOptions extends Record<string, a
}

if (style.textExpression) {
try {
const parseResult = this.deps.variables.values.executeExpression(
style.text,
location,
undefined,
injectedVariableValues
)
const parseResult = this.deps.variables.values.executeExpression(
style.text,
location,
undefined,
injectedVariableValues
)
if (parseResult.ok) {
style.text = parseResult.value + ''
this.last_draw_variables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null
} catch (e) {
this.logger.error(`Expression parse error: ${e}`)

} else {
this.logger.error(`Expression parse error: ${parseResult.error}`)
style.text = 'ERR'
this.last_draw_variables = null
}
this.last_draw_variables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null
} else {
const parseResult = this.deps.variables.values.parseVariables(style.text, location, injectedVariableValues)
style.text = parseResult.text
Expand Down
9 changes: 4 additions & 5 deletions companion/lib/Instance/Definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,11 @@ export class InstanceDefinitions {

if (style.text) {
if (style.textExpression) {
try {
const parseResult = this.#variablesValuesController.executeExpression(style.text, null)
const parseResult = this.#variablesValuesController.executeExpression(style.text, null)
if (parseResult.ok) {
style.text = parseResult.value + ''
} catch (e) {
this.#logger.error(`Expression parse error: ${e}`)

} else {
this.#logger.error(`Expression parse error: ${parseResult.error}`)
style.text = 'ERR'
}
} else {
Expand Down
17 changes: 9 additions & 8 deletions companion/lib/Internal/BuildingBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,17 @@ export class InternalBuildingBlocks implements InternalModuleFragment {
if (action.definitionId === 'wait') {
if (extras.abortDelayed.aborted) return true

let delay = 0
try {
delay = Number(
this.#internalModule.executeExpressionForInternalActionOrFeedback(action.rawOptions.time, extras, 'number')
.value
)
} catch (e: any) {
this.#logger.error(`Failed to parse delay: ${e.message}`)
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
action.rawOptions.time,
extras,
'number'
)
if (!expressionResult.ok) {
this.#logger.error(`Failed to parse delay: ${expressionResult.error}`)
}

let delay = expressionResult.ok ? Number(expressionResult.value) : 0

if (!isNaN(delay) && delay > 0) {
// Perform the wait
return new Promise((resolve) => setTimeout(resolve, delay)).then(() => true)
Expand Down
4 changes: 2 additions & 2 deletions companion/lib/Internal/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
import type { RunActionExtras } from '../Instance/Wrapper.js'
import type { CompanionVariableValue, CompanionVariableValues } from '@companion-module/base'
import type { ControlsController, NewFeedbackValue } from '../Controls/Controller.js'
import type { VariablesCache } from '../Variables/Util.js'
import type { ExecuteExpressionResult, VariablesCache } from '../Variables/Util.js'
import type { ParseVariablesResult } from '../Variables/Util.js'
import type { ControlLocation } from '@companion-app/shared/Model/Common.js'
import type { VariablesController } from '../Variables/Controller.js'
Expand Down Expand Up @@ -563,7 +563,7 @@ export class InternalController {
extras: RunActionExtras | FeedbackEntityModelExt,
requiredType?: string,
injectedVariableValues?: CompanionVariableValues
): { value: boolean | number | string | undefined; variableIds: Set<string> } {
): ExecuteExpressionResult {
if (!this.#initialized) throw new Error(`InternalController is not initialized`)

const injectedVariableValuesComplete = {
Expand Down
26 changes: 18 additions & 8 deletions companion/lib/Internal/Controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ export class InternalControls implements InternalModuleFragment {
let thePage = options.page

if (options.page_from_variable) {
thePage = this.#internalModule.executeExpressionForInternalActionOrFeedback(
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
options.page_variable,
extras,
'number'
).value
)
if (!expressionResult.ok) throw new Error(expressionResult.error)
thePage = expressionResult.value
}

if (thePage === 0 || thePage === '0') thePage = extras.location?.pageNumber ?? null
Expand Down Expand Up @@ -219,11 +221,13 @@ export class InternalControls implements InternalModuleFragment {
let theStep = options.step

if (options.step_from_expression) {
theStep = this.#internalModule.executeExpressionForInternalActionOrFeedback(
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
options.step_expression,
extras,
'number'
).value
)
if (!expressionResult.ok) throw new Error(expressionResult.error)
theStep = expressionResult.value
}

return theStep
Expand Down Expand Up @@ -909,11 +913,14 @@ export class InternalControls implements InternalModuleFragment {

const forcePress = !!action.rawOptions.force

const pressIt = !!this.#internalModule.executeExpressionForInternalActionOrFeedback(
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
action.rawOptions.expression,
extras,
'boolean'
).value
)
if (!expressionResult.ok) throw new Error(expressionResult.error)

const pressIt = !!expressionResult.value

if (pressIt) {
this.#controlsController.pressControl(theControlId, true, extras.surfaceId, forcePress)
Expand Down Expand Up @@ -1117,11 +1124,14 @@ export class InternalControls implements InternalModuleFragment {

const control = this.#controlsController.getControl(theControlId)

const pressIt = !!this.#internalModule.executeExpressionForInternalActionOrFeedback(
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
action.rawOptions.expression,
extras,
'boolean'
).value
)
if (!expressionResult.ok) throw new Error(expressionResult.error)

const pressIt = !!expressionResult.value

if (pressIt) {
if (control && control.supportsActionSets) {
Expand Down
14 changes: 7 additions & 7 deletions companion/lib/Internal/CustomVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ export class InternalCustomVariables implements InternalModuleFragment {
}
return true
} else if (action.definitionId === 'custom_variable_set_expression') {
try {
const result = this.#internalModule.executeExpressionForInternalActionOrFeedback(
action.rawOptions.expression,
extras
)
const result = this.#internalModule.executeExpressionForInternalActionOrFeedback(
action.rawOptions.expression,
extras
)
if (result.ok) {
this.#variableController.custom.setValue(action.rawOptions.name, result.value)
} catch (error: any) {
this.#logger.warn(`${error.toString()}, in expression: "${action.rawOptions.expression}"`)
} else {
this.#logger.warn(`${result.error}, in expression: "${action.rawOptions.expression}"`)
}

return true
Expand Down
8 changes: 6 additions & 2 deletions companion/lib/Internal/Surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,13 @@ export class InternalSurface implements InternalModuleFragment {
let thePageNumber: number | string | undefined = options.page

if (useVariableFields && options.page_from_variable) {
thePageNumber = Number(
this.#internalModule.executeExpressionForInternalActionOrFeedback(options.page_variable, extras, 'number').value
const expressionResult = this.#internalModule.executeExpressionForInternalActionOrFeedback(
options.page_variable,
extras,
'number'
)
if (!expressionResult.ok) throw new Error(expressionResult.error)
thePageNumber = Number(expressionResult.value)
}

if (extras.location) {
Expand Down
21 changes: 10 additions & 11 deletions companion/lib/Internal/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,18 @@ export function ParseInternalControlReference(
break
case 'expression':
if (useVariableFields) {
try {
const result = variablesController.executeExpression(
options.location_expression,
pressLocation,
'string',
injectedVariableValues
)

const result = variablesController.executeExpression(
options.location_expression,
pressLocation,
'string',
injectedVariableValues
)
if (result.ok) {
location = parseLocationString(String(result.value))
referencedVariables = Array.from(result.variableIds)
} catch (error: any) {
logger.warn(`${error.toString()}, in expression: "${options.location_expression}"`)
} else {
logger.warn(`${result.error}, in expression: "${options.location_expression}"`)
}
referencedVariables = Array.from(result.variableIds)
}
break
}
Expand Down
14 changes: 5 additions & 9 deletions companion/lib/Internal/Variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,15 @@ export class InternalVariables implements InternalModuleFragment {

return compareValues(feedback.options.op, result1.text, result2.text)
} else if (feedback.definitionId == 'check_expression') {
try {
const res = this.#variableController.executeExpression(
feedback.options.expression,
feedback.location,
'boolean'
)
const res = this.#variableController.executeExpression(feedback.options.expression, feedback.location, 'boolean')

this.#variableSubscriptions.set(feedback.id, Array.from(res.variableIds))
this.#variableSubscriptions.set(feedback.id, Array.from(res.variableIds))

if (res.ok) {
return !!res.value
} catch (e) {
} else {
const logger = LogController.createLogger(`Internal/Variables/${feedback.controlId}`)
logger.warn(`Failed to execute expression "${feedback.options.expression}": ${e}`)
logger.warn(`Failed to execute expression "${feedback.options.expression}": ${res.error}`)

return false
}
Expand Down
15 changes: 7 additions & 8 deletions companion/lib/Surface/IP/Satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,16 @@ export class SurfaceIPSatellite extends EventEmitter<SurfacePanelEvents> impleme
let expressionResult: CompanionVariableValue | undefined = VARIABLE_UNKNOWN_VALUE

const expressionText = this.#config[outputVariable.id]
try {
const parseResult = this.#executeExpression(expressionText ?? '', this.info.deviceId, undefined)
const parseResult = this.#executeExpression(expressionText ?? '', this.info.deviceId, undefined)
if (parseResult.ok) {
expressionResult = parseResult.value

outputVariable.lastReferencedVariables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null
} catch (e) {
this.#logger.error(`expression parse error: ${e}`)

outputVariable.lastReferencedVariables = null
} else {
this.#logger.error(`expression parse error: ${parseResult.error}`)
expressionResult = VARIABLE_UNKNOWN_VALUE
}

outputVariable.lastReferencedVariables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null

// Only send if the value has changed
if (outputVariable.lastValue === expressionResult) return
outputVariable.lastValue = expressionResult
Expand Down
3 changes: 2 additions & 1 deletion companion/lib/Surface/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { DataUserConfig } from '../Data/UserConfig.js'
import type { GraphicsController } from '../Graphics/Controller.js'
import type { PageController } from '../Page/Controller.js'
import type { VariablesController } from '../Variables/Controller.js'
import type { ExecuteExpressionResult } from '../Variables/Util.js'

export type SurfacePanelFactory = {
create: (path: string, options: LocalUSBDeviceOptions) => Promise<SurfacePanel>
Expand All @@ -25,7 +26,7 @@ export type SurfaceExecuteExpressionFn = (
str: string,
surfaceId: string,
injectedVariableValues?: CompanionVariableValues
) => { value: CompanionVariableValue | undefined; variableIds: Set<string> }
) => ExecuteExpressionResult

export interface SurfacePanelInfo {
deviceId: string
Expand Down
13 changes: 5 additions & 8 deletions companion/lib/Surface/USB/BlackmagicController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,13 @@ export class SurfaceUSBBlackmagicController extends EventEmitter<SurfacePanelEve
let expressionResult: CompanionVariableValue | undefined = 0

const expressionText = this.config.tbarLeds
try {
const parseResult = this.#executeExpression(expressionText ?? '', this.info.deviceId, undefined)
const parseResult = this.#executeExpression(expressionText ?? '', this.info.deviceId, undefined)
if (parseResult.ok) {
expressionResult = parseResult.value

this.#lastTbarDrawReferencedVariables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null
} catch (e) {
this.#logger.error(`T-bar expression parse error: ${e}`)

this.#lastTbarDrawReferencedVariables = null
} else {
this.#logger.error(`T-bar expression parse error: ${parseResult.error}`)
}
this.#lastTbarDrawReferencedVariables = parseResult.variableIds.size > 0 ? parseResult.variableIds : null

let ledValues = new Array(tbarControl.ledSegments).fill(false)
const fillLedCount = Number(expressionResult)
Expand Down
Loading

0 comments on commit 980e427

Please sign in to comment.