Danny Tuppeny
2016-07-29 17:36:08 UTC
I've managed to get VS Code to load/activate an extension written in Dart
but I'm struggling to register commands. The JavaScript I need to generate
is:
var vscode = require('vscode');
var disposable = vscode['commands'].registerCommand('extension.sayHello',
allowInterop(() {
vscode['window'].showInformationMessage('Hello World!');
}));
context.subscriptions.push(disposable);
The "vscode" module is an existing node JS module with no Dart code. I'd
like to load it so that I can interact with it (as if it was a plain JS
object) but I can't find a way to do it. The dev_compiler has output
requires() calls for other code, but it knows about them.
I tried using the js package to make a fake require method:
@JS()
library extension;
import "package:js/js.dart";
@JS()
external dynamic require(String name);
activate(dynamic context) {
var vscode = require("vscode");
}
However this failed with "dart.global.require is not a function".
It's not clear to me if the stuff on the js package page
<https://pub.dartlang.org/packages/js> is up-to-date and the correct way to
do JS interop; docs seem to be quite thin on the ground.
but I'm struggling to register commands. The JavaScript I need to generate
is:
var vscode = require('vscode');
var disposable = vscode['commands'].registerCommand('extension.sayHello',
allowInterop(() {
vscode['window'].showInformationMessage('Hello World!');
}));
context.subscriptions.push(disposable);
The "vscode" module is an existing node JS module with no Dart code. I'd
like to load it so that I can interact with it (as if it was a plain JS
object) but I can't find a way to do it. The dev_compiler has output
requires() calls for other code, but it knows about them.
I tried using the js package to make a fake require method:
@JS()
library extension;
import "package:js/js.dart";
@JS()
external dynamic require(String name);
activate(dynamic context) {
var vscode = require("vscode");
}
However this failed with "dart.global.require is not a function".
It's not clear to me if the stuff on the js package page
<https://pub.dartlang.org/packages/js> is up-to-date and the correct way to
do JS interop; docs seem to be quite thin on the ground.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.