@xpell/core 2.0.1 → 2.0.3
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/dist/FPSCalc.d.ts +18 -0
- package/dist/XDataModule.d.ts +12 -0
- package/dist/XObject.d.ts +24 -1
- package/dist/XUtils.d.ts +93 -18
- package/dist/Xpell.d.ts +1 -1
- package/dist/xpell-core.cjs.js +3 -2
- package/dist/xpell-core.es.js +884 -507
- package/docs/AGENTS.md +10 -0
- package/package.json +2 -2
- package/docs/Codex.md +0 -138
- package/docs/Codex_Skills/SKILL.md +0 -184
- package/docs/Codex_Skills/SKILL_API_MAP.md +0 -122
- package/docs/Codex_Skills/SKILL_CHECKLIST.md +0 -18
package/docs/AGENTS.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpell/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"typedoc": "^0.27.9",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"vite": "^7.3.
|
|
55
|
+
"vite": "^7.3.3"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"dev": "vite",
|
package/docs/Codex.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
# XPELL-CORE codex.md rules for ai agent for vibe coding with xpell-core
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
This document defines the strict contract for **xpell-core** — the runtime engine and interpreter that powers all Xpell systems.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Core Responsibilities
|
|
9
|
-
xpell-core provides:
|
|
10
|
-
- Engine loop
|
|
11
|
-
- Event system
|
|
12
|
-
- Command system
|
|
13
|
-
- Data layer (XData)
|
|
14
|
-
- Object lifecycle (XObject)
|
|
15
|
-
- Module loading (XModule)
|
|
16
|
-
|
|
17
|
-
xpell-core does **NOT** provide UI rendering.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Runtime Object Model
|
|
22
|
-
|
|
23
|
-
- `XObject` is the foundational runtime object.
|
|
24
|
-
- XObject is **UI-agnostic** and MUST NOT include or assume:
|
|
25
|
-
- DOM access
|
|
26
|
-
- visibility logic
|
|
27
|
-
- UI methods (`show`, `hide`, etc.)
|
|
28
|
-
|
|
29
|
-
UI behavior is added only by higher-level layers (e.g. `XUIObject`).
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
## XData Contract (XData2)
|
|
33
|
-
|
|
34
|
-
- XData is shared runtime memory (process-wide), used for explicit state sharing and signaling.
|
|
35
|
-
- XData is NOT persistence.
|
|
36
|
-
- Keys must be explicit, stable, and documented at their point of use.
|
|
37
|
-
- No module may mirror XData into hidden local mutable state as a “shadow source of truth”.
|
|
38
|
-
|
|
39
|
-
### Canonical API (required)
|
|
40
|
-
All new code MUST use the XData2 API:
|
|
41
|
-
|
|
42
|
-
- Read: `XData.get(key)` / `_xd.get(key)`
|
|
43
|
-
- Write: `XData.set(key, value, { source })` / `_xd.set(...)`
|
|
44
|
-
- Delete: `XData.delete(key, { source })` / `_xd.delete(...)`
|
|
45
|
-
- Subscribe: `XData.on(key, cb)` / `_xd.on(...)`
|
|
46
|
-
- Notify without changing value (optional): `XData.touch(key, { source })`
|
|
47
|
-
- Mailbox semantics (optional): `XData.pick(key, { source })`
|
|
48
|
-
|
|
49
|
-
### Compatibility API (legacy)
|
|
50
|
-
- Direct object access via `_o` is LEGACY compatibility only:
|
|
51
|
-
- `XData._o[key] = value`
|
|
52
|
-
- `_xd._o[key] = value`
|
|
53
|
-
- `_o` access MAY exist only to support old code and migration.
|
|
54
|
-
- New code MUST NOT write via `_o`.
|
|
55
|
-
- Core may optionally:
|
|
56
|
-
- warn in dev on legacy writes (`_warn_legacy_writes`)
|
|
57
|
-
- route legacy writes through `.set()` (`_compat_writes`)
|
|
58
|
-
- Whether `_o` triggers notifications is a configuration detail of XData2, not a contract.
|
|
59
|
-
|
|
60
|
-
### Required metadata
|
|
61
|
-
- Every `.set()` and `.delete()` in core/runtime code MUST include a `source` string.
|
|
62
|
-
- Example: `{ source: "xvm:navigate" }`
|
|
63
|
-
- `source` must be stable and human-readable for debugging.
|
|
64
|
-
|
|
65
|
-
### Rules
|
|
66
|
-
- Do not assume ordering of listeners.
|
|
67
|
-
- Avoid high-frequency writes unless necessary (frame loop keys should be intentional).
|
|
68
|
-
- Do not use XData as an event bus; use XEventManager (`_xem`) for events.
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## Naming Convention — Runtime State
|
|
73
|
-
|
|
74
|
-
- All runtime-managed object members MUST:
|
|
75
|
-
- start with `_`
|
|
76
|
-
- use `snake_case`
|
|
77
|
-
|
|
78
|
-
- Method names MAY use `camelCase`.
|
|
79
|
-
|
|
80
|
-
This defines the boundary between runtime state and implementation logic.
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Method Exposure & Command Mapping
|
|
85
|
-
|
|
86
|
-
### Method Visibility
|
|
87
|
-
- Methods starting with `_` are **public to the Xpell engine**.
|
|
88
|
-
- Such methods may be invoked via `run / execute`.
|
|
89
|
-
- Methods without `_` are internal-only.
|
|
90
|
-
|
|
91
|
-
This replaces legacy descriptor-based exposure.
|
|
92
|
-
|
|
93
|
-
### Command Name Mapping
|
|
94
|
-
- Leading `_` is removed when invoked.
|
|
95
|
-
- `_` and `-` are interchangeable.
|
|
96
|
-
- No other transformations are allowed.
|
|
97
|
-
|
|
98
|
-
Example:
|
|
99
|
-
```ts
|
|
100
|
-
public _my_x_method(cmd) { ... }
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Callable as:
|
|
104
|
-
```txt
|
|
105
|
-
my_x_method
|
|
106
|
-
my-x-method
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Parser Responsibilities
|
|
112
|
-
|
|
113
|
-
- `XParser.parse()` → module-level commands only.
|
|
114
|
-
- Object / nano-command parsing is internal and separate.
|
|
115
|
-
- Parsers must not infer or substitute for one another.
|
|
116
|
-
- Parsing never executes commands or mutates state.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Platform Rules
|
|
121
|
-
|
|
122
|
-
- xpell-core is platform-agnostic by design.
|
|
123
|
-
- Platform-specific logic must be isolated.
|
|
124
|
-
- Core must not assume DOM, UI, or filesystem access.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Forbidden Patterns ❌
|
|
129
|
-
- UI logic in core
|
|
130
|
-
- Implicit globals
|
|
131
|
-
- Hidden mutable state
|
|
132
|
-
- Framework-style lifecycles
|
|
133
|
-
- API inference or auto-magic
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## One-Line Anchor
|
|
138
|
-
**xpell-core is a real-time interpreter engine that provides execution, data, and events for Xpell systems.**
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Xpell Core Contract
|
|
3
|
-
id: xpell-core
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
updated: 2026-02-26
|
|
6
|
-
description: Foundational runtime contract for @xpell/core: deterministic interpreter, XData2 shared state, Nano-Commands v2, XEM event bus, and module/object base classes. Enforces data-first AI-native execution.
|
|
7
|
-
requires:
|
|
8
|
-
- xpell-contract
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 1) Applies to / Scope
|
|
12
|
-
- Package: `@xpell/core` in this repository.
|
|
13
|
-
- Source of truth scanned: `package.json`, all `src/*.ts`, `README.md`, `docs/Codex.md`, `docs/XData 2.md`, `docs/nano-commands2.md`, `docs/architecture/overview.md`, and built type entry (`dist/index.d.ts`).
|
|
14
|
-
- This contract governs code that depends on core directly, and integration layers built on top (`@xpell/ui`, `@xpell/node`, `@xpell/3d`, app repos).
|
|
15
|
-
|
|
16
|
-
## 2) Core identity (what it is / isn’t)
|
|
17
|
-
What it is:
|
|
18
|
-
- A runtime/interpreter core with:
|
|
19
|
-
- engine loop + scheduler (`XpellEngine.onFrame`, `start`)
|
|
20
|
-
- command dispatch (`run`, `execute`)
|
|
21
|
-
- shared runtime state (`XData` / `_xd`)
|
|
22
|
-
- event bus (`XEventManager` / `_xem`)
|
|
23
|
-
- base extension/object model (`XModule`, `XObject`, `XObjectManager`)
|
|
24
|
-
|
|
25
|
-
What it is not:
|
|
26
|
-
- Not a UI renderer or DOM layer.
|
|
27
|
-
- Not a persistence/database layer.
|
|
28
|
-
- Not an app/business framework.
|
|
29
|
-
- Not a hidden-state runtime; contracts are explicit.
|
|
30
|
-
|
|
31
|
-
Code reality caveat:
|
|
32
|
-
- `XParser.xmlString2Xpell()` uses `DOMParser`; this helper requires an environment that provides it.
|
|
33
|
-
|
|
34
|
-
## 3) Public API map (high level; details in SKILL_API_MAP.md)
|
|
35
|
-
- Package export surface is a single public subpath: `"."` (plus `"./package.json"`).
|
|
36
|
-
- Public entrypoint re-exports from `src/Xpell.ts` via `src/index.ts`.
|
|
37
|
-
- High-level API groups:
|
|
38
|
-
- Engine/runtime singleton: `Xpell`, `_x`, `XpellEngine`
|
|
39
|
-
- State: `XData`, `_xd`, `_XData`
|
|
40
|
-
- Events: `XEventManager`, `_xem`, `_XEventManager`
|
|
41
|
-
- Modules/objects: `XModule`, `XObject`, `XObjectManager`, `XObjectPack`
|
|
42
|
-
- Commands/parsing: `XCommand`, `XParser`, nano-command types
|
|
43
|
-
- Utility/protocol/error: `XUtils`, `XParams`, `XResponse*`, `XError`, `XLogger`
|
|
44
|
-
- Integration expectations by layer:
|
|
45
|
-
- `@xpell/ui`: implements UI-specific objects/ops on top of core (`XObject` stays UI-agnostic in core).
|
|
46
|
-
- `@xpell/3d`: implements 3D/spatial behavior on top of core lifecycle, events, and commands.
|
|
47
|
-
- `@xpell/node`: uses core runtime contracts (commands/events/XData/protocol) without DOM assumptions.
|
|
48
|
-
- App repos: should depend on higher layers (`@xpell/ui`, `@xpell/node`, `@xpell/3d`) unless extending engine internals directly.
|
|
49
|
-
- Detailed package-specific operation allowlists for `@xpell/ui`, `@xpell/3d`, and `@xpell/node` are `unknown` in this repo (not defined under `@xpell/core` source).
|
|
50
|
-
|
|
51
|
-
## 4) Runtime invariants (single source of truth, execute path, state, events)
|
|
52
|
-
- Single source of truth:
|
|
53
|
-
- Engine module registry inside `_x` (`_modules`) is authoritative for module command routing.
|
|
54
|
-
- Runtime shared data keys live in `XData`; object-level behavior lives on `XObject` instances.
|
|
55
|
-
- Execute path:
|
|
56
|
-
- `_x.run("...")` -> `XParser.parse(...)` -> `_x.execute(xcmd)`.
|
|
57
|
-
- `_x.execute(xcmd)` requires `xcmd._module` and a loaded module; otherwise throws.
|
|
58
|
-
- `XModule.execute(xcmd)`:
|
|
59
|
-
- if `xcmd._object` exists: dispatches to that object’s `XObject.execute(...)`.
|
|
60
|
-
- else maps op to module method: `"_"+_op.replaceAll("-", "_")`; missing op throws.
|
|
61
|
-
- `XObject.execute(xcmd)` resolves `_op` in object’s `_nano_commands`; missing op logs error.
|
|
62
|
-
- Loop/state:
|
|
63
|
-
- Engine increments frame, calls each module `onFrame`, then writes:
|
|
64
|
-
- `engine:frame-number`
|
|
65
|
-
- `engine:fps`
|
|
66
|
-
- legacy keys `frame-number` / `fps` only when `_compat_legacy_keys` is true.
|
|
67
|
-
- Events:
|
|
68
|
-
- Event coordination uses `_xem` (`on`, `once`, `fire`, `remove`, `removeOwner`).
|
|
69
|
-
- `XObject` event handlers are parsed once on mount and cleaned on dispose.
|
|
70
|
-
- Serialization:
|
|
71
|
-
- `XObject.toXData()` drops function fields.
|
|
72
|
-
- `XResponse.toXData()` returns transport-safe response envelope.
|
|
73
|
-
|
|
74
|
-
## 5) XData2 contract (keys, mutation rules, no hidden mirrors)
|
|
75
|
-
- Canonical API: `get`, `set`, `patch`, `touch`, `has`, `delete`, `pick`, `on`, `off`, `onAny`, `clean`.
|
|
76
|
-
- Mutations emit `XDataChange` with `{ key, value, prev, ts, op, meta }`.
|
|
77
|
-
- `_o` exists for compatibility and can proxy writes/deletes to canonical methods when `_compat_writes=true`.
|
|
78
|
-
- Listener order should not be relied on by consumers.
|
|
79
|
-
- Keys should be explicit and stable (contract/documentation requirement).
|
|
80
|
-
- Hidden mirrored mutable state is forbidden by contract (`docs/Codex.md`), not automatically enforced by runtime code.
|
|
81
|
-
- `source` metadata on writes/deletes is required by contract docs, but enforcement is partial: code accepts missing `meta` (`unknown` enforcement completeness).
|
|
82
|
-
|
|
83
|
-
## 6) Nano-Commands v2 contract (data-only, JSON form, sequences if present)
|
|
84
|
-
- Handler forms supported by `XObject` runtime:
|
|
85
|
-
- function (dev/runtime-authored)
|
|
86
|
-
- string nano-command
|
|
87
|
-
- JSON command object with `_op` (and optional `_params`)
|
|
88
|
-
- arrays/sequences of handlers (executed in order, awaited)
|
|
89
|
-
- JSON handler target rules in `XObject.checkAndRunInternalFunction`:
|
|
90
|
-
- `_object` may be omitted, `"this"`, or the current object id.
|
|
91
|
-
- non-self targets are rejected (logged, not executed).
|
|
92
|
-
- Built-in nano commands in core pack include:
|
|
93
|
-
- `info`, `log`, `fire`, `noop`, `set-field`, `delete-field`, `toggle-field`, `merge`, `run-seq`
|
|
94
|
-
- `run-seq` exists in code and enforces self-targeted steps only.
|
|
95
|
-
- Contract mismatch to note:
|
|
96
|
-
- `docs/nano-commands2.md` says “no run-seq nano command”; source code currently implements `"run-seq"`.
|
|
97
|
-
- Data-only requirement for DB-stored views is documented, but runtime does not globally block function handlers (`unknown` global validation boundary).
|
|
98
|
-
|
|
99
|
-
## 7) XEM contract (events are not a state store; payload explicit; ordering not assumed)
|
|
100
|
-
- API: `on`, `once`, `fire`, `remove`, `removeOwner`, `clear`.
|
|
101
|
-
- Events are coordination only; state belongs in `XData`.
|
|
102
|
-
- Payload is explicit (`fire(event_name, data)`).
|
|
103
|
-
- Listener order should not be assumed by consumers. Current implementation iterates a snapshot in registration order.
|
|
104
|
-
- Listener exceptions are caught and logged; dispatch continues.
|
|
105
|
-
|
|
106
|
-
## 8) XModule contract (only extension point; naming; ops; cross-module boundaries)
|
|
107
|
-
- `XModule` is the base extension point for behavior.
|
|
108
|
-
- Module identity uses `_name` and `_id`.
|
|
109
|
-
- Command exposure is underscore-prefixed methods:
|
|
110
|
-
- command `"my-op"` maps to method `"_my_op"`.
|
|
111
|
-
- Objects are created/owned through module’s `XObjectManager`.
|
|
112
|
-
- Object-targeted commands require explicit `_object` id.
|
|
113
|
-
- No fallback object-name command resolution in `execute` (explicitness over ambiguity).
|
|
114
|
-
- Cross-module behavior should go through engine dispatch/events/XData contracts; direct hidden mutation across modules is an anti-pattern.
|
|
115
|
-
|
|
116
|
-
## 9) XObject contract (no UI assumptions; lifecycle; no platform coupling)
|
|
117
|
-
- `XObject` is the base runtime node, not a UI object.
|
|
118
|
-
- Lifecycle hooks:
|
|
119
|
-
- `onCreate`
|
|
120
|
-
- `onMount` (parses events, binds `_data_source`)
|
|
121
|
-
- `onData`
|
|
122
|
-
- `onFrame`
|
|
123
|
-
- `dispose` (unbind data, remove listeners, clear refs, dispose children)
|
|
124
|
-
- Data-source binding is subscription-based (`_xd.on`), not frame polling.
|
|
125
|
-
- Exports are JSON-first via `toXData`; functions are omitted.
|
|
126
|
-
- `XObject` itself is UI-agnostic; UI methods belong to higher layers (`@xpell/ui`).
|
|
127
|
-
|
|
128
|
-
## 10) Hard forbiddens (explicit bullets)
|
|
129
|
-
- Do not add UI behavior (DOM/show/hide/layout/CSS assumptions) to `@xpell/core` base classes.
|
|
130
|
-
- Do not use `XData` as an event bus; use `_xem`.
|
|
131
|
-
- Do not rely on hidden mirrors of `XData` as shadow state.
|
|
132
|
-
- Do not write new code via `XData._o[...]` when canonical methods are available.
|
|
133
|
-
- Do not assume listener ordering semantics.
|
|
134
|
-
- Do not use `eval`, `new Function`, or executable code inside persisted command payloads.
|
|
135
|
-
- Do not perform implicit cross-object targeting in JSON handlers; keep handlers local unless explicitly supported by runtime boundary.
|
|
136
|
-
- Do not couple core to Node FS/DOM-only APIs in base runtime contracts.
|
|
137
|
-
|
|
138
|
-
## 11) Error + logging contract (structured errors, no secret logs)
|
|
139
|
-
- Structured error type: `XError` with `_code`, `_level`, `_meta`, `_cause`, `message`.
|
|
140
|
-
- Protocol envelope: `XResponse` / `XResponseOK` / `XResponseError` with `_ok`, `_ts`, `_pt`, `_result`.
|
|
141
|
-
- Unknown errors are normalized to `XError("E_INTERNAL", ...)` in `XResponse.error`.
|
|
142
|
-
- Logging:
|
|
143
|
-
- `XLogger` singleton is configurable.
|
|
144
|
-
- `_xlog` is `console` in dev and `XLogger` in production.
|
|
145
|
-
- Secret redaction is not built into logger (`unknown` automated redaction policy). Treat sensitive data logging as forbidden at usage level.
|
|
146
|
-
|
|
147
|
-
## 12) Minimal examples (2–3 short snippets, proven by repo patterns)
|
|
148
|
-
```ts
|
|
149
|
-
import { _x, XModule } from "@xpell/core";
|
|
150
|
-
|
|
151
|
-
class DemoModule extends XModule {
|
|
152
|
-
constructor() { super({ _name: "demo" }); }
|
|
153
|
-
_ping(cmd: any) { return cmd?._params?.msg ?? "pong"; }
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
_x.loadModule(new DemoModule());
|
|
157
|
-
const out = await _x.execute({ _module: "demo", _op: "ping", _params: { msg: "hi" } });
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
import { _xd } from "@xpell/core";
|
|
162
|
-
|
|
163
|
-
const off = _xd.on("engine:fps", (ch) => {
|
|
164
|
-
console.log("fps:", ch.value);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
_xd.set("engine:fps", 60, { source: "example:fps" });
|
|
168
|
-
off();
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
```ts
|
|
172
|
-
import { XObject } from "@xpell/core";
|
|
173
|
-
|
|
174
|
-
const obj = new XObject({
|
|
175
|
-
_id: "obj-1",
|
|
176
|
-
_on_data: [
|
|
177
|
-
{ _op: "log" },
|
|
178
|
-
{ _op: "set-field", _params: { name: "_name", value: "updated" } }
|
|
179
|
-
]
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
await obj.onMount();
|
|
183
|
-
await obj.onData({ value: 1 });
|
|
184
|
-
```
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# @xpell/core Skill API Map
|
|
2
|
-
|
|
3
|
-
## 1) package.json exports map
|
|
4
|
-
|
|
5
|
-
Verbatim export keys:
|
|
6
|
-
- `"."`
|
|
7
|
-
- `"./package.json"`
|
|
8
|
-
|
|
9
|
-
Resolved values summary:
|
|
10
|
-
- `"."`:
|
|
11
|
-
- `types`: `./dist/index.d.ts`
|
|
12
|
-
- `import`: `./dist/xpell-core.es.js`
|
|
13
|
-
- `require`: `./dist/xpell-core.cjs.js`
|
|
14
|
-
- `"./package.json"` -> `./package.json`
|
|
15
|
-
|
|
16
|
-
Related package entry fields:
|
|
17
|
-
- `main`: `./dist/xpell-core.cjs.js`
|
|
18
|
-
- `module`: `./dist/xpell-core.es.js`
|
|
19
|
-
- `types`: `./dist/index.d.ts`
|
|
20
|
-
|
|
21
|
-
## 2) Entrypoints and what they export
|
|
22
|
-
|
|
23
|
-
### `src/index.ts`
|
|
24
|
-
- `export * from "./Xpell"`
|
|
25
|
-
- `export { default } from "./Xpell"`
|
|
26
|
-
|
|
27
|
-
### `src/Xpell.ts` (public surface re-exported by package root)
|
|
28
|
-
Engine:
|
|
29
|
-
- `XpellEngine`
|
|
30
|
-
- `Xpell` (singleton), `_x` alias
|
|
31
|
-
- `XD_FRAME_NUMBER`, `XD_FPS`
|
|
32
|
-
|
|
33
|
-
State:
|
|
34
|
-
- `XData`, `_xd`, `_XData`
|
|
35
|
-
- `type XDataStore`
|
|
36
|
-
|
|
37
|
-
Events:
|
|
38
|
-
- `XEventManager`, `_xem`, `_XEventManager`
|
|
39
|
-
- `type XEventListener`
|
|
40
|
-
- `type XEventListenerOptions`
|
|
41
|
-
|
|
42
|
-
Modules/objects:
|
|
43
|
-
- `XModule` + `type XModuleData`
|
|
44
|
-
- `XObject`, `XObjectPack`
|
|
45
|
-
- `XObjectManager`
|
|
46
|
-
- `type XObjectData`
|
|
47
|
-
- `type XObjectOnEventIndex`
|
|
48
|
-
- `type XObjectOnEventHandler`
|
|
49
|
-
- `type XDataXporter`
|
|
50
|
-
- `type XDataXporterHandler`
|
|
51
|
-
- `type IXData`
|
|
52
|
-
- `type XValue`
|
|
53
|
-
|
|
54
|
-
Commands/parsing:
|
|
55
|
-
- `XParser`
|
|
56
|
-
- `XCommand` + `type XCommandData`
|
|
57
|
-
- `type XNanoCommandPack`
|
|
58
|
-
- `type XNanoCommand`
|
|
59
|
-
- `XParams`
|
|
60
|
-
|
|
61
|
-
Utilities/runtime helpers:
|
|
62
|
-
- `XUtils`, `_xu`, `_XUtils`
|
|
63
|
-
- `type XFrameScheduler`
|
|
64
|
-
- `XLogger`, `_xlog`, `_XLogger`
|
|
65
|
-
|
|
66
|
-
Protocol/errors:
|
|
67
|
-
- `XError` + `type XErrorOptions` + `type XErrorLevel` + `type XErrorMeta`
|
|
68
|
-
- `XResponse`, `XResponseOK`, `XResponseError`
|
|
69
|
-
- `type XResponseData`
|
|
70
|
-
|
|
71
|
-
## 3) Main folders/subsystems
|
|
72
|
-
|
|
73
|
-
`src/Xpell.ts`
|
|
74
|
-
- Engine singleton and frame loop, module loading, top-level command dispatch.
|
|
75
|
-
|
|
76
|
-
`src/XData.ts`
|
|
77
|
-
- XData2 shared runtime memory, change events, legacy `_o` compatibility proxy.
|
|
78
|
-
|
|
79
|
-
`src/XNanoCommands.ts`
|
|
80
|
-
- Built-in object nano-commands (`info`, `log`, `fire`, `noop`, field mutators, `run-seq`).
|
|
81
|
-
|
|
82
|
-
`src/XEventManager.ts`
|
|
83
|
-
- Process-wide event bus with listener ids, owner cleanup, one-time listeners.
|
|
84
|
-
|
|
85
|
-
`src/XModule.ts`
|
|
86
|
-
- Base module extension point, object registry ownership, op dispatch mapping.
|
|
87
|
-
|
|
88
|
-
`src/XObject.ts`
|
|
89
|
-
- Base runtime object with lifecycle hooks, event wiring, data-source binding, nano-command execution, JSON export.
|
|
90
|
-
|
|
91
|
-
`src/XObjectManager.ts`
|
|
92
|
-
- Registry for object classes and live module-owned objects.
|
|
93
|
-
|
|
94
|
-
`src/XParser.ts` + `src/XCommand.ts`
|
|
95
|
-
- Text/object command parsing and canonical command shape.
|
|
96
|
-
|
|
97
|
-
`src/XProtocol.ts` + `src/XError.ts`
|
|
98
|
-
- Response envelope and structured error model.
|
|
99
|
-
|
|
100
|
-
`src/XUtils.ts`, `src/XLogger.ts`, `src/XParams.ts`, `src/XConst.ts`
|
|
101
|
-
- Runtime utilities, logging, parameter helpers, shared node constants.
|
|
102
|
-
|
|
103
|
-
## 4) Hot classes/singletons for maintainers
|
|
104
|
-
|
|
105
|
-
Hot singletons:
|
|
106
|
-
- `_x` / `Xpell` -> global engine instance
|
|
107
|
-
- `_xd` / `XData` -> global runtime state store
|
|
108
|
-
- `_xem` / `XEventManager` -> global event bus
|
|
109
|
-
- `_xlog` / `XLogger` -> logging facade
|
|
110
|
-
- `_xu` / `XUtils` -> utility singleton
|
|
111
|
-
|
|
112
|
-
Hot base classes:
|
|
113
|
-
- `XModule` -> extension boundary for module behavior
|
|
114
|
-
- `XObject` -> base runtime object (no UI assumptions)
|
|
115
|
-
- `XObjectManager` -> module object/class registry
|
|
116
|
-
- `XCommand` -> normalized command envelope
|
|
117
|
-
- `_XData`, `_XEventManager`, `_XLogger`, `_XUtils` -> class-level implementations behind singletons
|
|
118
|
-
|
|
119
|
-
## 5) Maintainer notes (code-vs-doc reality)
|
|
120
|
-
|
|
121
|
-
- `docs/nano-commands2.md` states “no run-seq nano command”, but `src/XNanoCommands.ts` currently implements `"run-seq"`.
|
|
122
|
-
- Data-only handlers are documented as required for persisted views, but `XObject` still accepts function handlers (runtime/dev use).
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# @xpell/core Codex Checklist
|
|
2
|
-
|
|
3
|
-
Use this checklist before generating or editing code that depends on `@xpell/core`.
|
|
4
|
-
|
|
5
|
-
- [ ] Do not infer missing runtime state. Use explicit keys/params only.
|
|
6
|
-
- [ ] Treat `XData` as shared runtime memory, not persistence or an event bus.
|
|
7
|
-
- [ ] Use canonical `XData` APIs (`get/set/delete/touch/patch/on`), not new writes via `_o`.
|
|
8
|
-
- [ ] Include stable `source` metadata on `XData.set/delete/touch/pick` calls.
|
|
9
|
-
- [ ] Route cross-module behavior through `_x.execute(...)`, `_xem`, or documented `XData` keys.
|
|
10
|
-
- [ ] Ensure `_x.execute` payload includes `_module` and `_op`; include `_object` only for explicit object targeting.
|
|
11
|
-
- [ ] In `XModule`, expose executable ops as underscore methods (`_op_name`) and keep op names explicit.
|
|
12
|
-
- [ ] In `XObject`, keep handlers local/data-first: string, JSON command, or array sequence; avoid function handlers for persisted/agent-editable payloads.
|
|
13
|
-
- [ ] Do not assume event listener ordering; treat `_xem` events as coordination signals only.
|
|
14
|
-
- [ ] Keep core usage platform-neutral: no UI/DOM/Node-FS assumptions unless the code path explicitly supports that environment.
|
|
15
|
-
- [ ] Do not add UI behavior to core base classes (`XObject`, `XModule`, engine).
|
|
16
|
-
- [ ] Use structured errors (`XError`) and protocol responses (`XResponse*`) for transport-facing failures.
|
|
17
|
-
- [ ] Avoid logging secrets/sensitive payloads; `_xlog` has no built-in redaction guarantee.
|
|
18
|
-
- [ ] If docs and source disagree, follow source code and record the mismatch.
|