@x-skills-for-ai/angular 1.0.0
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 +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/xskills.directive.d.ts +8 -0
- package/dist/xskills.directive.js +33 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# xskills-angular
|
|
2
|
+
|
|
3
|
+
Angular directive for [xskills-core](..).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install xskills-angular xskills-core @angular/core @angular/common @angular/platform-browser
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Component } from '@angular/core';
|
|
15
|
+
import { XSkillDefinition } from 'xskills-core';
|
|
16
|
+
import { XSkillDirective } from 'xskills-angular';
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
selector: 'app-counter',
|
|
20
|
+
standalone: true,
|
|
21
|
+
imports: [XSkillDirective],
|
|
22
|
+
template: `
|
|
23
|
+
<div xSkill [xSkill]="skillDef">
|
|
24
|
+
<h1>Count: {{ count }}</h1>
|
|
25
|
+
<p>Open console: await getXSkillsRuntime().execute('increment')</p>
|
|
26
|
+
</div>
|
|
27
|
+
`
|
|
28
|
+
})
|
|
29
|
+
export class CounterComponent {
|
|
30
|
+
count = 0;
|
|
31
|
+
|
|
32
|
+
skillDef: XSkillDefinition = {
|
|
33
|
+
id: 'increment',
|
|
34
|
+
description: 'Increase counter by 1',
|
|
35
|
+
handler: () => this.count++
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The directive automatically registers the skill on init and unregisters on destroy.
|
|
41
|
+
|
|
42
|
+
See [example.component.ts](example.component.ts).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './xskills.directive';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './xskills.directive';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { XSkillDefinition } from '@x-skills-for-ai/core';
|
|
3
|
+
export declare class XSkillDirective implements OnInit, OnDestroy {
|
|
4
|
+
def: XSkillDefinition;
|
|
5
|
+
private unregister;
|
|
6
|
+
ngOnInit(): void;
|
|
7
|
+
ngOnDestroy(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Directive, Input } from '@angular/core';
|
|
11
|
+
import { getXSkillsRuntime } from '@x-skills-for-ai/core';
|
|
12
|
+
let XSkillDirective = class XSkillDirective {
|
|
13
|
+
def;
|
|
14
|
+
unregister = null;
|
|
15
|
+
ngOnInit() {
|
|
16
|
+
if (this.def) {
|
|
17
|
+
this.unregister = getXSkillsRuntime().register(this.def);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
ngOnDestroy() {
|
|
21
|
+
this.unregister?.();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
Input('xSkill'),
|
|
26
|
+
__metadata("design:type", Object)
|
|
27
|
+
], XSkillDirective.prototype, "def", void 0);
|
|
28
|
+
XSkillDirective = __decorate([
|
|
29
|
+
Directive({
|
|
30
|
+
selector: '[xSkill]'
|
|
31
|
+
})
|
|
32
|
+
], XSkillDirective);
|
|
33
|
+
export { XSkillDirective };
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-skills-for-ai/angular",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Angular service for xskills-core integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@angular/core": "^17.0.0"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@x-skills-for-ai/core": "^1.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@angular/core": "^17.0.0",
|
|
18
|
+
"typescript": "^5.5.4",
|
|
19
|
+
"rimraf": "^5.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rimraf dist && tsc",
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"xskills",
|
|
28
|
+
"angular",
|
|
29
|
+
"skills"
|
|
30
|
+
],
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "MIT"
|
|
33
|
+
}
|