You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New window is opened from parent window. Webchimera module is loaded but exception ensuses because its window object points to parent window. That is because NW.js caches its modules. I get that. So I tried clearing cache both manually and with require-new module, doesn't matter. The wcjs-player module keeps pointing to parent window object no matter what I do.
PARENT
<div id="chimera_container"></div>
...
var gui; // global variable for parent object
var wjs; // global variable for parent object
....
gui = require('nw.gui');
wjs = wjs = require('wcjs-player');
....
video_emit = gui.Window.open('video_emit.html',{
"window" : {
"focus": true,
"toolbar": true,
"frame": true,
"width" : 640,
"height" : 640
},
"dependencies": {
"require-new": "^1.1.0",
"wcjs-player": "^0.5.6"
},
});
video_emit window
<div id="vid"></div>
....
var wjs; // global variable for new window object
wjs = require('wcjs-player');
video_container = new wjs("#vid"); <---- Exception because it can't find the #vid div because window.document points to parent window.document
:(
In the node_modules\wcjs-player\index.js line 82 I added console.log(window.document);
PARENT CONSOLE OUTPUT
#document
...
<div id="chimera_container"></div>
video_emit CONSOLE OUTPUT
#document
...
<div id="chimera_container"></div>
Solutions tried
Manually clearing cache
Calling function clearRequiredModulesbefore requiring 'wcjs-player' module on video_emit window.
var clearRequiredModules = function(){
// clear wcjs-player from require cache to force new load
var clearModules = [
"wcjs-player",
"jquery" // https://github.com/jaruba/wcjs-player/issues/38
];
for (var i in clearModules) {
for (var module in global.require.cache) {
if ( global.require.cache.hasOwnProperty(module)
&& module.indexOf(clearModules[i]) > -1
)
delete global.require.cache[module];
}
}
};
Not working. Same problem as if I hadn't cleared at all. wcjs-player module still points to parent window object.
Using require-new module
There's no science to this code, I load module and use it in video_emit window.
var req_new = require('require-new');
wjs = req_new('wcjs-player');
Same problem. Nothing changes.
I've tried install the wcjs-player module with a different name and loading them separately (as if they were different modules). Using one for each window, didn't matter. Same problem. The only way it works is if I simply make video_emit the first window to open up (by setting it as main in the package.json file). But then if I open a new window and try to load the module, I'm back at square one. That module only points to the window of the first window to open up.
I know that adding new-instance: true to the gui.Window.open of the parent would fix this, but I need parent and new window to communicate via the global variable usable only if they are on the same render.
This is driving me nuts. I don't even know where to look for the problem. Thanks for the help.
The text was updated successfully, but these errors were encountered:
Environment
Problem
New window is opened from parent window. Webchimera module is loaded but exception ensuses because its window object points to parent window. That is because NW.js caches its modules. I get that. So I tried clearing cache both manually and with require-new module, doesn't matter. The wcjs-player module keeps pointing to parent window object no matter what I do.
PARENT
video_emit window
:(
In the node_modules\wcjs-player\index.js line 82 I added
console.log(window.document);
PARENT CONSOLE OUTPUT
video_emit CONSOLE OUTPUT
Solutions tried
Manually clearing cache
Calling function clearRequiredModulesbefore requiring 'wcjs-player' module on video_emit window.
Not working. Same problem as if I hadn't cleared at all. wcjs-player module still points to parent window object.
Using require-new module
There's no science to this code, I load module and use it in video_emit window.
Same problem. Nothing changes.
I've tried install the wcjs-player module with a different name and loading them separately (as if they were different modules). Using one for each window, didn't matter. Same problem. The only way it works is if I simply make video_emit the first window to open up (by setting it as main in the package.json file). But then if I open a new window and try to load the module, I'm back at square one. That module only points to the window of the first window to open up.
I know that adding new-instance: true to the gui.Window.open of the parent would fix this, but I need parent and new window to communicate via the global variable usable only if they are on the same render.
This is driving me nuts. I don't even know where to look for the problem. Thanks for the help.
The text was updated successfully, but these errors were encountered: