Invalid value for transfer while using ipcRenderer.postMessage of electron - electron

Invalid value for transfer while using ipcRenderer.postMessage of electron?I don't know what's wrong with it
// eslint-disable-next-line no-undef
const { port1 } = new MessageChannel();
// eslint-disable-next-line no-undef
ipcRenderer.postMessage('port', { message: 'hello' }, [port1]);
I wonder if something wrong in my preload.js?
I upload all my code to github
https://github.com/codeh2o/electronVuePreloadIssue

Related

Zoho Catalyst Data Store, Functions - Unable to retrieve a row

I'm trying to get a row from datastore, while trying I've got the below error.I've included the script I'm trying.
Output:
{
"status": "failure",
"data": {
"message": "basicio Execution Time Exceeded",
"error_code": "EXECUTION_TIME_EXCEEDED"
}
}
Code Snippet :
let rowData =
{
response: "George Hamilton",
};
const https = require("https");
const axios = require("axios");
const catalyst = require("zcatalyst-sdk-node");
const app = catalyst.initialize(context);
let datastore = app.datastore();
let table = datastore.table('xxxx');
let rowPromise = table.getRow(xxxxx);
basicIO.write(rowPromise + "");
}
Zoho Catalyst Basic IO functions will have an execution timeout of maximum of 30 seconds. Missing of proper exception handling might also lead to a timeout. Enclose your code in a try catch block in order to catch the exceptions and you need to await in table.getRow() since it returns a promise and you have to resolve the promise by using .then().
let rowPromise = await table.getRow('xxxxx');
rowPromise.then((response) => {
console.log(response);
res.status(200).send(JSON.stringify(response));
}).catch((err)=> {
console.log(err);
res.status(500).send(err.toString());
})

How do i style a youtube live stream message?

Hi so i am manually inserting in my live stream using a node js googleapis/youtube package. The message shows as a plain text message, what i would like to know is how can i change the design of this text message so that it is more noticeable like maybe highlighting it? I am currently using the following code
const youtubeService = {};
youtubeService.insertMessage = messageText => {
console.log(myliveChatId);
const response = youtube.liveChatMessages.insert(
{
auth: auth,
part: 'snippet',
resource: {
snippet: {
type: 'textMessageEvent',
liveChatId: myliveChatId,
textMessageDetails: {
messageText: 'hello man'
}
}
}
},
(error) => {
console.log(error);
}
);
console.log(response);
};
EDIT:
This is how a chat message usually appears
what i want is something like this
Note: The message that is inserted onto my livestream via the code wont be through my account but rather someone else's.

How can I detect a "certificate-error" message in an electron app?

I have an Electron app. Running fine.
I add the following function in to main.ts:
function MakeHTTPCall(url:string, id:string)
{
var request = require('request');
var options = {
'method': 'GET',
'url': url,
'headers': {
'Cookie': ''
}
};
options.headers["Cookie"] = 'ID=' + id;
request(options, function (error:any, response:any) {
if (error){
throw new Error(error);
}
var s = response;
})
}
This code currently lands on the "throw new Error" line. When I look at the error text it is:
code:'SELF_SIGNED_CERT_IN_CHAIN'
message:'self signed certificate in certificate chain'
stack:'Error: self signed certificate in certificate chain\n at TLS
After doing a web search I added this to my main.ts code:
app.on ("certificate-error", (event, webContents, url, error, cert, callback) => {
// Do some verification based on the URL to not allow potentially malicious certs:
if (url.startsWith ("https://yourdomain.tld")) {
// Hint: For more security, you may actually perform some checks against
// the passed certificate (parameter "cert") right here
event.preventDefault (); // Stop Chromium from rejecting the certificate
callback (true); // Trust this certificate
} else callback (false); // Let Chromium do its thing
});
But this code is never called.
How can I get it to fire? I just want to see if I can ignore the error and make the HTML call.
Thanks

Trouble reading user accessible files

