WebStorm shows deprecation error in postMessage function of a web worker - web

When writing something like this in WebStorm:
let webWorker = new Worker('...')
...
webWorker.postMessage(...)
The postMessage is striked out with the following message:
"Deprecated symbol used, consult docs for better alternative"
"Checks for using deprecated JavaScript functions and variables ..."
Is postMessage function of the webWorker is deprecated?

This method is annotated with #deprecated tag in lib.dom.d.ts provided by Microsoft (that, in turn, was auto-generated from the webidl definition of edge); Microsoft has recently fixed the issue in https://github.com/Microsoft/TypeScript/pull/24669, method is no more marked deprecated in https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts.
Webstorm will bundle Typescript 3.x that includes the fix in upcoming 2018.2.1 update (https://youtrack.jetbrains.com/issue/WEB-34144)

Related

Graph SDK for .NET doesn't have Request method

I'm trying to use the Graph SDK and NuGet 5.0.0-preview16 and forwarding the example it says to use Request method in example
var users = await graphClient.Users.Request().GetAsync();
but I have an error in the code:
'UsersRequestBuilder' does not contain a definition for 'Request' and
no accessible extension method 'Request' accepting a first argument of
type 'UsersRequestBuilder' could be found (are you missing a using
directive or an assembly reference?
Since C# SDK V5 Request method is removed and you can call directly GetAsync method. But V5 is still in preview and it's better to use latest V4 version.
var users = await graphClient.Users.GetAsync();
Upgrade guide can be found here.
Fixed: I changed Microsoft.Graph on NuGet from 5.0.0-preview16 to 4.47.0

V4 Generator - OData V2 Non-Simple Function Import Parameters

I am using version odata-v4-generator-cli 3.40.0 to generate a client from the SAP B1 Service Layer definition.
However, there are many errors like the following:
Function import DraftsService_SaveDraftToDocument has non-simple type for parameter Document, but OData V2 does not support non-simple types as function import parameters.
And the function is not present in the generated client code. The error seems to indicate it is a limitation with V2, but this is a V4 definition with the V4 version of the generator.
The log message you are seeing is indeed very misleading - in fact it is plain wrong.
We have a fix for the incorrect message in our pipeline.
In general, however, generating function imports (V2) and (un-)bound actions (V4) with non-primitive parameters is not yet supported in our OData generators.
This is why these methods are not included in the generated code.
We are receiving many requests asking for this feature and have it rather high up in our backlog.
Unfortunately, I cannot give any details for a release schedule - I will update this answer when we have more concrete information.
EDIT (06/14/2021)
With release 3.46.0 of the SAP Cloud SDK for Java, we have shipped a first version of bound functions and actions.

How can I fix 'window is undefined' when running Mapkit JS in Node.js (Firebase Functions)

I have been using Apple Mapkit JS POI search and reverseGeoLocation search in the browser and want to move my code to Firebase functions (node.js).
I can import mapkit using mapkit-npm (or just downloading the latest CDN file and importing that directly).
When I declare mapkit using const mapkit = require() I get an error "window is undefined".
I have tried to use NPM jsDOM to create a window object, but I'm still getting errors which I think are due to fields missing on either my window or navigator objects. (errors such as "Cannot perform toLowerCase on undefined").
Please can someone help me run mapkit in a non-browser environment?
Thanks :)
Answered in the comments - unfortunately the non-DOM aspects of mapkit are currently tied up in the browser part of the module, so they can't be used outside of a browser and therefore can't be used server side.
I was trying to use the geolocation ones as they're much cheaper than google (and provide all the info needed in one request).
Nevermind!

Is it possible to use dialogflow-nodejs-client-v2 in front-end (Angular)?

I built an app a long time ago using Firebase and dialogflow-javascript-client.
Now, dialogflow-javascript-client is deprecated. Since dialogflow-nodejs-client-v2 is a node.js client, it is not supposed to run on Angular. Did they drop the javascript support? I can't get any answer from the devs, they just seem to avoid it.
If it is not possible, my only solution is to drop support of Dialogflow in my app.
There is absolutely not documentation or info for users migrating from Javascript, here is the only thing they give you:
Off course I tried to run it anyway, thinking it was also built to run on javascript...
But here is what I get:
WARNING in
./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
17:20-67 Critical dependency: the request of a dependency is an
expression
WARNING in
./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
20:22-48 Critical dependency: the request of a dependency is an
expression
WARNING in
./node_modules/google-gax/node_modules/grpc/src/grpc_extension.js
32:12-33 Critical dependency: the request of a dependency is an
expression
WARNING in
./node_modules/google-gax/node_modules/grpc/node_modules/minimatch/minimatch.js
Module not found: Error: Can't resolve 'path' in
'D:\ng\ww-app\node_modules\google-gax\node_modules\grpc\node_modules\minimatch'
WARNING in ./node_modules/minimatch/minimatch.js Module not found:
Error: Can't resolve 'path' in 'D:\ng\ww-app\node_modules\minimatch'
ERROR in ./node_modules/dialogflow/src/v2/agents_client.js Module not
found: Error: Can't resolve './agents_client_config' in
'D:\ng\ww-app\node_modules\dialogflow\src\v2'
.... (many more following)
The dialogflow-nodejs-client-v2 only supports a node.js environment. To update your agent to V2, you should create a Cloud Function for Firebase that sends requests to dialogflow-nodejs-client-v2, then call that Cloud Function from your Angular code rather than calling the API directly.
There is a major benefit of this approach: you will no longer have your API credentials exposed on the client side, which is a security risk.
I read a tutorial once with Node.js, maybe you can migrate your data from angular to Node.js like in this question anwered before.
I found another solution:
I've created a javascript client... and I get token from nodejs api getToken endpoint when it expires (that is every hour)... I have restricted the getToken endpoint to the same domain.

Implement gRPC in an iOS React Native app

As described in this issue, we can't implement a gRPC client using the Node implementation because "RN is not pure Node".
So I started working on an Objective-C implementation using the Native Modules.
[service postWithRequest:request handler:^(RequestConfirmation * _Nullable response, NSError * _Nullable error) {
if (response) {
// This prints correctly in my JS console
RCTLogInfo(#"%#", response.message);
// This generates an error, see below
resolve(response);
// This works
NSDictionary *formattedResponse = #{
#"id": response.id_p,
#"message": response.message
};
resolve(formattedResponse);
} else {
reject(#"error", #"An error occurred while saving", error);
}
}];
Error :
RCTJSONStringify() encountered the following error: Invalid type in JSON write (RequestConfirmation)
As you can see the problem is with the resolve method. I suppose React does not find any way to convert my proto message to JSON.
How can I keep the response as is and pass it to the resolve method ?
Then I can decode it in my JS code.
Thanks.
EDIT 1 :
RequestConfirmation is defined in my proto file like this :
message RequestConfirmation {
string id = 1;
string message = 2;
}
And then it is generated in Objective-C :
#interface RequestConfirmation : GPBMessage
#property(nonatomic, readwrite, copy, null_resettable) NSString *id_p;
#property(nonatomic, readwrite, copy, null_resettable) NSString *message;
#end
Maybe the following is a potential solution for this.
Improbable Engineering have coded:
grpc-web - Typescript/Javascript, browser or NodeJS!
Aside from the unfortunate naming, this appears not to be a mere fork of the official, C++-using, grpc-web project).
Quoting the Improbable project's own grpc-web-client page:
This library is intended for both JavaScript and TypeScript usage from either a browser or Node.js
The possible benefits of Improbable's version seem to be:
It doesn't appear to use native code (i.e. no C/C++/Java)
It can generate Typescript (therefore JavaScript) for Node.JS
So, maybe, we could get GRPC-on-RN working, when point No. 2 is coupled with a NodeJS-on-RN project such as rn-nodeify.
Please provide feedback, if you have any success with this.
At the time of writing, Improbable Engineering's gRP-Web can't be used with React Native.
Instead you must use React Native Native Modules and build native modules in Swift or Objective-C. Since React Native doesn't talk to Swift directly, you must create an Objective-C bridge if you choose to use Swift.
You will:
implement a gRPC client in the native language of your device,
export it using React Native's Native module framework
access the native module and its gRPC methods through React Native
Call those exported methods in React your Native code
The basic structure of this relationship is:
# Swift project
Reat Native <-> ObjC Bridge <-> Swift <-> gRPC
# Objective-C project
Reat Native <-> ObjC <-> gRPC
It's a pretty lengthy explanation of how to integrate these components. I've written a tutorial for Building a gPRC Client in React Native on iOS/Swift. I hope people find that useful.

Resources