Skip to content

Commit

Permalink
Move to rourltransfer object
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jun 4, 2024
1 parent 8bfc1ed commit 4b0aa7a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
29 changes: 17 additions & 12 deletions scripts/scrape-roku-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,16 +1180,7 @@ class Runner {
}
},
components: {
roregion: {
interfaces: [{
name: 'ifDraw2D',
url: 'https://developer.roku.com/docs/references/brightscript/interfaces/ifdraw2d.md'
}]
}
},
events: {},
interfaces: {
ifsetmessageport: {
rourltransfer: {
methods: [{
description: 'DEPRECATED: use `.SetMessagePort()` instead. \n\nSets the roMessagePort to be used to receive events',
isDeprecated: true,
Expand All @@ -1204,9 +1195,19 @@ class Runner {
'type': 'Object'
}
],
returnType: 'Void'
returnType: 'Void',
returnDescription: undefined
}]
},
roregion: {
interfaces: [{
name: 'ifDraw2D',
url: 'https://developer.roku.com/docs/references/brightscript/interfaces/ifdraw2d.md'
}]
} as Partial<RokuInterface>,
}
} as Record<string, Partial<BrightScriptComponent>>,
events: {},
interfaces: {
ifsgnodechildren: {
methods: [{
name: 'update',
Expand Down Expand Up @@ -1778,6 +1779,10 @@ interface BrightScriptComponent extends PossiblyDeprecated {
description: string;
constructors: Array<Signature>;
interfaces: Reference[];
/**
* Most components only get their methods from interfaces, but occasionally we need to attach one
*/
methods: Func[];
events: Reference[];
}

Expand Down
11 changes: 11 additions & 0 deletions src/files/BrsFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5133,4 +5133,15 @@ describe('BrsFile', () => {
).to.be.false;
});
});

it('handles deprecated .setPort() on rourltransfer', () => {
program.setFile('source/main.bs', `
function main()
url = createObject("roUrlTransfer") as roUrlTransfer
url.setPort(80)
end function
`);
program.validate();
expectZeroDiagnostics(program);
});
});
36 changes: 19 additions & 17 deletions src/roku-types/data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedDate": "2024-06-03T20:53:52.847Z",
"generatedDate": "2024-06-04T12:31:13.858Z",
"nodes": {
"animation": {
"description": "Extends [**AnimationBase**](https://developer.roku.com/docs/references/scenegraph/abstract-nodes/animationbase.md\n\nThe Animation node class provides animations of renderable nodes, by applying interpolator functions to the values in specified renderable node fields. For an animation to take effect, an Animation node definition must include a child field interpolator node ([FloatFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/floatfieldinterpolator.md\"FloatFieldInterpolator\"), [Vector2DFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/vector2dfieldinterpolator.md\"Vector2DFieldInterpolator\"), [ColorFieldInterpolator](https://developer.roku.com/docs/references/scenegraph/animation-nodes/colorfieldinterpolator.md\"ColorFieldInterpolator\")) definition for each renderable node field that is animated.\n\nThe Animation node class provides a simple linear interpolator function, where the animation takes place smoothly and simply from beginning to end. The Animation node class also provides several more complex interpolator functions to allow custom animation effects. For example, you can move a graphic image around the screen at differing speeds and curved trajectories at different times in the animation by specifying the appropriate function in the easeFunction field (quadratic and exponential are two examples of functions that can be specified). The interpolator functions are divided into two parts: the beginning of the animation (ease-in), and the end of the animation (ease-out). You can apply a specified interpolator function to either or both ease-in and ease-out, or specify no function for either or both (which is the linear function). You can also change the portion of the animation that is ease-in and ease-out to arbitrary fractional values for a quadratic interpolator function applied to both ease-in and ease-out.",
Expand Down Expand Up @@ -8813,6 +8813,24 @@
"url": "https://developer.roku.com/docs/references/brightscript/interfaces/ifurltransfer.md"
}
],
"methods": [
{
"deprecatedDescription": "Use .SetMessagePort instead. Some legacy objects still implement the older `SetPort` function, but apps should not be using it.",
"description": "DEPRECATED: use `.SetMessagePort()` instead. \n\nSets the roMessagePort to be used to receive events",
"isDeprecated": true,
"name": "SetPort",
"params": [
{
"default": null,
"description": "The port to be used to receive events.",
"isRequired": true,
"name": "port",
"type": "Object"
}
],
"returnType": "Void"
}
],
"name": "roUrlTransfer",
"url": "https://developer.roku.com/docs/references/brightscript/components/rourltransfer.md"
},
Expand Down Expand Up @@ -14504,22 +14522,6 @@
}
],
"returnType": "Void"
},
{
"deprecatedDescription": "Use .SetMessagePort instead. Some legacy objects still implement the older `SetPort` function, but apps should not be using it.",
"description": "DEPRECATED: use `.SetMessagePort()` instead. \n\nSets the roMessagePort to be used to receive events",
"isDeprecated": true,
"name": "SetPort",
"params": [
{
"default": null,
"description": "The port to be used to receive events.",
"isRequired": true,
"name": "port",
"type": "Object"
}
],
"returnType": "Void"
}
],
"name": "ifSetMessagePort",
Expand Down
9 changes: 8 additions & 1 deletion src/types/BuiltInInterfaceAdder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export class BuiltInInterfaceAdder {
}
const interfacesToLoop = builtInComponent.interfaces ?? [builtInComponent];

//add any direct methods from this component to the member table
for (const method of builtInComponent.methods ?? []) {
const methodFuncType = this.buildMethodFromDocData(method, overrides, thisType);
builtInMemberTable.addSymbol(method.name, { description: method.description, completionPriority: 1 }, methodFuncType, SymbolTypeFlag.runtime);
}

for (const iface of interfacesToLoop) {
const lowerIfaceName = iface.name.toLowerCase();
const ifaceData = (interfaces[lowerIfaceName] ?? events[lowerIfaceName]) as BRSInterfaceData;
Expand Down Expand Up @@ -147,7 +153,8 @@ export class BuiltInInterfaceAdder {
}
}

static getMatchingRokuComponent(theType: BscType) {
//the return type is a union of the three data types. Just pick the first item from each collection, as every item in the collection should have the same shape
static getMatchingRokuComponent(theType: BscType): typeof components['roappinfo'] & typeof interfaces['ifappinfo'] & typeof events['rourlevent'] {
const componentName = this.getMatchingRokuComponentName(theType);
if (!componentName) {
// No component matches the given type
Expand Down

0 comments on commit 4b0aa7a

Please sign in to comment.