Skip to content

Commit

Permalink
feat: add loadPackage node.js API
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Apr 16, 2024
1 parent a602d1d commit fd219d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion blog/2024-04-17-newsletter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ content = template.execute("""\
cargo add --git https://github.com/kcl-lang/lib
```

- The initial release of the KCL Node.js SDK, supporting KCL code execution API and variable reading API. Repository link: [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs). Contributions are welcome.
- The initial release of the KCL Node.js SDK. Repository link: [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs). Contributions are welcome.

+ `__test__/test_data/schema.k`

Expand Down Expand Up @@ -103,6 +103,19 @@ function main() {
main();
```

+ `loadPackage`

```ts
import { listVariables, ListVariablesArgs } from "kcl-lib";

function main() {
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
console.log(result.symbols);
}

main();
```

**💻 IDE Updates**

- Added compilation unit caching to enhance IDE performance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ content = template.execute("""\
cargo add --git https://github.com/kcl-lang/lib
```

- KCL Node.js SDK 初版发布,支持 KCL 代码运行 API 和变量读取 API,仓库地址 [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs), 欢迎共建
- KCL Node.js SDK 初版发布,仓库地址 [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs), 欢迎共建

+ `__test__/test_data/schema.k`

Expand Down Expand Up @@ -103,6 +103,19 @@ function main() {
main();
```

+ `execProgram`

```ts
import { listVariables, ListVariablesArgs } from "kcl-lib";

function main() {
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
console.log(result.symbols);
}

main();
```

**💻 IDE 更新**

- 新增编译单元缓存提升 IDE 性能
Expand Down

0 comments on commit fd219d0

Please sign in to comment.