@xpell/core 2.0.0-alpha.10 → 2.0.1

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 CHANGED
@@ -1,96 +1,135 @@
1
- # Xpell Core
1
+ # @xpell/core
2
2
 
3
- **Xpell Core** is the foundational runtime of the Xpell framework.
4
- It provides the core engine, real-time update loop, event system, data layer, and utilities used by XUI (UI engine), X3D (3D engine), and higher-level Xpell modules.
3
+ Xpell 2 Alpha --- AI-Native Runtime Engine
5
4
 
6
- Xpell Core is designed for **high-performance, real-time JavaScript/TypeScript applications**, including:
5
+ `@xpell/core` is the foundational execution layer of the Xpell 2
6
+ platform.
7
7
 
8
- - real-time UI
9
- - AI-driven interfaces
10
- - dashboards
11
- - data-driven visualizations
12
- - WebGL/3D experiences
13
- - vibe-coded apps (LLM-assisted development)
8
+ It defines the runtime contracts that power the entire ecosystem,
9
+ including:
14
10
 
15
- If you are building with Xpell, this package provides the low-level primitives the rest of the framework depends on.
11
+ - `@xpell/ui` (real-time UI layer)
12
+ - `@xpell/3d` (spatial runtime)
13
+ - `@xpell/node` (server runtime)
16
14
 
17
- ## Features
15
+ Xpell Core is designed for real-time, AI-collaborative systems --- where
16
+ applications can evolve at runtime instead of relying solely on rebuild
17
+ cycles.
18
18
 
19
- - Real-time engine update loop
20
- - Event and signal system
21
- - Core data structures
22
- - Object lifecycle management
23
- - Shared utilities for UI, 3D, and AI modules
24
- - Zero-dependency, lightweight foundation
25
- - Written in TypeScript
19
+ > This package is part of the Xpell 2 Alpha platform.\
20
+ > See the full release overview at https://xpell.ai
26
21
 
27
- ## Installation
22
+ ------------------------------------------------------------------------
28
23
 
29
- npm install xpell-core
30
- pnpm add xpell-core
31
- yarn add xpell-core
24
+ ## What @xpell/core Provides
32
25
 
33
- ## Usage
26
+ ### XData 2
34
27
 
35
- xpell-core provides low-level building blocks for the Xpell framework. Below is a simple example showing how to use Xpell Core's event system and update loop.
28
+ Structured shared runtime state for predictable mutation and
29
+ coordination.
36
30
 
37
- ## When to use Xpell Core
31
+ ### Nano-Commands 2
38
32
 
39
- Use xpell-core directly if you are:
33
+ Command handlers defined as text or structured JSON, enabling safe
34
+ serialization and AI-driven runtime edits.
40
35
 
41
- - Building low-level extensions for Xpell
42
- - Creating custom UI components
43
- - Developing new rendering pipelines
44
- - Writing real-time, loop-driven modules
45
- - Integrating AI-powered reactive systems
46
- - Working inside internal Xpell packages
36
+ ### XEM (Xpell Event Manager)
47
37
 
48
- Most end-users should install:
38
+ A lightweight process-wide event bus for decoupled runtime coordination.
49
39
 
50
- npm install xpell
40
+ ### XModule
51
41
 
52
- which includes xpell-core automatically.
42
+ The only valid extension point for behavior in the Xpell runtime.
53
43
 
54
- ## Who Should Use xpell-core Directly?
44
+ ### XObject
55
45
 
56
- Most developers should **not** depend on xpell-core directly.
46
+ The base runtime object model (UI behavior lives only in `@xpell/ui`).
57
47
 
58
- Use xpell-core only if you are:
59
- - Developing Xpell framework modules
60
- - Building custom runtime systems
61
- - Extending XModule or XObject internals
62
- - Working on Xpell UI / 3D / server internals
48
+ ### Execution Loop
63
49
 
64
- For application development, use:
65
- - xpell-ui
66
- - xpell
50
+ Deterministic real-time update cycle for dynamic systems.
67
51
 
52
+ ------------------------------------------------------------------------
68
53
 
69
- ## Relationship to the Xpell Framework
54
+ ## Design Principles
70
55
 
