How to remove warnings from lastValue in SparkAR - javascript

In a SparkAR script, I use star.transform.z.lastValue to get the actual number. I want to do some math with the numbers, not with ScalarSignals (observable values). Now by doing so, I get lots of warnings:
This API is deprecated, please update to the newest SDK version.
Please use pinLastValue() instead to receive a ConstSignal as a replacement for lastValue
I don't see what ConstSignal is or how to extract the value from it, since the documentation seems to be lacking:
https://sparkar.facebook.com/ar-studio/search/ConstSignal
I tried doing figure out what kind of fields/functions it has with reflection, but reflection doesn't seem to work in SparkAR, and I don't have code completion on it either. So I have no idea how to resolve this.
Everything works fine when I'm just using lastValue, but I'd love to have a clean console.
Note: I am using Spark AR Studio v96

Use star.transform.z.pinLastValue() to instead.

Related

Unable to execute karate script() method

I am trying to migrate one of selenium test to karate, while doing this I am using script() method defined in documentation which is used in karate for evaluating the given string as JavaScript within the browser but I am getting this
driver.executeScript("sauce:job-result=passed");
Also Sharing my feature file which getting failed:
Also Even I tried calling below statement in my script but still getting the same error
* script("console.log('hello world')")
I am using testImplementation("com.intuit.karate:karate-core:1.2.0.RC1") version with gatling
First - try version 1.2.0.RC6 that has some fixes for the console.log() issue.
I also must say that sauce:job-result=passed does not look like valid JavaScript to me. Please take some time to read the docs: https://github.com/karatelabs/karate/tree/master/karate-core#karate-vs-the-browser
If still stuck, follow this process. That is the only way to replicate and for us to determine what fixes we need to make (if any): https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue
See this answer for ideas on how to troubleshoot things at your end: https://stackoverflow.com/a/71952132/143475

Disable deprecation in javascript console

I'm using a library from another person but it's probably pretty old and, even though it works just fine, I get a DEP066 deprecation error in my console when I run it.
I'm a COMPLETE noob when talking about javascript so I need your help. Is there a way to disable the deprecation warning/fix it if I use a newer function ?
EDIT:
Thank you so much! It works with the --no-deprecation option.
Try running the the script using the the --no-deprecation parameter which will "silence deprecation warnings":
node --no-deprecation script
Alternatively, --no-warnings will "silence all process warnings (including deprecations)."

"Intl not available" in Edge 15

I'm seeing an Intl not available error in the JS console when my script runs the following code in Edge 15:
new Date().toLocaleDateString()
I'm a bit stumped by this. It is working just fine in Edge 14, and I can't find any reference to the internationalization API suddenly disappearing from Edge 15.
I'm not sure if this is the proper way to test it, but running window.hasOwnProperty("Intl") in the console actually returns true. To me this seems to indicate that Intl actually is there.
Anyone with more JS skills able to tell what is really going on here?
Make sure your JS code doesn't redefine standard Map class.
We had almost the same problem, but with Intl.Collator object instead. We couldn't use String.prototype.localeCompare("...", "locale") because of this.
You can look at this codepen in Edge 15 and in other browsers for explanation: https://codepen.io/kgorob/pen/pweaWV.
P.S.
I'm not sure your problem is because of Map class specifically, maybe it's some other standard JS class you are re-defining.
The problem is because of these lines in Chakracore code. Intl.js is javascript file that is used internally to perform various internationalization specific operations. Since Mapis used, over-writing it before Intl.js code executes (it is executed lazily), causes problem. This should be addressed soon.
As ksp's answer says, this is caused by Intl lazy-loading after Map is overwritten. Therefore, the easiest workaround is to just force it to initialise early, before other scripts run:
<html>
<head>
<script>Intl.DateTimeFormat</script>
...
Here is the issue in the Chakra repo: https://github.com/Microsoft/ChakraCore/issues/3189

How to lint specific function call in JavaScript?

My team has had the occasional problem of developers pushing Karma/Protractor tests containing the .only() function call, which of course makes our Jenkins etc only run that particular test, potentially allowing bugs to slip by. As such I thought I'd try and figure out a way to stop this from happening without being discovered.
First, I thought I'd look into simply using JSHint to point out the function call, but I can't seem to find a way to do that. I also looked at ESLint for its custom plugins, but I can't figure out how to write a plugin for this particular case.
Could you guys give me some ideas on how to solve this issue? Alternative solutions are also appreciated, of course!
Here's a (probably not working example) of how to create a plugin that flags an error if the parser ever sees a only() call. Again, mileage may vary, but it should be enough to get you started. This does not work if it sees a.only(), we'll leave that up to you.
module.exports.rules = {
"no-only-call": context => ({
CallExpression: (node) => {
if(node.callee.name == "only"){
context.report(node, 'Calls to only() are disallowed');
}
}
})
};
https://www.kenneth-truyers.net/2016/05/27/writing-custom-eslint-rules/ - Simple example of creating a custom rule
http://esprima.org/demo/parse.html - Use this online parser to help you understand the parse tree.
https://www.npmjs.com/package/generator-eslint - Use this generator to start your plugin project

dart's latest js-interop library causes some issues lately

I have seen some strange changes in the latest js-interop library and I wonder if anybody can give some clarification about it.
After upgrading to the latest version I noticed dart2js doesn't work anymore. After some investigation I concluded the cause was an #proxy annotation inside the js-interop library ( also mentioned here).
Because of this I switched between a couple of versions and I noticed some functions like scoped have been deprecated in a timespan of only a couple of days after which it has been completely removed! If you missed the in between version in which this function is marked as deprecated you miss the hint which give's some info about it. Also note that the main tutorials about the js library on dartlang.org don't even give a hint about the fact that large parts of it have become outdated.
I decided to go back to version 0.0.26 and although it seemed to work as before... I noticed in one instance when retrieving a variable from the javascript context in dart I received a dart DateTime object and not a js.Proxy object.
Going back a version earlier (v0.0.25) I got back my js.Proxy when using a variable from the js context, as expected.
The weird thing is that on github the versions go until 0.0.25 (which work as expected) and the one on pub has 3 versions more, which all break backwards compatibility a lot (which sometimes is needed) without clear instructions about what is going on (which I find lightly frustrating).
Can somebody give some clarifications about what is going on and what I can expect for the coming times?
http://pub.dartlang.org/packages/js
All this breaking changes have been announced in Future breaking changes in package:js and BREAKING CHANGE: package:js deprecated features removed.
Basically, starting from 0.0.26, package:js is now baked with dart:js. This change comes with several things :
scopes/retain/release are no longer needed
several types are now transfered directly between Dart and Js and not proxied
null, bool, num, String, DateTime
Blob
KeyRange
ImageData
TypedData, including its subclasses like Int32List, but not ByteBuffer
Node
Element from shadow dom can now be transfered as well
Callback are now longer needed.
a really big performance improvement
Here's a quick migration guide :
scopes : remove js.retain, js.release and js.scoped.
replace new Callback.xxxx(f) with f and remove callback.dispose().
replace Proxy with transferable type based on the above list.

Categories

Resources