@spearwolf/shadow-objects 0.27.0 → 0.29.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/CHANGELOG.md +42 -4
- package/README.md +9 -42
- package/bundle.js +2 -2
- package/package.json +1 -1
- package/src/elements/ShaeEntElement.d.ts +1 -0
- package/src/elements/ShaeEntElement.d.ts.map +1 -1
- package/src/elements/ShaeEntElement.js +78 -2
- package/src/elements/ShaeEntElement.js.map +1 -1
- package/src/elements/ShaeWorkerElement.d.ts.map +1 -1
- package/src/elements/ShaeWorkerElement.js +7 -1
- package/src/elements/ShaeWorkerElement.js.map +1 -1
- package/src/elements/constants.d.ts +1 -0
- package/src/elements/constants.d.ts.map +1 -1
- package/src/elements/constants.js +1 -0
- package/src/elements/constants.js.map +1 -1
- package/src/in-the-dark/Entity.d.ts +2 -1
- package/src/in-the-dark/Entity.d.ts.map +1 -1
- package/src/in-the-dark/Entity.js +1 -1
- package/src/in-the-dark/Entity.js.map +1 -1
- package/src/in-the-dark/Kernel.d.ts.map +1 -1
- package/src/in-the-dark/Kernel.js +22 -2
- package/src/in-the-dark/Kernel.js.map +1 -1
- package/src/in-the-dark/events.d.ts +4 -4
- package/src/in-the-dark/events.d.ts.map +1 -1
- package/src/in-the-dark/events.js +4 -4
- package/src/in-the-dark/events.js.map +1 -1
- package/src/types.d.ts +9 -2
- package/src/types.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,17 +5,55 @@ All notable changes to [@spearwolf/shadow-objects](https://github.com/spearwolf/
|
|
|
5
5
|
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## [0.29.0] - 2026-01-21
|
|
9
|
+
|
|
10
|
+
- **New Feature:** Added `forward-custom-events` attribute to `<shae-ent>` custom element.
|
|
11
|
+
- Allows forwarding events emitted by the internal `ViewComponent` (Shadow Object) as standard DOM `CustomEvent`s on the `<shae-ent>` element.
|
|
12
|
+
- Supports forwarding all events or filtering specific event types (e.g., `forward-custom-events="my-event,another-event"`).
|
|
13
|
+
- Event payload is passed as `detail` property of the `CustomEvent`.
|
|
14
|
+
|
|
15
|
+
## [0.28.0] - 2026-01-20
|
|
16
|
+
|
|
17
|
+
- **API Update:** `on()` and `once()` in `ShadowObjectCreationAPI` now support an implicit event source.
|
|
18
|
+
- If the first argument is a `string`, `symbol`, or `[]`, the `entity` is automatically used as the event source.
|
|
19
|
+
- Example: `on('eventName', callback)` is equivalent to `on(entity, 'eventName', callback)`.
|
|
20
|
+
- This simplifies the common case of listening to entity events.
|
|
21
|
+
- **API Update:** introduce `onViewEvent()` in `ShadowObjectCreationAPI`
|
|
22
|
+
- Simplifies listening to view events dispatched to the entity.
|
|
23
|
+
- Example:
|
|
24
|
+
```typescript
|
|
25
|
+
onViewEvent((type, data) => {
|
|
26
|
+
if (type === 'my-event') {
|
|
27
|
+
// handle event
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
- **Refactor** the `EntityApi` type
|
|
32
|
+
- **Refactor** the `useProperties` supports type maps now
|
|
33
|
+
- **Documentation:** Comprehensive update to the documentation structure and content.
|
|
9
34
|
|
|
10
|
-
|
|
35
|
+
### ⚠️ Breaking Changes
|
|
36
|
+
|
|
37
|
+
- The _entity_ events `onCreate`, `onDestroy`, `onParentChanged` and `onViewEvent` changed to _symbols_.
|
|
38
|
+
- Update your event listeners accordingly:
|
|
39
|
+
- import the event symbols from the package:
|
|
40
|
+
```typescript
|
|
41
|
+
import {onCreate, onDestroy, onParentChanged, onViewEvent} from '@spearwolf/shadow-objects/shadow-objects.js';
|
|
42
|
+
```
|
|
43
|
+
- _Functional Shadow-Objects:_
|
|
44
|
+
- **Before:** `on(entity, 'onCreate', ...)`
|
|
45
|
+
- **After:** `on(onCreate, ...)`
|
|
46
|
+
- _Class-based Shadow-Objects:_
|
|
47
|
+
- **Before:** `onCreate(entity)`
|
|
48
|
+
- **After:** `[onCreate](entity)`
|
|
11
49
|
|
|
12
50
|
## [0.27.0] - 2026-01-19
|
|
13
51
|
|
|
14
52
|
### ⚠️ Breaking Changes
|
|
15
53
|
|
|
16
54
|
- **API Update:** `dispatchMessageToView` has been moved from the `entity` instance to the `ShadowObjectCreationAPI`.
|
|
17
|
-
|
|
18
|
-
|
|
55
|
+
- **Before:** `entity.dispatchMessageToView(...)`
|
|
56
|
+
- **After:** `dispatchMessageToView(...)` (available as an argument in the constructor/factory function)
|
|
19
57
|
- **Type Definitions:** Removed `dispatchMessageToView` from `EntityApi` interface.
|
|
20
58
|
|
|
21
59
|
## [0.26.4] - 2026-01-15
|
package/README.md
CHANGED
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
# Shadow Objects Framework
|
|
1
|
+
# Shadow Objects Framework
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package contains the core library for the **Shadow Objects Framework**.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
> 🚀 This is a highly experimental framework that is slowly maturing. Use at your own risk. 🔥
|
|
5
|
+
**👉 [Read the Documentation](./docs/README.md)**
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Contents
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
* [**Concepts**](./docs/01-concepts/): Understand the mental model, architecture, and lifecycle.
|
|
10
|
+
* [**Guides**](./docs/02-guides/): Step-by-step instructions.
|
|
11
|
+
* [**API Reference**](./docs/03-api/): Detailed API docs.
|
|
12
|
+
* [**Best Practices & Patterns**](./docs/04-patterns/): Idiomatic usage and design patterns.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
* [**Guides**](./docs/02-guides/): Step-by-step instructions for getting started and building with Shadow Objects.
|
|
14
|
-
* [**API Reference**](./docs/03-api/): Detailed API documentation for Shadow Objects and the Registry.
|
|
15
|
-
|
|
16
|
-
## Overview
|
|
17
|
-
|
|
18
|
-
### What is it?
|
|
19
|
-
|
|
20
|
-
Shadow Objects creates a strict separation between the **View** (what the user sees) and the **Logic** (how the application behaves).
|
|
21
|
-
|
|
22
|
-
* **View (Browser Window):** Handles rendering and user input. It remains lightweight and "dumb".
|
|
23
|
-
* **Logic (Web Worker):** Manages state, side effects, and business rules. It is organized as "Shadow Objects" that are attached to abstract "Entities".
|
|
24
|
-
|
|
25
|
-
### Installation
|
|
26
|
-
|
|
27
|
-
The framework is available as an npm package:
|
|
14
|
+
## Installation
|
|
28
15
|
|
|
29
16
|
```bash
|
|
30
17
|
npm install @spearwolf/shadow-objects
|
|
31
18
|
```
|
|
32
|
-
|
|
33
|
-
### Integration
|
|
34
|
-
|
|
35
|
-
To integrate Shadow Objects into your project, you connect the View to your Logic using tokens.
|
|
36
|
-
|
|
37
|
-
1. **Define Logic**: Write your Shadow Objects (logic units) using the functional API.
|
|
38
|
-
2. **Register**: Map your Shadow Objects to **Tokens** in a module definition.
|
|
39
|
-
3. **Connect View**: Use the provided Web Components to load your module and build your UI hierarchy.
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
<!-- 1. Initialize the Environment & Load Logic -->
|
|
43
|
-
<shae-worker src="./my-logic-module.js"></shae-worker>
|
|
44
|
-
|
|
45
|
-
<!-- 2. Create Entities in the View -->
|
|
46
|
-
<shae-ent token="my-feature">
|
|
47
|
-
<!-- The framework automatically instantiates the Shadow Object mapped to "my-feature" in the worker -->
|
|
48
|
-
</shae-ent>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
For detailed setup instructions, please refer to the [Getting Started](./docs/02-guides/01-getting-started.md) guide.
|