node-api-dotnet-generator 0.2.32 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ and it isn't yet all packaged up nicely in a way that can be easily consumed._
18
18
  ### Minimal example - JS calling .NET
19
19
  ```JavaScript
20
20
  // JavaScript
21
- const Console = require('node-api-dotnet').Console;
21
+ const Console = require('node-api-dotnet').System.Console;
22
22
  Console.WriteLine('Hello from .NET!');
23
23
  ```
24
24
 
@@ -51,21 +51,17 @@ For more examples, see the [examples](./examples/) directory.
51
51
 
52
52
  ### Load and call .NET assemblies from JS
53
53
  The `node-api-dotnet` package manages hosting the .NET runtime in the JS process
54
- (if not using AOT - see below). The .NET core library types are available directly on the
55
- `node-api-dotnet` module, and additional .NET assemblies can be loaded by file path:
54
+ (if not using AOT - see below). The .NET core library types are available immediately;
55
+ additional .NET assemblies can be loaded by file path:
56
56
  ```JavaScript
57
57
  // JavaScript
58
58
  const dotnet = require('node-api-dotnet');
59
- const ExampleAssembly = dotnet.load('path/to/ExampleAssembly.dll');
60
- const exampleObj = new ExampleAssembly.ExampleClass(...args);
59
+ dotnet.load('path/to/ExampleAssembly.dll');
60
+ const exampleObj = new dotnet.ExampleNamespace.ExampleClass(...args);
61
61
  ```
62
62
 
63
- .NET namespaces are stripped for convenience, but in case of ambiguity it's possible to get a type
64
- by full name:
65
- ```JavaScript
66
- // JavaScript
67
- const MyType = ExampleAssembly['Namespace.Qualified.MyType'];
68
- ```
63
+ All .NET namespaces are projected onto the top-level `dotnet` object. When loading multiple .NET
64
+ assemblies, types from all assemblies are merged into the same namespace hierarchy.
69
65
 
70
66
  ### Load and call JavaScript packages from .NET
71
67
  Calling JavaScript from .NET requires hosting a JS runtime such as Node.js in the .NET app.
@@ -100,17 +96,19 @@ type definitions.
100
96
 
101
97
  ### Generate TS type definitions for .NET APIs
102
98
  If writing TypeScript, or type-checked JavaScript, there is a tool to generate type `.d.ts` type
103
- definitions for .NET APIs. Soon, it should also generate a small `.js` file that exports the
104
- assembly in a more natural way as a JS module.
99
+ definitions for .NET APIs. It also generates a small `.js` file that makes it simple to load the
100
+ assembly DLL and type-definitions together.
105
101
  ```bash
106
102
  $ npm exec node-api-dotnet-generator --assembly ExampleAssembly.dll --typedefs ExampleAssembly.d.ts
107
103
  ```
108
104
  ```TypeScript
109
105
  // TypeScript
110
- import { ExampleClass } from './ExampleAssembly';
111
- ExampleClass.ExampleMethod(...args); // This call is type-checked!
106
+ import './ExampleAssembly.js'; // TS also loads the adjacent .d.ts file.
107
+ dotnet.ExampleNamespace.ExampleClass.ExampleMethod(...args); // This call is type-checked!
112
108
  ```
113
109
 
110
+ (CommonJS modules must use `require()` instead of `import`.)
111
+
114
112
  For reference, there is a [list of C# type projections to TypeScript](/Docs/typescript.md).
115
113
 
116
114
  ### Full async support
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "node-api-dotnet-generator",
3
- "version": "0.2.32",
3
+ "version": "0.3.1",
4
4
  "description": "Node-API for .Net code generator",
5
5
  "main": "index.js",
6
6
  "bin": "index.js",
7
7
  "license": "MIT",
8
8
  "author": "Microsoft",
9
9
  "dependencies": {
10
- "node-api-dotnet": "0.2.32"
10
+ "node-api-dotnet": "0.3.1"
11
11
  },
12
12
  "keywords": [
13
13
  "Node-API",