About the wrapper:
- Line 36:
chrome.webview.hostObjects.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
Should be (missing .sync.):
chrome.webview.hostObjects.sync.foo_uie_webview.execute(filePath, parameters, directoryPath, operation, showMode);
- Same error at line 74 and 84
- Class MediaLibrary, I would say this method should be getter (unless I misunderstood something, it returns directly a property and is not a method: isEnabled
- Class Foobar2000, should be getters: canReadFiles, canReadDirectories, canExecuteShellOperations
- As commented by PM, the MetaDBHandleList constructor may need additional things if you plan to add methods to remove/add handles to it. In any case, the count could be internally cached. Since it's fixed at creation and only changes whenever you add/remove items (which can only happen under user request by specific code).
- MetaDBHandleList: I think at release method you should also delete the actual pointers in the object, otherwise the object itself will be pointing to another undefined object. As result doing things like:
const handleList = MetaDBHandleList(...);
handleList.release();
handleList.count; // 50 but it's not true xd It should either throw or report 0
Will probably either crash your component unless you check all the inputs to be valid (not sure if you are already doing that), crash the JS logic or simply behave wrong. After .release(), this.Source points to a non existent entity, with no indexes. All the properties of the parent should be deleted or set to safe values.
this.release = function () // Using any method or getter will return safe values and do nothing
{
const n = this.count;
for (let i = 0; i < n; ++i) {delete this[i];}
this.count = 0; // Choosing this instead of void to not invalidate the iterator
this.release = () => void(0);
WebView.releaseMetaDBHandleList(this.Source);
this.Source = void(0);
};
or just
this.release = function () // Using anything will either throw or return undefined
{
WebView.releaseMetaDBHandleList(this.Source);
Object.keys(this).forEach((key) => delete this.key);
};
- Let me know if you want me to create a pull request to wrap the methods to create handleList and all that directly from WebView as discussed by PM.
- And just a note about the JSdoc comments, if they are supposed to work in VScode, using Object.defineProperty for methods/getters and adding comments above will not make them work on intellisense. You have to "reference" them first (I have tried many other supposed workarounds with @name, etc. but they don't work for me at least). Check the images:
/**
Gets the path.
@type {string}
**/
this.path; // It doesn't mind whether it's set as undefined or just accessed.
Object.defineProperty(this, 'path',
{
get() { return WebView.getMetaDBHandlePath(this.Source); }
});
- I would also recommend this at the wrapper, which simplifies usage a lot:
const WebView = chrome.webview.hostObjects.sync.foo_uie_webview;