I am using nativescript-mediafilepicker as means of choosing a file, and this can read external storage successfully (I have downloaded a PDF to the 'downloads' folder on iOS and I am able to pick it.) I then try to load the file using the file system module from nativescript library, and this fails because it is listed as NativeScript encountered a fatal error: Uncaught Error: You can’t save the file “com.xxxxxx” because the volume is read only. This doesn't make sense as I am trying to read anyway - I don't understand where the saving part is from. The error comes from fileSystemModule.File.fromPath() line.
Something to note that file['file'] is file:///Users/adair/Library/Developer/CoreSimulator/Devices/82F397CE-B0B3-4ADD-AD52-805265C7AC49/data/Containers/Data/Application/7B47A8BD-6DBA-42CF-8792-38A8C5E61174/tmp/com.xxxxxx/test.pdf
Is the file automatically being pulled to an application specific directory after this media picker?
getFiles() {
let extensions = [];
if (app.ios) {
extensions = [kUTTypePDF]; // you can get more types from here: https://developer.apple.com/documentation/mobilecoreservices/uttype
} else {
extensions = ["pdf"];
}
const mediaFilePicker = new Mediafilepicker();
const filePickerOptions = {
android: {
extensions,
maxNumberFiles: 1,
},
ios: {
extensions,
maxNumberFiles: 1,
},
};
masterPermissions
.requestPermissions([masterPermissions.PERMISSIONS.READ_EXTERNAL_STORAGE,masterPermissions.PERMISSIONS.WRITE_EXTERNAL_STORAGE])
.then((fulfilled) => {
console.log(fulfilled);
mediaFilePicker.openFilePicker(filePickerOptions);
mediaFilePicker.on("getFiles", function (res) {
let results = res.object.get("results");
let file = results[0];
console.dir(file);
let fileObject = fileSystemModule.File.fromPath(file["file"]);
console.log(fileObject);
});
mediaFilePicker.on("error", function (res) {
let msg = res.object.get("msg");
console.log(msg);
});
mediaFilePicker.on("cancel", function (res) {
let msg = res.object.get("msg");
console.log(msg);
});
})
.catch((e) => {
console.log(e);
});
},
The issue I have experienced is resultant of the expectation of File.fromPath and what is returned by the file picker. File picker is returning a "file://path" URI, and File.fromPath is expecting a string of just "path".
Simply using the following instead is enough.
let fileObject = fileSystemModule.File.fromPath(file["file"].replace("file://","");

Get error on GML options

I'm trying to create wfs-t service I have used the ol.format.WFS#writeTransaction method and serialize the WFS-t XML but my jslint always preview error at the GML format options. Is it possible that I am initializing the ol.format.WFS object incorrectly?
Or maybe I am passing the wrong options to the writeTransaction method? Or maybe it's a bug in OpenLayers4? this detail of my wfs-t service using angular http service:
private _transactWFS(feature: any, operation: any): any {
let payload;
try {
const formatWFS = new ol.format.WFS({});
const formatGML = new ol.format.GML({
featureNS: operation.featureNS,
featureType: operation.featureType,
srsName: operation.srsName
});
const xs = new XMLSerializer();
let node: any = null;
switch (operation.mode) {
case 'insert':
node = formatWFS.writeTransaction([feature], null, null, formatGML);
break;
case 'update':
node = formatWFS.writeTransaction(null, [feature], null, formatGML);
break;
case 'delete':
node = formatWFS.writeTransaction(null, null, [feature], formatGML);
break;
}
payload = xs.serializeToString(node);
} catch (error) {}
return payload;
}
lint message:
[ts]
Argument of type 'GML' is not assignable to parameter of type 'WFSWriteTransactionOptions'.
Property 'featureNS' is missing in type 'GML'.
From the OpenLayers WFS-T example:
// Word to the Wise from an anonymous OpenLayers hacker:
//
// The typename in the options list when adding/loading a wfs
// layer not should contain the namespace before, (as in the
// first typename parameter to the wfs consctructor).
//
// Specifically, in the first parameter you write typename:
// 'topp:myLayerName', and in the following option list
// typeName: 'myLayerName'.
//
// If you have topp included in the second one you will get
// namespace 14 errors when trying to insert features.
//
wfs = new OpenLayers.Layer.WFS(
"Cities",
"http://sigma.openplans.org/geoserver/wfs",
{typename: 'topp:tasmania_cities'},
{
typename: "tasmania_cities",
featureNS: "http://www.openplans.org/topp",
extractAttributes: false,
commitReport: function(str) {
OpenLayers.Console.log(str);
}
}
);
Seems to indicate you are building your WFS object wrong.
I'm give up using WFS Format for build WFS Transaction request so my problem was solved by myself, I found this lib geojson-to-wfs-t-2. This library is very legit for solving my problem.

Resources