71
- Xpell Core powers all other Xpell packages:
56
+ - Runtime-first architecture
57
+ - Explicit contracts over hidden state
58
+ - Modular extension via XModule
59
+ - No UI assumptions inside core
60
+ - Zero external dependencies
61
+ - TypeScript-native
72
62
 
73
- - xpell-ui
74
- - xpell-3d
75
- - xpell
76
- - future Xpell II modules
63
+ ------------------------------------------------------------------------
77
64
 
78
- ## Documentation
65
+ ## Installation (Alpha)
79
66
 
80
- For a detailed overview of the Xpell architecture, see
81
- [`docs/architecture/overview.md`](docs/architecture/overview.md).
67
+ npm install @xpell/core@alpha
82
68
 
83
- ## Links
69
+ You will typically combine it with:
84
70
 
85
- https://xpell.ai
71
+ npm install @xpell/ui@alpha\
72
+ npm install @xpell/node@alpha\
73
+ npm install @xpell/3d@alpha
86
74
 
87
- GitHub:
88
- https://github.com/xpell-ai/xpell-core
75
+ Alpha builds are intentionally not published under the `latest` tag.
76
+
77
+ ------------------------------------------------------------------------
78
+
79
+ ## When to Use @xpell/core Directly
80
+
81
+ Most application developers should work with higher-level packages.
82
+
83
+ Use `@xpell/core` directly if you are:
84
+
85
+ - Building runtime extensions
86
+ - Creating custom XModule implementations
87
+ - Extending engine-level primitives
88
+ - Working on Xpell internals
89
+ - Developing advanced AI-driven runtime systems
90
+
91
+ ------------------------------------------------------------------------
92
+
93
+ ## Architecture Role in Xpell 2
94
+
95
+ Xpell 2 is modular:
96
+
97
+ - `@xpell/core` → Runtime contracts + execution engine\
98
+ - `@xpell/ui` → Real-time UI framework\
99
+ - `@xpell/3d` → Three.js-based spatial runtime\
100
+ - `@xpell/node` → Server runtime (xnode, Wormholes, XDB)
101
+
102
+ Core defines the execution model.\
103
+ Other packages implement specialized layers on top of it.
104
+
105
+ ------------------------------------------------------------------------
106
+
107
+ ## Alpha Status
108
+
109
+ This package is currently in Alpha.
110
+
111
+ - APIs may evolve
112
+ - Contracts may be refined
113
+ - Performance optimizations are ongoing
114
+
115
+ This release is intended for architectural experimentation and early
116
+ adopters.
117
+
118
+ ------------------------------------------------------------------------
119
+
120
+ ## Documentation & Links
121
+
122
+ Website: https://xpell.ai\
123
+ GitHub: https://github.com/xpell-ai/xpell-core
124
+
125
+ ------------------------------------------------------------------------
89
126
 
90
127
  ## Versioning
91
128
 
92
- xpell-core follows **semantic versioning**, aligned with the main Xpell release stream.
129
+ Follows semantic versioning under the Xpell 2 release stream.
130
+
131
+ ------------------------------------------------------------------------
93
132
 
94
133
  ## License
95
134
 
96
- MIT License © Aime Technologies, 2022–Present
135
+ MIT License --- © Aime Technologies
@@ -42,7 +42,7 @@ export type XCommandData = {
42
42
  _object?: string;
43
43
  _op: string;
44
44
  _params?: {
45
- [k: string]: string | number | Function;
45
+ [k: string]: string | number | boolean | null | undefined | object | any[];
46
46
  };
47
47
  };
