Update src/extensions/jg_prism/index.js
Browse files
src/extensions/jg_prism/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
const formatMessage = require('format-message');
|
2 |
const BlockType = require('../../extension-support/block-type');
|
3 |
const ArgumentType = require('../../extension-support/argument-type');
|
4 |
-
const ProjectPermissionManager = require('../../util/project-permissions');
|
5 |
const SandboxRunner = require('../../util/sandboxed-javascript-runner');
|
6 |
const beatgammit = {
|
7 |
deflate: require('./beatgammit-deflate'),
|
@@ -573,11 +572,6 @@ class JgPrismBlocks {
|
|
573 |
// eslint-disable-next-line no-unused-vars
|
574 |
evaluate(args, util, realBlockInfo) {
|
575 |
return new Promise((resolve, reject) => {
|
576 |
-
// if (!(this.isJSPermissionGranted)) {
|
577 |
-
// this.isJSPermissionGranted = ProjectPermissionManager.RequestPermission("javascript");
|
578 |
-
// if (!this.isJSPermissionGranted) return;
|
579 |
-
// }
|
580 |
-
// // otherwise
|
581 |
SandboxRunner.execute(String(args.JAVASCRIPT)).then(result => {
|
582 |
if (!result.success) {
|
583 |
alert(result.value);
|
@@ -591,27 +585,12 @@ class JgPrismBlocks {
|
|
591 |
// eslint-disable-next-line no-unused-vars
|
592 |
evaluate2(args, util, realBlockInfo) {
|
593 |
return new Promise((resolve, reject) => {
|
594 |
-
// if (!(this.isJSPermissionGranted)) {
|
595 |
-
// this.isJSPermissionGranted = ProjectPermissionManager.RequestPermission("javascript");
|
596 |
-
// if (!this.isJSPermissionGranted) return "";
|
597 |
-
// }
|
598 |
-
// // otherwise
|
599 |
SandboxRunner.execute(String(args.JAVASCRIPT)).then(result => {
|
600 |
if (!result.success) {
|
601 |
console.error(result.value);
|
602 |
}
|
603 |
resolve(result.value)
|
604 |
})
|
605 |
-
// let result = "";
|
606 |
-
// try {
|
607 |
-
// // eslint-disable-next-line no-eval
|
608 |
-
// result = eval(String(args.JAVASCRIPT));
|
609 |
-
// } catch (e) {
|
610 |
-
// result = e;
|
611 |
-
// console.error(e);
|
612 |
-
// }
|
613 |
-
// return result;
|
614 |
-
// return "";
|
615 |
})
|
616 |
}
|
617 |
// eslint-disable-next-line no-unused-vars
|
@@ -624,22 +603,6 @@ class JgPrismBlocks {
|
|
624 |
resolve(result.value === true)
|
625 |
})
|
626 |
})
|
627 |
-
// if (!(this.isJSPermissionGranted)) {
|
628 |
-
// this.isJSPermissionGranted = ProjectPermissionManager.RequestPermission("javascript");
|
629 |
-
// if (!this.isJSPermissionGranted) return false;
|
630 |
-
// }
|
631 |
-
// // otherwise
|
632 |
-
// let result = true;
|
633 |
-
// try {
|
634 |
-
// // eslint-disable-next-line no-eval
|
635 |
-
// result = eval(String(args.JAVASCRIPT));
|
636 |
-
// } catch (e) {
|
637 |
-
// result = false;
|
638 |
-
// console.error(e);
|
639 |
-
// }
|
640 |
-
// // // otherwise
|
641 |
-
// return result === true;
|
642 |
-
// return false;
|
643 |
}
|
644 |
screenshotStage() {
|
645 |
// should we look for an external canvas
|
@@ -651,14 +614,8 @@ class JgPrismBlocks {
|
|
651 |
return this.runtime.prism_screenshot_externalCanvas.toDataURL();
|
652 |
}
|
653 |
}
|
654 |
-
|
655 |
-
|
656 |
-
// user's camera is on, ask for permission to take a picture of them
|
657 |
-
if (!(this.isCameraScreenshotEnabled)) {
|
658 |
-
this.isCameraScreenshotEnabled = ProjectPermissionManager.RequestPermission("cameraPictures");
|
659 |
-
if (!this.isCameraScreenshotEnabled) return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY/j//z8ABf4C/qc1gYQAAAAASUVORK5CYII="; // 1 pixel of white
|
660 |
-
}
|
661 |
-
}
|
662 |
return new Promise(resolve => {
|
663 |
vm.renderer.requestSnapshot(uri => {
|
664 |
resolve(uri);
|
@@ -802,4 +759,4 @@ class JgPrismBlocks {
|
|
802 |
}
|
803 |
}
|
804 |
|
805 |
-
module.exports = JgPrismBlocks;
|
|
|
1 |
const formatMessage = require('format-message');
|
2 |
const BlockType = require('../../extension-support/block-type');
|
3 |
const ArgumentType = require('../../extension-support/argument-type');
|
|
|
4 |
const SandboxRunner = require('../../util/sandboxed-javascript-runner');
|
5 |
const beatgammit = {
|
6 |
deflate: require('./beatgammit-deflate'),
|
|
|
572 |
// eslint-disable-next-line no-unused-vars
|
573 |
evaluate(args, util, realBlockInfo) {
|
574 |
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
|
|
|
575 |
SandboxRunner.execute(String(args.JAVASCRIPT)).then(result => {
|
576 |
if (!result.success) {
|
577 |
alert(result.value);
|
|
|
585 |
// eslint-disable-next-line no-unused-vars
|
586 |
evaluate2(args, util, realBlockInfo) {
|
587 |
return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
|
|
|
|
588 |
SandboxRunner.execute(String(args.JAVASCRIPT)).then(result => {
|
589 |
if (!result.success) {
|
590 |
console.error(result.value);
|
591 |
}
|
592 |
resolve(result.value)
|
593 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
})
|
595 |
}
|
596 |
// eslint-disable-next-line no-unused-vars
|
|
|
603 |
resolve(result.value === true)
|
604 |
})
|
605 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
}
|
607 |
screenshotStage() {
|
608 |
// should we look for an external canvas
|
|
|
614 |
return this.runtime.prism_screenshot_externalCanvas.toDataURL();
|
615 |
}
|
616 |
}
|
617 |
+
|
618 |
+
// renderer will handle not capturing video data
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
return new Promise(resolve => {
|
620 |
vm.renderer.requestSnapshot(uri => {
|
621 |
resolve(uri);
|
|
|
759 |
}
|
760 |
}
|
761 |
|
762 |
+
module.exports = JgPrismBlocks;
|