-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJavascriptApi.h
542 lines (441 loc) · 19.4 KB
/
JavascriptApi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
#pragma once
#include <string>
#include <map>
class JavascriptApi
{
public:
enum JSFuncs
{
JS_INVALID = 0,
JS_DOCK_EXECUTEJAVASCRIPT,
JS_DOCK_SETURL,
JS_QUERY_DOCKS,
JS_DOWNLOAD_ZIP,
JS_DOWNLOAD_FILE,
JS_INSTALL_FONT,
JS_READ_FILE,
JS_DELETE_FILES,
JS_DROP_FOLDER,
JS_QUERY_DOWNLOADS_FOLDER,
JS_GET_LOGS_REPORT_STRING,
JS_OBS_SOURCE_CREATE,
JS_OBS_SOURCE_DESTROY,
JS_DOCK_SETAREA,
JS_DOCK_RESIZE,
JS_DOCK_SWAP,
JS_DOCK_NEW_BROWSER_DOCK,
JS_GET_MAIN_WINDOW_GEOMETRY,
JS_TOGGLE_USER_INPUT,
JS_TOGGLE_DOCK_VISIBILITY,
JS_DESTROY_DOCK,
JS_DOCK_RENAME,
JS_DOCK_SETTITLE,
JS_SET_STREAMSETTINGS,
JS_GET_STREAMSETTINGS,
JS_START_WEBSERVER,
JS_STOP_WEBSERVER,
JS_LAUNCH_OS_BROWSER_URL,
JS_GET_AUTH_TOKEN,
JS_CLEAR_AUTH_TOKEN,
JS_SET_CURRENT_SCENE,
JS_GET_CURRENT_SCENE,
JS_CREATE_SCENE,
JS_SCENE_ADD,
JS_SCENE_GET_SOURCES,
JS_QUERY_ALL_SOURCES,
JS_QUERY_SCENES,
JS_SOURCE_GET_PROPERTIES,
JS_SOURCE_GET_SETTINGS,
JS_SOURCE_SET_SETTINGS,
JS_GET_SCENE_COLLECTIONS,
JS_GET_CURRENT_SCENE_COLLECTION,
JS_SET_CURRENT_SCENE_COLLECTION,
JS_ADD_SCENE_COLLECTION,
JS_SET_SCENEITEM_POS,
JS_SET_SCENEITEM_ROT,
JS_SET_SCENEITEM_CROP,
JS_SET_SCENEITEM_SCALE_FILTER,
JS_SET_SCENEITEM_BLENDING_MODE,
JS_SET_SCENEITEM_BLENDING_METHOD,
JS_SET_SCALE,
JS_GET_SCENEITEM_POS,
JS_GET_SCENEITEM_ROT,
JS_GET_SCENEITEM_CROP,
JS_GET_SCENEITEM_SCALE_FILTER,
JS_GET_SCENEITEM_BLENDING_MODE,
JS_GET_SCENEITEM_BLENDING_METHOD,
JS_GET_SCALE,
JS_GET_SOURCE_DIMENSIONS,
JS_GET_CANVAS_DIMENSIONS,
JS_BROWSER_RESIZE_BROWSER,
JS_OBS_BRING_FRONT,
JS_BROWSER_BRING_FRONT,
JS_BROWSER_SET_WINDOW_POSITION,
JS_OBS_TOGGLE_HIDE_SELF,
JS_BROWSER_SET_ALLOW_HIDE_BROWSER,
JS_OBS_ADD_TRANSITION,
JS_OBS_SET_CURRENT_TRANSITION,
JS_OBS_REMOVE_TRANSITION,
JS_GET_IS_OBS_STREAMING,
JS_TRANSITION_GET_SETTINGS,
JS_TRANSITION_SET_SETTINGS,
JS_ENUM_SCENES,
JS_RESTART_OBS,
JS_SL_VERSION_INFO,
JS_SAVE_SL_BROWSER_DOCKS,
JS_QT_SET_JS_ON_CLICK_STREAM,
JS_QT_INVOKE_CLICK_ON_STREAM_BUTTON,
JS_BROWSER_SET_HIDDEN_STATE,
};
public:
// Control over the plugin/OBS side
static std::map<std::string, JSFuncs> &getPluginFunctionNames()
{
// None of the api function belows are blocking, they return immediatelly, but can accept a function as arg1 thats invoked when work is complete, which should allow await/promise structure
static std::map<std::string, JSFuncs> names =
{
/***
* Docks
*/
// .(@function(arg1))
// Example arg1 = [{ "objectName": ".", "x": 0, "y": 0, "width": 0, "height": 0, "isSlabs": bool, "floating": bool, "url": ".", "visible": ".", "title": "." }]
{"dock_queryAll", JS_QUERY_DOCKS},
// .(@function(arg1), @objectName, @url)
// Only works on docks we've created
{"dock_setURL", JS_DOCK_SETURL},
// .(@function(arg1), @objectName, @jsString)
// Only works on docks we've created
{"dock_executeJavascript", JS_DOCK_EXECUTEJAVASCRIPT},
// .(@function(arg1), @objectName, @bool_visible)
{"dock_toggleDockVisibility", JS_TOGGLE_DOCK_VISIBILITY},
// Current release, OBS 29.1, does not have api support for destroying docks. Futurue releases will.
// .(@objectName)
// Only works on docks we've created
{"dock_destroyBrowserDock", JS_DESTROY_DOCK},
// .(@function(arg1), @title, @url, @objectName)
// Creates a new browser dock, its guid is the 'objectName', title is what the user sees. Will appear in their list of docks but not as a "Browser Dock", even though it works identically as one
// objectName is the unique identifer of the dock
{"dock_newBrowserDock", JS_DOCK_NEW_BROWSER_DOCK},
// .(@function(arg1), @objectName, @int_areaMask)
// areaMask can be a combination of Left Right Top Bottom, ie (LeftDockWidgetArea | RightDockWidgetArea) or (TopDockWidgetArea | BottomDockWidgetArea)
// These are the current values from Qt
// LeftDockWidgetArea = 0x1,
// RightDockWidgetArea = 0x2,
// TopDockWidgetArea = 0x4,
// BottomDockWidgetArea = 0x8,
// If the dock is floating then this will set that to false and place it somewhere
{"dock_setArea", JS_DOCK_SETAREA},
// .(@function(arg1), @objectName, @int_width, @int_height)
// Calls Qt 'resize' on the dock in question with w/h
{"dock_resize", JS_DOCK_RESIZE},
// .(@function(arg1), @objectName1, @objectName2)
// Swaps the the positions of dock1 with dock2
{"dock_swap", JS_DOCK_SWAP},
// .(@function(arg1), @objectName, @newName)
// Sets a dock's objectName
// !! DEPRECATED !!
// Not functional after OBS30, deprecated on all of our versions as of Feb 2024.
{"dock_rename", JS_DOCK_RENAME},
// .(@function(arg1), @objectName, @newTitle)
// Sets a dock's windowTitle
{"dock_setTitle", JS_DOCK_SETTITLE},
// .(@function(arg1)
// This is automatically done when the user gracefully closes the program
// However, the program might not gracefully close, so this can be used to save to their OBS config the existence of the docks
{"dock_saveSlabsBrowserDocks", JS_SAVE_SL_BROWSER_DOCKS},
/***
* Qt
*/
// .(@function(arg1))
// Returns the screen x,y and width/height of the main window
// Example arg1 = { "x": ".", "y": ".", "width": ".", "height": "." }
{"qt_getMainWindowGeometry", JS_GET_MAIN_WINDOW_GEOMETRY},
// .(@function(arg1), @str_javascriptCode)
// Assigns the code that will get excuted on the Browser Page whenever the Start Stream button is pressed.
// NOTE: You receive this message when the button is literally pressed, during a stream the button changes to "Stop Stream"
// Which means you are informed of clicks, not the meaning of the click
// NOTE: When this value is assigned to a non-null value, the Start Stream button will only execute your javascript. To actually go through with starting the stream, you msut do that.
// You have the ability to invoke "clicks" on that button. Therefore, if the button is ready for "Start Stream", invoking a click does that. If ready for a "Stop Stream" press, it does just that.
// You should be able to infer the state of button by obs functions for checking if a stream is active, etc
//
// This specific function, which just assigns a value, always returns back a 'success' json, its return value not important
{"qt_set_js_on_click_stream", JS_QT_SET_JS_ON_CLICK_STREAM},
// .(@function(arg1))
// Performs a literal ->click() on that Gui object
// Example arg1 = {"error", "activeModalWidget"}
// arg1 = {"status", "success"}
// (the button cannot be pressed if popups are locking up the GUI)
//
// Note that the "Start Stream" button is always the same button regardless of the stream running, the GUI text changes but it's always the same object even when it swaps to "Stop Streaming"
//
// NOTE: the "Start Stream" button in OBS sometimes throws a popup, and this function wont call back that popup is done
{"qt_click_stream_button", JS_QT_INVOKE_CLICK_ON_STREAM_BUTTON},
/***
* Windows
*/
// .(@function(arg1), @bool_enable)
// Disable/Enable user input to the window
{"win_toggleUserInput", JS_TOGGLE_USER_INPUT},
// .(@function(arg1))
// Launches a new OBS and terminates existing one at same time.
{"win_restartOBS", JS_RESTART_OBS},
/***
* Filesystem
*/
// .(@function(arg1), @url)
// Downloads and unpacks the zip, returning a list of full file paths to the files that were in it
// Example arg1 = [{ "path": "..." },]
{"fs_downloadZip", JS_DOWNLOAD_ZIP},
// .(@function(arg1), @url, @filename)
// Downloads file, returning a filepath to it
// Example arg1 = { "path": "..." }
{"fs_downloadFile", JS_DOWNLOAD_FILE},
// .(@function(arg1), @filepath)
// Performs 'AddFontResourceA' from the WinApi to the filepath in question
{"fs_installFont", JS_INSTALL_FONT},
// .(@function(arg1), @filepath)
// Returns the contents of a file as a string. If the filesize is over 1mb this will return an error
// Example arg1 = { "contents": "..." }
{"fs_readFile", JS_READ_FILE},
// .(@function(arg1), @filepaths_jsonStr)
// Json string, array, [{ path: "..." },] paths must be relative to the streamlabs download folder, ie "/download1234/file.png"
{"fs_deleteFiles", JS_DELETE_FILES},
// .(@function(arg1), @path)
// Path must be relative to the streamlabs download folder, ie "/download1234/"
{"fs_dropFolder", JS_DROP_FOLDER},
// .(@function(arg1))
// Returns comprehensive list of everything in our downloads folder
// Example arg1 = [{ "path": "..." },]
{"fs_queryDownloadsFolder", JS_QUERY_DOWNLOADS_FOLDER},
// .(@function(arg1))
// Returns a string that is a combination of log files
// Example arg1 = { "content": "about 1-5mb of text" }
{"fs_getLogsReportString", JS_GET_LOGS_REPORT_STRING},
/***
* obs
*/
// .(@function(arg1), @id, @name, @settings_jsonStr, @hotkey_data_jsonStr)
// Creates an obs source, also returns back some information about the source you just created if you want it
// Note that 'name' is also the guid of it, duplicates can't exist
// Example arg1 = { "settings_jsonStr": "obs_data_get_full_json()", "audio_mixers": "obs_source_get_audio_mixers()", "deinterlace_mode": "obs_source_get_deinterlace_mode()", "deinterlace_field_order": "obs_source_get_deinterlace_field_order()" }
{"obs_source_create", JS_OBS_SOURCE_CREATE},
// .(@function(arg1), name)
// Destroys an obs source with the name provided if it exists via obs_source_remove(name)
// NOTE: Can be used to destroy scenes/transition/colletions, as they are types of sources. In the case of scenes or scene colletions, obs_sceneitem_remove/obs_sceneitem_release on sources belonging to it akin to OSN scene remove
{"obs_source_destroy", JS_OBS_SOURCE_DESTROY},
// .(@function(arg1), @service, @protocol, @server, @bool_use_auth, @username, @password, @key)
// Revises stream settings with the provided params
// 'service' can be "rtmp_custom" : "rtmp_common"
{"obs_set_stream_settings", JS_SET_STREAMSETTINGS},
// .(@function(arg1))
// Returns json of service, protocol, server, bool_use_auth, username, password, key
{"obs_get_stream_settings", JS_GET_STREAMSETTINGS},
// .(@function(arg1), @sceneName)
// Performs 'obs_frontend_set_current_scene' on the scene in question
{"obs_set_current_scene", JS_SET_CURRENT_SCENE},
// .(@function(arg1))
// Example arg1 = { "name": "." }
{"obs_get_current_scene", JS_GET_CURRENT_SCENE},
// .(@function(arg1), @sceneName)
// Peforms literally obs_scene_create(sceneName)
{"obs_create_scene", JS_CREATE_SCENE},
// .(@function(arg1), @sceneName, @sourceName)
// Peforms literally obs_scene_add(sceneName, sourceName)
{"obs_scene_add", JS_SCENE_ADD},
// .(@function(arg1), @sceneName)
// Example arg1 = { "source_names": [] }
{"obs_scene_get_sources", JS_SCENE_GET_SOURCES},
// .(@function(arg1))
// OBS_SOURCE_TYPE_INPUT = 0
// OBS_SOURCE_TYPE_FILTER = 1
// Example arg1 = [ { "name": ".", "type": 0, "id": "." }, ... ]
//
// Tansition/scene are sources yet may not be a part of obs_enum_sources
// OBS_SOURCE_TYPE_TRANSITION = 2
// OBS_SOURCE_TYPE_SCENE = 3
{"obs_query_all_sources", JS_QUERY_ALL_SOURCES},
// .(@function(arg1))
// Example arg1 = [ { "name": ".", "type": 0, "id": "." }, ... ]
{"obs_enum_scenes", JS_ENUM_SCENES},
// .(@function(arg1)
// Not yet implemented
{"obs_source_get_properties_json", JS_SOURCE_GET_PROPERTIES},
// .(@function(arg1), @sourceName)
// Iterates the settings of a source and returns them as a json strong
// Example arg1 = <settings>
{"obs_source_get_settings_json", JS_SOURCE_GET_SETTINGS},
// .(@function(arg1), @json_settings, @sourceName)
// Applies the json data into the source settings
{"obs_source_set_settings_json", JS_SOURCE_SET_SETTINGS},
// .(@function(arg1))
// Example arg1 = [{ "name": "..." },]
{"obs_get_scene_collections", JS_GET_SCENE_COLLECTIONS},
// .(@function(arg1))
// Example arg1 = [{ "name": "..." }
{"obs_get_current_scene_collection", JS_GET_CURRENT_SCENE_COLLECTION},
// .(@function(arg1), @sceneName)
{"obs_set_current_scene_collection", JS_SET_CURRENT_SCENE_COLLECTION},
// .(@function(arg1), @sceneName)
{"obs_add_scene_collection", JS_ADD_SCENE_COLLECTION},
// .(@function(arg1), @sceneName, @sourceName, @decimal_x, @decimal_y)
{"obs_sceneitem_set_pos", JS_SET_SCENEITEM_POS},
// .(@function(arg1), @sceneName, @sourceName, @decimal_rot)
{"obs_sceneitem_set_rot", JS_SET_SCENEITEM_ROT},
// .(@function(arg1), @sceneName, @sourceName, @int_left, @int_top, @int_right, @int_bottom)
{"obs_sceneitem_set_crop", JS_SET_SCENEITEM_CROP},
// .(@function(arg1), @sceneName, @sourceName, @decimal_x, @decimal_y)
{"obs_sceneitem_set_scale", JS_SET_SCALE},
// .(@function(arg1), @sceneName, @sourceName, @int_scaleType)
// OBS_SCALE_DISABLE = 1
// OBS_SCALE_POINT = 2
// OBS_SCALE_BICUBIC = 3
// OBS_SCALE_BILINEAR = 4
// OBS_SCALE_LANCZOS = 5
// OBS_SCALE_AREA = 6
{"obs_sceneitem_set_scale_filter", JS_SET_SCENEITEM_SCALE_FILTER},
// .(@function(arg1), @sceneName, @sourceName, @int_blendingType)
// OBS_BLEND_NORMAL = 1
// OBS_BLEND_ADDITIVE = 2
// OBS_BLEND_SUBTRACT = 3
// OBS_BLEND_SCREEN = 4
// OBS_BLEND_MULTIPLY = 5
// OBS_BLEND_LIGHTEN = 6
// OBS_BLEND_DARKEN = 7
{"obs_sceneitem_set_blending_mode", JS_SET_SCENEITEM_BLENDING_MODE},
// .(@function(arg1), @sceneName, @sourceName, @int_blendingMethod)
// OBS_BLEND_METHOD_DEFAULT = 1
// OBS_BLEND_METHOD_SRGB_OFF = 2
{"obs_sceneitem_set_blending_method", JS_SET_SCENEITEM_BLENDING_METHOD},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "x": 0.0, "y": 0.0 }
{"obs_sceneitem_get_pos", JS_GET_SCENEITEM_POS},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "rotation": 0.0 }
{"obs_sceneitem_get_rot", JS_GET_SCENEITEM_ROT},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "left": 0.0, "right": 0.0, "top": 0.0, "bottom": 0.0 }
{"obs_sceneitem_get_crop", JS_GET_SCENEITEM_CROP},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "x": 0.0, "y": 0.0 }
{"obs_sceneitem_get_scale", JS_GET_SCALE},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "scale_filter": 0 }
{"obs_sceneitem_get_scale_filter", JS_GET_SCENEITEM_SCALE_FILTER},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "blending_mode": 0 }
{"obs_sceneitem_get_blending_mode", JS_GET_SCENEITEM_BLENDING_MODE},
// .(@function(arg1), @sceneName, @sourceName)
// Example arg1 = { "blending_method": 0 }
{"obs_sceneitem_get_blending_method", JS_GET_SCENEITEM_BLENDING_METHOD},
// .(@function(arg1), @sourceName)
// Example arg1 = { "width": 0, "height": 0 }
{"obs_source_get_dimensions", JS_GET_SOURCE_DIMENSIONS},
// .(@function(arg1))
// Example arg1 = { "width": 0, "height": 0 }
{"obs_canvas_get_dimensions", JS_GET_CANVAS_DIMENSIONS},
// .(@function(arg1))
{"obs_bring_front", JS_OBS_BRING_FRONT},
// .(@function(arg1), @bool_hide)
{"obs_toggle_hide_self", JS_OBS_TOGGLE_HIDE_SELF},
// .(@function(arg1), @id, @sourceName)
// @id must be correct or application will crash, ie "swipe_transition" is one example
{"obs_add_transition", JS_OBS_ADD_TRANSITION},
// .(@function(arg1), @sourceName)
{"obs_set_current_transition", JS_OBS_SET_CURRENT_TRANSITION},
// .(@function(arg1), @sourceName)
{"obs_remove_transition", JS_OBS_REMOVE_TRANSITION},
// .(@function(arg1), @sourceName)
// Iterates the settings of a source and returns them as a json strong
// Example arg1 = <settings>
{"obs_transition_get_settings_json", JS_TRANSITION_GET_SETTINGS},
// .(@function(arg1), @json_settings, @sourceName)
// Applies the json data into the source settings
{"obs_transition_set_settings_json", JS_TRANSITION_SET_SETTINGS},
// .(@function(arg1))
// Returns the boolean value of the named obs function
// Example arg1 = { "value": true }
{"obs_frontend_streaming_active", JS_GET_IS_OBS_STREAMING},
/***
* Web
*/
// .(@function(arg1), port, expectedReferer, redirectUrl)
// Only one can exist at a time (do we need multiple? lmk)
// 'port', ie http://localhost:port, if you assign port 0 then the OS will choose one (value is returned in function arg1)
// 'expectedReferer' is the prefix you want chopped off leading to the token. If the you set this to "/?" and the incoming HTTP request is "GET /?success=true HTTP/1.1", you get back "success=true" - you get everything up to " HTTP/1.1" in that example.
// 'redirectUrl' is where you want them to be redirected to whenever accessing 'http://localhost:port'
// Example arg1 = { "port": 12345 }
//
// NOTE: Calling this while it's running will simply update new 'expectedReferer' and 'redirectUrl' values and return the port again.
{"web_startServer", JS_START_WEBSERVER},
// .(@function(arg1))
// Stops the webserver
{"web_stopServer", JS_STOP_WEBSERVER},
// .(@function(arg1), @url)
// Launches their default browser with the URL supplied using ShellExecuteA, any errors returned are according to ShellExecuteA winapi doc
{"web_launchOSBrowserUrl", JS_LAUNCH_OS_BROWSER_URL},
// .(@function(arg1))
// Example arg1 = { "token": "." }
{"web_getAuthToken", JS_GET_AUTH_TOKEN},
// .(@function(arg1))
{"web_clearAuthToken", JS_CLEAR_AUTH_TOKEN},
/***
* Streamlabs
*/
// .(@function(arg1))
// Example arg1 = { "branch": '29.1.0', "git_sha": 'abcdefg...', "rev": '10' }
// DEV NOTE: THIS FUNCTION CAN NEVER BE RENAMED !!
{"sl_getVersionInfo", JS_SL_VERSION_INFO},
};
return names;
}
// Control over our the browser
static std::map<std::string, JSFuncs> &getBrowserFunctionNames()
{
// None of the api function belows are blocking, they return immediatelly, but can accept a function as arg1 thats invoked when work is complete, which should allow await/promise structure
static std::map<std::string, JSFuncs> names =
{
/**
* Browser Window
*/
// .(@function(arg1), x, y)`
{"browser_resizeBrowser", JS_BROWSER_RESIZE_BROWSER},
// .(@function(arg1))`
// DEV NOTE: THIS FUNCTION CAN NEVER BE RENAMED !!
{"browser_bringToFront", JS_BROWSER_BRING_FRONT},
// .(@function(arg1), x, y)`
{"browser_setWindowPosition", JS_BROWSER_SET_WINDOW_POSITION},
// .(@function(arg1), bool)`
{"browser_setAllowHideBrowser", JS_BROWSER_SET_ALLOW_HIDE_BROWSER},
// .(@function(arg1), bool)`
// DEV NOTE: THIS FUNCTION MUST NEVER BE RENAMED !!
{"browser_setHiddenState", JS_BROWSER_SET_HIDDEN_STATE},
};
return names;
}
static bool isValidFunctionName(const std::string &str)
{
return isPluginFunctionName(str) || isBrowserFunctionName(str);
}
static bool isPluginFunctionName(const std::string &str)
{
auto ref = getPluginFunctionNames();
return ref.find(str) != ref.end();
}
static bool isBrowserFunctionName(const std::string &str)
{
auto ref = getBrowserFunctionNames();
return ref.find(str) != ref.end();
}
static JSFuncs getFunctionId(const std::string &funcName)
{
auto ref = getPluginFunctionNames();
auto itr = ref.find(funcName);
if (itr != ref.end())
return itr->second;
ref = getBrowserFunctionNames();
itr = ref.find(funcName);
if (itr != ref.end())
return itr->second;
return JS_INVALID;
}
};