Skip to content

Commit fd219d0

Browse files
committed
feat: add loadPackage node.js API
Signed-off-by: peefy <[email protected]>
1 parent a602d1d commit fd219d0

File tree

2 files changed

+28
-2
lines changed
  • blog/2024-04-17-newsletter
  • i18n/zh-CN/docusaurus-plugin-content-blog/2024-04-17-newsletter

2 files changed

+28
-2
lines changed

blog/2024-04-17-newsletter/index.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ content = template.execute("""\
6464
cargo add --git https://github.com/kcl-lang/lib
6565
```
6666

67-
- 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.
67+
- 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.
6868

6969
+ `__test__/test_data/schema.k`
7070

@@ -103,6 +103,19 @@ function main() {
103103
main();
104104
```
105105

106+
+ `loadPackage`
107+
108+
```ts
109+
import { listVariables, ListVariablesArgs } from "kcl-lib";
110+
111+
function main() {
112+
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
113+
console.log(result.symbols);
114+
}
115+
116+
main();
117+
```
118+
106119
**💻 IDE Updates**
107120

108121
- Added compilation unit caching to enhance IDE performance.

i18n/zh-CN/docusaurus-plugin-content-blog/2024-04-17-newsletter/index.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ content = template.execute("""\
6464
cargo add --git https://github.com/kcl-lang/lib
6565
```
6666

67-
- 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), 欢迎共建
67+
- KCL Node.js SDK 初版发布,仓库地址 [https://github.com/kcl-lang/lib/tree/main/nodejs](https://github.com/kcl-lang/lib/tree/main/nodejs), 欢迎共建
6868

6969
+ `__test__/test_data/schema.k`
7070

@@ -103,6 +103,19 @@ function main() {
103103
main();
104104
```
105105

106+
+ `execProgram`
107+
108+
```ts
109+
import { listVariables, ListVariablesArgs } from "kcl-lib";
110+
111+
function main() {
112+
const result = loadPackage(LoadPackageArgs(['__test__/test_data/schema.k'], [], true));
113+
console.log(result.symbols);
114+
}
115+
116+
main();
117+
```
118+
106119
**💻 IDE 更新**
107120

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

0 commit comments

Comments
 (0)