@hackbuild/agents-views 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +114 -2
- package/dist/agents-views.iife.js +402 -0
- package/dist/associations-table.d.ts +56 -0
- package/dist/associations-table.js +107 -0
- package/dist/dom.d.ts +11 -0
- package/dist/dom.js +26 -0
- package/dist/drives-bars.d.ts +67 -0
- package/dist/drives-bars.js +98 -0
- package/dist/elements.d.ts +25 -0
- package/dist/elements.js +86 -0
- package/dist/eye-inset.d.ts +42 -0
- package/dist/eye-inset.js +84 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/single.d.ts +1 -0
- package/dist/single.js +6 -0
- package/dist/vue.d.ts +109 -0
- package/dist/vue.js +82 -0
- package/how.ts +24 -0
- package/package.json +49 -4
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import { type AssociationsState } from "./associations-table.js";
|
|
3
|
+
import { type DrivesBarsState } from "./drives-bars.js";
|
|
4
|
+
import { type EyeWho } from "./eye-inset.js";
|
|
5
|
+
/** The behavior block, utility rows (current in pink) and drive rows. */
|
|
6
|
+
export declare const DrivesBars: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
state: {
|
|
8
|
+
type: PropType<DrivesBarsState>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
note: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
18
|
+
state: {
|
|
19
|
+
type: PropType<DrivesBarsState>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
note: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
default: undefined;
|
|
25
|
+
};
|
|
26
|
+
}>> & Readonly<{}>, {
|
|
27
|
+
note: string;
|
|
28
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
/** The cues by acts heat table with attention, the explanation and reset. Emits `reset`. */
|
|
30
|
+
export declare const AssociationsTable: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
31
|
+
state: {
|
|
32
|
+
type: PropType<AssociationsState>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
limit: {
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
default: number;
|
|
38
|
+
};
|
|
39
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "reset"[], "reset", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
42
|
+
state: {
|
|
43
|
+
type: PropType<AssociationsState>;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
limit: {
|
|
47
|
+
type: NumberConstructor;
|
|
48
|
+
default: number;
|
|
49
|
+
};
|
|
50
|
+
}>> & Readonly<{
|
|
51
|
+
onReset?: (...args: any[]) => any;
|
|
52
|
+
}>, {
|
|
53
|
+
limit: number;
|
|
54
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
55
|
+
/**
|
|
56
|
+
* The eye card. `draw` paints a frame of the selected who; call the exposed
|
|
57
|
+
* `frame()` each frame (a template ref). v-model:who is the selected id.
|
|
58
|
+
*/
|
|
59
|
+
export declare const EyeInset: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
60
|
+
who: {
|
|
61
|
+
type: PropType<EyeWho[]>;
|
|
62
|
+
required: true;
|
|
63
|
+
};
|
|
64
|
+
draw: {
|
|
65
|
+
type: PropType<(canvas: HTMLCanvasElement, who: EyeWho) => string | void>;
|
|
66
|
+
required: true;
|
|
67
|
+
};
|
|
68
|
+
selected: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
width: {
|
|
73
|
+
type: NumberConstructor;
|
|
74
|
+
default: number;
|
|
75
|
+
};
|
|
76
|
+
height: {
|
|
77
|
+
type: NumberConstructor;
|
|
78
|
+
default: number;
|
|
79
|
+
};
|
|
80
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:selected"[], "update:selected", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
83
|
+
who: {
|
|
84
|
+
type: PropType<EyeWho[]>;
|
|
85
|
+
required: true;
|
|
86
|
+
};
|
|
87
|
+
draw: {
|
|
88
|
+
type: PropType<(canvas: HTMLCanvasElement, who: EyeWho) => string | void>;
|
|
89
|
+
required: true;
|
|
90
|
+
};
|
|
91
|
+
selected: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
default: undefined;
|
|
94
|
+
};
|
|
95
|
+
width: {
|
|
96
|
+
type: NumberConstructor;
|
|
97
|
+
default: number;
|
|
98
|
+
};
|
|
99
|
+
height: {
|
|
100
|
+
type: NumberConstructor;
|
|
101
|
+
default: number;
|
|
102
|
+
};
|
|
103
|
+
}>> & Readonly<{
|
|
104
|
+
"onUpdate:selected"?: (...args: any[]) => any;
|
|
105
|
+
}>, {
|
|
106
|
+
selected: string;
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The Vue components: each mounts the vanilla view on its root element and
|
|
2
|
+
// follows its props, so the Vue and plain HTML forms draw the same markup.
|
|
3
|
+
import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
4
|
+
import { associationsTable } from "./associations-table.js";
|
|
5
|
+
import { drivesBars } from "./drives-bars.js";
|
|
6
|
+
import { eyeInset } from "./eye-inset.js";
|
|
7
|
+
/** The behavior block, utility rows (current in pink) and drive rows. */
|
|
8
|
+
export const DrivesBars = defineComponent({
|
|
9
|
+
name: "DrivesBars",
|
|
10
|
+
props: {
|
|
11
|
+
state: { type: Object, required: true },
|
|
12
|
+
note: { type: String, default: undefined },
|
|
13
|
+
},
|
|
14
|
+
setup(props) {
|
|
15
|
+
const root = ref(null);
|
|
16
|
+
let view = null;
|
|
17
|
+
onMounted(() => {
|
|
18
|
+
view = drivesBars(root.value, props.note ? { note: props.note } : {});
|
|
19
|
+
view.update(props.state);
|
|
20
|
+
});
|
|
21
|
+
watch(() => props.state, (s) => view?.update(s), { deep: true });
|
|
22
|
+
onBeforeUnmount(() => view?.dispose());
|
|
23
|
+
return () => h("div", { ref: root });
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
/** The cues by acts heat table with attention, the explanation and reset. Emits `reset`. */
|
|
27
|
+
export const AssociationsTable = defineComponent({
|
|
28
|
+
name: "AssociationsTable",
|
|
29
|
+
props: {
|
|
30
|
+
state: { type: Object, required: true },
|
|
31
|
+
limit: { type: Number, default: 16 },
|
|
32
|
+
},
|
|
33
|
+
emits: ["reset"],
|
|
34
|
+
setup(props, { emit }) {
|
|
35
|
+
const root = ref(null);
|
|
36
|
+
let view = null;
|
|
37
|
+
onMounted(() => {
|
|
38
|
+
view = associationsTable(root.value, { onReset: () => emit("reset"), limit: props.limit });
|
|
39
|
+
view.update(props.state);
|
|
40
|
+
});
|
|
41
|
+
watch(() => props.state, (s) => view?.update(s), { deep: true });
|
|
42
|
+
onBeforeUnmount(() => view?.dispose());
|
|
43
|
+
return () => h("div", { ref: root });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* The eye card. `draw` paints a frame of the selected who; call the exposed
|
|
48
|
+
* `frame()` each frame (a template ref). v-model:who is the selected id.
|
|
49
|
+
*/
|
|
50
|
+
export const EyeInset = defineComponent({
|
|
51
|
+
name: "EyeInset",
|
|
52
|
+
props: {
|
|
53
|
+
who: { type: Array, required: true },
|
|
54
|
+
draw: { type: Function, required: true },
|
|
55
|
+
selected: { type: String, default: undefined },
|
|
56
|
+
width: { type: Number, default: 320 },
|
|
57
|
+
height: { type: Number, default: 160 },
|
|
58
|
+
},
|
|
59
|
+
emits: ["update:selected"],
|
|
60
|
+
setup(props, { emit, expose }) {
|
|
61
|
+
const root = ref(null);
|
|
62
|
+
let view = null;
|
|
63
|
+
onMounted(() => {
|
|
64
|
+
view = eyeInset(root.value, {
|
|
65
|
+
who: props.who,
|
|
66
|
+
draw: (c, w) => props.draw(c, w),
|
|
67
|
+
width: props.width,
|
|
68
|
+
height: props.height,
|
|
69
|
+
...(props.selected ? { selected: props.selected } : {}),
|
|
70
|
+
onWho: (id) => emit("update:selected", id),
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
watch(() => props.selected, (id) => id && view?.select(id));
|
|
74
|
+
onBeforeUnmount(() => view?.dispose());
|
|
75
|
+
expose({
|
|
76
|
+
frame: () => view?.frame(),
|
|
77
|
+
mode: (t) => view?.mode(t),
|
|
78
|
+
canvas: () => view?.canvas ?? null,
|
|
79
|
+
});
|
|
80
|
+
return () => h("figure", { ref: root });
|
|
81
|
+
},
|
|
82
|
+
});
|
package/how.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// how this works: the fold of the package page and of the suite tool. Plain data, no imports;
|
|
2
|
+
// checked by tsconfig.how.json, shipped in the tarball, never imported by the runtime entry.
|
|
3
|
+
const how: HowDoc = {
|
|
4
|
+
what: "the brain bars, the associations table and the eye card of the dog yard, as views you mount on any page. each is a vue component and a custom element drawn with hackbuild-ui classes.",
|
|
5
|
+
how: [
|
|
6
|
+
"`drivesBars` draws what it is doing in big letters with the why under it, a bar per act for what that act is worth now with the chosen one in pink, and a bar per drive. `drivesBarsState` builds its state from a drives `Chooser` decision and the `Drives` values.",
|
|
7
|
+
"`associationsTable` draws cues by acts: each cell is the net strength, excitation minus inhibition, from 0 to 99 in pink, and the attn column is how much it still pays attention to the cue. `associationsState` reads a `CueLearner`; reset learning calls your `onReset`.",
|
|
8
|
+
"`eyeInset` makes an element the eye card: a canvas, a who switch and a mode line. each frame it calls your draw inside the who's first person eye from @hackbuild/cameras, so its own head is hidden for that render. a draw that returns a string sets the mode line.",
|
|
9
|
+
"`defineViews()` registers `hb-drives-bars`, `hb-associations-table` and `hb-eye-inset`; the vue forms live in `@hackbuild/agents-views/vue`. load hackbuild-ui's hackbuild.css for the look.",
|
|
10
|
+
],
|
|
11
|
+
packages: ["@hackbuild/agents-views", "@hackbuild/drives", "@hackbuild/cameras"],
|
|
12
|
+
install: "npm install @hackbuild/agents-views @hackbuild/drives @hackbuild/cameras @virgilvox/hackbuild-ui",
|
|
13
|
+
today: `git clone https://github.com/hackbuild/hackbuild-agents
|
|
14
|
+
cd hackbuild-agents && npm ci && npm run build -w @hackbuild/agents-views`,
|
|
15
|
+
lang: "ts",
|
|
16
|
+
code: `import { drivesBars, drivesBarsState } from "@hackbuild/agents-views";
|
|
17
|
+
|
|
18
|
+
const bars = drivesBars(document.querySelector("#brain"));
|
|
19
|
+
// each tick, after the chooser decided
|
|
20
|
+
const d = chooser.update(now, utilities);
|
|
21
|
+
bars.update(drivesBarsState(d, drives, { now, seconds: now - since }));`,
|
|
22
|
+
links: { page: "https://hackbuild.github.io/hackbuild-agents/drives-bars/", source: "https://github.com/hackbuild/hackbuild-agents/tree/main/packages/agents-views" },
|
|
23
|
+
};
|
|
24
|
+
export default how;
|
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/agents-views",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Views that bind the agents packages to the hackbuild-ui class layer: the behaviour, utility and drive bars, the cues by acts associations table, and the eye inset. Each ships as a Vue component and as a custom element.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Moheeb Zara <hackbuildvideo@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/hackbuild/hackbuild-agents.git",
|
|
11
|
+
"directory": "packages/agents-views"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./vue": {
|
|
23
|
+
"types": "./dist/vue.d.ts",
|
|
24
|
+
"import": "./dist/vue.js"
|
|
25
|
+
},
|
|
26
|
+
"./iife": "./dist/agents-views.iife.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"how.ts"
|
|
33
|
+
],
|
|
34
|
+
"unpkg": "./dist/agents-views.iife.js",
|
|
35
|
+
"jsdelivr": "./dist/agents-views.iife.js",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node ../../tools/build-package.mjs agents-views HackbuildAgentsViews"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@virgilvox/hackbuild-ui": ">=0.10.0 <0.12.0",
|
|
41
|
+
"vue": "^3.5.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@virgilvox/hackbuild-ui": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"vue": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|