48
48
  export declare class XCommand {
@@ -62,7 +62,7 @@ export declare class XCommand {
62
62
  * command parameters array
63
63
  */
64
64
  _params?: {
65
- [k: string]: string | number | Function;
65
+ [k: string]: string | number | boolean | null | object | any[];
66
66
  };
67
67
  /**
68
68
  * XCommand create date timestamp
package/dist/XData.d.ts CHANGED
@@ -48,4 +48,5 @@ export declare class _XData {
48
48
  }
49
49
  /** Singleton */
50
50
  export declare const XData: _XData;
51
+ export declare const _xd: _XData;
51
52
  export default XData;
@@ -0,0 +1,41 @@
1
+ import { XModule } from "./XModule";
2
+ import { XCommand } from "./XCommand";
3
+ import type { XpellSkill, XpellSkillCommand } from "./XSkills";
4
+ export declare class XDataModule extends XModule {
5
+ static _name: string;
6
+ static _skill: XpellSkill;
7
+ static _ops: Record<string, XpellSkillCommand>;
8
+ constructor();
9
+ _get(xcmd: XCommand): Promise<{
10
+ _ok: boolean;
11
+ _result: any;
12
+ }>;
13
+ _set(xcmd: XCommand): Promise<{
14
+ _ok: boolean;
15
+ _result: {
16
+ key: string;
17
+ };
18
+ }>;
19
+ _patch(xcmd: XCommand): Promise<{
20
+ _ok: boolean;
21
+ _result: {
22
+ key: string;
23
+ };
24
+ }>;
25
+ _delete(xcmd: XCommand): Promise<{
26
+ _ok: boolean;
27
+ _result: {
28
+ key: string;
29
+ };
30
+ }>;
31
+ _touch(xcmd: XCommand): Promise<{
32
+ _ok: boolean;
33
+ _result: {
34
+ key: string;
35
+ };
36
+ }>;
37
+ _has(xcmd: XCommand): Promise<{
38
+ _ok: boolean;
39
+ _result: boolean;
40
+ }>;
41
+ }
@@ -0,0 +1,10 @@
1
+ import XCommand from "./XCommand.js";
2
+ import { XModule } from "./XModule.js";
3
+ import type { XpellSkill, XpellSkillCommand } from "./XSkills";
4
+ export declare class XEventManagerModule extends XModule {
5
+ static _name: string;
6
+ static _skill: XpellSkill;
7
+ static _ops: Record<string, XpellSkillCommand>;
8
+ constructor();
9
+ _fire(xcmd: XCommand): Promise<void>;
10
+ }
@@ -49,9 +49,6 @@ export declare class _XEventManager {
49
49
  */
50
50
  clear(): void;
51
51
  }
52
- /**
53
- * Global Xpell event manager instance.
54
- */
55
- export declare const XEventManager: _XEventManager;
56
- export declare const _xem: _XEventManager;
57
- export default XEventManager;
52
+ export declare function setXEventManager(xem: any): void;
53
+ export declare function getXEventManager(): any;
54
+ export default _XEventManager;
package/dist/XModule.d.ts CHANGED
@@ -56,10 +56,12 @@
56
56
  import XObjectManager from "./XObjectManager";
57
57
  import { XObjectData, XObject, XObjectPack } from "./XObject";
58
58
  import XCommand, { XCommandData } from "./XCommand";
59
+ import type { XpellSkill, XpellSkillCommand } from "./XSkills";
59
60
  export type XModuleData = {
60
61
  _name: string;
61
62
  };
62
63
  export declare const XD_MODULE_NUM_OF_OBJECTS = "engine:module:num-of-objects:";
64
+ export declare const XMODULE_SKILL: XpellSkill;
63
65
  /**
64
66
  * Xpell Base Module
65
67
  * This class represents xpell base module to be extends
@@ -71,12 +73,22 @@ export declare class XModule {
71
73
  [k: string]: any;
72
74
  _id: string;
73
75
  _name: string;
76
+ _loaded: boolean;
77
+ _loading: boolean;
74
78
  _log_rules: {
75
79
  createObject: boolean;
76
80
  removeObject: boolean;
77
81
  };
82
+ static _skill: XpellSkill;
83
+ static _ops: Record<string, XpellSkillCommand>;
84
+ static getOwnSkillBase(): XpellSkill;
85
+ getOwnSkill(): XpellSkill;
86
+ getSkillChain(): XpellSkill[];
87
+ getObjectSkills(): XpellSkill[];
88
+ getCommandSkills(): XpellSkillCommand[];
78
89
  constructor(data: XModuleData);
79
- load(): void;
90
+ load(): Promise<void>;
91
+ protected onLoad(): Promise<void>;
80
92
  /**
81
93
  * Creates new XObject from data object
82
94
  * @param data - The data of the new object (JSON)
@@ -126,6 +138,7 @@ export declare class XModule {
126
138
  * @returns XObject
127
139
  */
128
140
  getObject(objectId: string): XObject;
141
+ hasObject(name: string): boolean;
129
142
  /**
130
143
  * Returns the XObject instance from the module Object Manager
131
144
  * Usage:
@@ -1,42 +1,14 @@
1
- /**
2
- * XNanoCommands — Core Nano Command Definitions
3
- *
4
- * Built-in nano commands available to all XObject instances.
5
- *
6
- * This module defines the foundational nano commands that form the
7
- * minimal executable vocabulary of the Xpell runtime. These commands
8
- * are registered on every XObject and can be invoked via command text,
9
- * events, or programmatic execution.
10
- *
11
- * Nano commands act as the bridge between declarative intent
12
- * (strings, schemas, AI output) and imperative runtime behavior.
13
- *
14
- * One-liner: Nano commands are the verbs of the Xpell runtime.
15
- *
16
- * @packageDocumentation
17
- * @since 2022-07-22
18
- * @author Tamir Fridman
19
- * @license MIT
20
- * @copyright
21
- * © 2022–present Aime Technologies. All rights reserved.
22
- */
23
1
  import XCommand, { XCommandData } from "./XCommand";
24
2
  import XObject from "./XObject";
25
- /**
26
- * Single x-nano-command interface
27
- */
3
+ import type { XpellSkillCommand } from "./XSkills";
28
4
  export interface XNanoCommand {
29
- (xCommand: XCommand | XCommandData, xObject: XObject): any;
5
+ (xCommand: XCommand | XCommandData, xObject?: XObject): any;
6
+ _skill?: XpellSkillCommand;
7
+ getSkill?: () => XpellSkillCommand;
30
8
  }
31
- /**
32
- * x-nano-command pack
33
- */
34
9
  export type XNanoCommandPack = {
35
10
  [k: string]: XNanoCommand;
36
11
  };
37
- /**
38
- * XNanoCommand Pack
39
- */
12
+ export declare function createNanoCommandWithSkill(handler: XNanoCommand, skill: XpellSkillCommand): XNanoCommand;
40
13
  export declare const _xobject_basic_nano_commands: XNanoCommandPack;
41
- declare const _default: XNanoCommandPack;
42
- export default _default;
14
+ export default _xobject_basic_nano_commands;
package/dist/XObject.d.ts CHANGED
@@ -26,10 +26,12 @@
26
26
  import XCommand, { XCommandData } from "./XCommand";
27
27
  import { XEventListenerOptions } from "./XEventManager";
28
28
  import { XNanoCommandPack, XNanoCommand } from "./XNanoCommands";
29
+ import type { XpellSkill, XpellSkillCommand } from "./XSkills";
30
+ export declare const XOBJECT_SKILL: XpellSkill;
29
31
  export type wordsList = {
30
32
  [k: string]: string;
31
33
  };
32
- export type XValue = string | number | boolean | null | undefined | Function | XValue[] | {
34
+ export type XValue = string | number | boolean | null | undefined | Function | object | any[] | XValue[] | {
33
35
  [k: string]: XValue;
34
36
  };
35
37
  export interface IXData {
@@ -48,10 +50,11 @@ export type XDataXporter = {
48
50
  [id: string]: XDataInstanceXporter;
49
51
  };
50
52
  };
51
- export type XObjectOnEventHandler = (xObject: XObject, data?: any) => void;
53
+ export type XObjectOnEventHandler = ((xObject: XObject, data?: any) => void) | string | XCommandData | XObjectOnEventHandler[];
52
54
  export interface XObjectOnEventIndex {
53
55
  [eventName: string]: XObjectOnEventHandler;
54
56
  }
57
+ type XObjectHandler = Function | string | XCommandData | XObjectHandler[];
55
58
  export type XObjectData = {
56
59
  [k: string]: XValue;
57
60
  _id?: string;
@@ -61,10 +64,10 @@ export type XObjectData = {
61
64
  _data_source?: string;
62
65
  _on?: XObjectOnEventIndex;
63
66
  _once?: XObjectOnEventIndex;
64
- _on_create?: string | Function;
65
- _on_mount?: string | Function;
66
- _on_frame?: string | Function;
67
- _on_data?: string | Function;
67
+ _on_create?: XObjectHandler;
68
+ _on_mount?: XObjectHandler;
69
+ _on_frame?: XObjectHandler;
70
+ _on_data?: XObjectHandler;
68
71
  _process_frame?: boolean;
69
72
  _process_data?: boolean;
70
73
  _nano_commands?: XNanoCommandPack;
@@ -76,6 +79,7 @@ export type XObjectData = {
76
79
  */
77
80
  export declare class XObject {
78
81
  [k: string]: string | null | [] | undefined | Function | boolean | number | {} | null;
82
+ static _xtype: string;
79
83
  _id: string;
80
84
  _type: string;
81
85
  _children: Array<XObject | XObjectData>;
@@ -85,11 +89,11 @@ export declare class XObject {
85
89
  _debug?: boolean;
86
90
  _on: XObjectOnEventIndex;
87
91
  _once: XObjectOnEventIndex;
88
- _on_create?: string | Function | undefined;
89
- _on_mount?: string | Function | undefined;
90
- _on_frame?: string | Function | undefined;
91
- _on_data?: string | Function | undefined;
92
- _on_event?: string | Function | undefined;
92
+ _on_create?: XObjectHandler | undefined;
93
+ _on_mount?: XObjectHandler | undefined;
94
+ _on_frame?: XObjectHandler | undefined;
95
+ _on_data?: XObjectHandler | undefined;
96
+ _on_event?: XObjectHandler | undefined;
93
97
  _process_frame: boolean;
94
98
  _process_data: boolean;
95
99
  protected _xem_options: XEventListenerOptions;
@@ -106,6 +110,15 @@ export declare class XObject {
106
110
  protected _xporter: XDataXporter;
107
111
  private _xd_unsub?;
108
112
  private _xd_bound_key?;
113
+ /***
114
+ * Skills
115
+ */
116
+ static _skill: XpellSkill;
117
+ static getOwnSkill(): XpellSkill;
118
+ static getSkillChain(): XpellSkill[];
119
+ static getOwnNanoCommands(): XNanoCommandPack;
120
+ static getNanoCommands(): XNanoCommandPack;
121
+ static getNanoCommandSkills(): XpellSkillCommand[];
109
122
  /**
110
123
  * XObject constructor is creating the object and adding all the data keys to the XObject instance
111
124
  * @param data constructor input data (object)
@@ -123,7 +136,7 @@ export declare class XObject {
123
136
  */
124
137
  init(data?: any, skipParse?: boolean): void;
125
138
  parseEvents(options?: XEventListenerOptions): void;
126
- addEventListener(eventName: string, handler: XObjectOnEventHandler | string, options?: XEventListenerOptions): void;
139
+ addEventListener(eventName: string, handler: XObjectOnEventHandler | string | any, options?: XEventListenerOptions): string;
127
140
  removeEventListener(eventName: string): void;
128
141
  removeAllEventListeners(): void;
129
142
  /**
@@ -185,7 +198,8 @@ export declare class XObject {
185
198
  *
186
199
  */
187
200
  onCreate(): Promise<void>;
188
- protected checkAndRunInternalFunction(func: any, ...params: any): Promise<void>;
201
+ private runCmd;
202
+ protected checkAndRunInternalFunction(func: any, ...params: any): Promise<any>;
189
203
  /**
190
204
  * Triggers when the object is being mounted to other element
191
205
  * support external _on_create anonymous function in the , example:
@@ -241,7 +255,7 @@ export declare class XObject {
241
255
  * }
242
256
  *
243
257
  */
244
- execute(xCommand: XCommand | XCommandData): Promise<void>;
258
+ execute(xCommand: XCommand | XCommandData): Promise<any>;
245
259
  /**
246
260
  * Return an IXObjectData JSON representation of the XObject
247
261
  * @returns IXObjectData
@@ -61,8 +61,10 @@ export declare class XObjectManager {
61
61
  /**
62
62
  * Retrieves all the classes dictionary
63
63
  * @returns XObjectManagerIndex
64
+ * @deprecated use getObjectClasses() instead
64
65
  */
65
66
  getAllClasses(): XObjectManagerIndex;
67
+ getObjectClasses(): XObjectManagerIndex;
66
68
  get _classes(): XObjectManagerIndex;
67
69
  /**
68
70
  * Add XObject instance to the manager
package/dist/XParams.d.ts CHANGED
@@ -52,7 +52,7 @@ export type XCmdLike = {
52
52
  };
53
53
  export declare class XParams {
54
54
  static get(cmd: any, key: string | number, def?: any): any;
55
- static has(cmd: any, key: string | number): any;
55
+ static has(cmd: any, key: string | number): boolean;
56
56
  static str(cmd: any, ...keys: (string | number)[]): string | undefined;
57
57
  static bool(cmd: any, key: string | number, def?: boolean): boolean;
58
58
  static int(cmd: any, key: string | number, def?: number): number;
@@ -0,0 +1,2 @@
1
+ export declare function setXRuntime(x: any): void;
2
+ export declare function getXRuntime(): any;
@@ -0,0 +1,47 @@
1
+ export type XpellSkillType = "view-skill" | "flow-skill" | "entity-skill" | "runtime-api-skill" | "nano-command-pack" | "server-module-api" | "client-module-api" | "wormholes-protocol" | "xdata-skill" | "general";
2
+ export type XpellSkillCommand = {
3
+ _name: string;
4
+ _scope?: string;
5
+ _description?: string;
6
+ _params?: Record<string, any>;
7
+ _example?: Record<string, any>;
8
+ };
9
+ export type XpellSkillModule = {
10
+ _name: string;
11
+ _scope?: "server" | "client" | "shared";
12
+ _description?: string;
13
+ _ops?: XpellSkillCommand[];
14
+ };
15
+ export type XpellSkill = {
16
+ _id: string;
17
+ _title: string;
18
+ _version: string;
19
+ _active?: boolean;
20
+ _type?: XpellSkillType;
21
+ _description?: string;
22
+ _requires?: string[];
23
+ _match?: {
24
+ _keywords?: string[];
25
+ _requires_any?: string[];
26
+ _requires_all?: string[];
27
+ _exclude_keywords?: string[];
28
+ _priority?: number;
29
+ };
30
+ _fields?: Record<string, any>;
31
+ _exports?: {
32
+ _xui_objects?: string[];
33
+ _xui_fields?: string[];
34
+ _nano_commands?: XpellSkillCommand[];
35
+ _modules?: XpellSkillModule[];
36
+ _client_ops?: XpellSkillCommand[];
37
+ _server_ops?: XpellSkillCommand[];
38
+ };
39
+ _core_rules?: string[];
40
+ _priority_rules?: string[];
41
+ _canonical_examples?: Record<string, any>[];
42
+ _anti_patterns?: Array<string | {
43
+ _bad: any;
44
+ _reason: string;
45
+ }>;
46
+ _notes?: string[];
47
+ };
package/dist/XUtils.d.ts CHANGED
@@ -75,6 +75,41 @@ export declare class _XUtils {
75
75
  * - Node / non-DOM: setImmediate (fast) or setTimeout (paced by target fps)
76
76
  */
77
77
  createDefaultScheduler(_target_fps?: number): XFrameScheduler;
78
+ to_iso_now(): string;
79
+ is_plain_object(value: unknown): value is Record<string, any>;
80
+ ensure_string(value: unknown, field: string): string;
81
+ ensure_params(raw: unknown): Record<string, any>;
82
+ /**
83
+ * Copy keys from source to target only when value is not null/undefined.
84
+ * Keeps valid falsy values (0, false, "").
85
+ */
86
+ addIfNotNull(source: any, target: any, keys: string[]): void;
87
+ /**
88
+ * Add Last Slash
89
+ * adds a last slash to the url if it doesn't have one
90
+ */
91
+ als(url: string): string;
92
+ /**
93
+ * Clear Last Slash
94
+ * removes the last slash if exists
95
+ */
96
+ cls(url: string): string;
97
+ /**
98
+ * Add First Slash
99
+ */
100
+ afs(url: string): string;
101
+ /**
102
+ * Clear First Slash
103
+ */
104
+ cfs(url: string): string;
105
+ /**
106
+ * Calculates expiration time based on short format:
107
+ * - 1h (hours)
108
+ * - 2d (days)
109
+ * - 3y (years, 365d)
110
+ * Returns epoch ms (now + delta).
111
+ */
112
+ calculateExpiration(exp: string): number;
78
113
  }
79
114
  declare const XUtils: _XUtils;
80
115
  declare const _xu: _XUtils;