@blorkfield/overlay-core 0.8.8 → 0.8.9
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 +24 -7
- package/dist/index.cjs +20 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,13 +22,24 @@ pnpm add @blorkfield/overlay-core
|
|
|
22
22
|
|
|
23
23
|
### Tag Based Behavior
|
|
24
24
|
|
|
25
|
-
Objects don't have fixed types. Instead, their behavior is determined by string tags:
|
|
25
|
+
Objects don't have fixed types. Instead, their behavior is determined by string tags. Import the tag constants to avoid magic strings:
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
```typescript
|
|
28
|
+
import { TAGS, TAG_FALLING, TAG_GRABABLE, TAG_FOLLOW_WINDOW } from '@blorkfield/overlay-core';
|
|
29
|
+
|
|
30
|
+
// Use individual constants
|
|
31
|
+
scene.spawnObject({ tags: [TAG_FALLING, TAG_GRABABLE], ... });
|
|
32
|
+
|
|
33
|
+
// Or destructure from TAGS object
|
|
34
|
+
const { FALLING, GRABABLE } = TAGS;
|
|
35
|
+
scene.spawnObject({ tags: [FALLING, GRABABLE], ... });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Constant | Value | Behavior |
|
|
39
|
+
|----------|-------|----------|
|
|
40
|
+
| `TAG_FALLING` / `TAGS.FALLING` | `'falling'` | Object is dynamic and affected by gravity |
|
|
41
|
+
| `TAG_FOLLOW_WINDOW` / `TAGS.FOLLOW_WINDOW` | `'follow_window'` | Object follows mouse position when grounded |
|
|
42
|
+
| `TAG_GRABABLE` / `TAGS.GRABABLE` | `'grabable'` | Object can be grabbed and moved with mouse |
|
|
32
43
|
|
|
33
44
|
Without the `falling` tag, objects are static and won't move.
|
|
34
45
|
|
|
@@ -712,6 +723,12 @@ import type {
|
|
|
712
723
|
UpdateCallbackData,
|
|
713
724
|
|
|
714
725
|
// Logging
|
|
715
|
-
LogLevel
|
|
726
|
+
LogLevel,
|
|
727
|
+
|
|
728
|
+
// Tags
|
|
729
|
+
Tag
|
|
716
730
|
} from '@blorkfield/overlay-core';
|
|
731
|
+
|
|
732
|
+
// Tag constants (values, not types)
|
|
733
|
+
import { TAGS, TAG_FALLING, TAG_GRABABLE, TAG_FOLLOW_WINDOW } from '@blorkfield/overlay-core';
|
|
717
734
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,10 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BackgroundManager: () => BackgroundManager,
|
|
34
34
|
OverlayScene: () => OverlayScene,
|
|
35
|
+
TAGS: () => TAGS,
|
|
36
|
+
TAG_FALLING: () => TAG_FALLING,
|
|
37
|
+
TAG_FOLLOW_WINDOW: () => TAG_FOLLOW_WINDOW,
|
|
38
|
+
TAG_GRABABLE: () => TAG_GRABABLE,
|
|
35
39
|
clearFontCache: () => clearFontCache,
|
|
36
40
|
getGlyphData: () => getGlyphData,
|
|
37
41
|
getKerning: () => getKerning,
|
|
@@ -1547,7 +1551,7 @@ var OverlayScene = class {
|
|
|
1547
1551
|
const isDragging = this.grabbedObjectId === entry.id;
|
|
1548
1552
|
if (!isDragging) {
|
|
1549
1553
|
for (const tag of entry.tags) {
|
|
1550
|
-
const key = tag === "
|
|
1554
|
+
const key = tag === "follow_window" ? "mouse" : tag.startsWith("follow-") ? tag.slice(7) : null;
|
|
1551
1555
|
if (key) {
|
|
1552
1556
|
const target = this.followTargets.get(key);
|
|
1553
1557
|
if (target) {
|
|
@@ -2082,7 +2086,7 @@ var OverlayScene = class {
|
|
|
2082
2086
|
* Spawn an object synchronously.
|
|
2083
2087
|
* Object behavior is determined by tags:
|
|
2084
2088
|
* - 'falling': Object is dynamic (affected by gravity)
|
|
2085
|
-
* - '
|
|
2089
|
+
* - 'follow_window': Object follows mouse when grounded (walks toward mouse)
|
|
2086
2090
|
* - 'grabable': Object can be grabbed and moved with mouse
|
|
2087
2091
|
* Without 'falling' tag, object is static.
|
|
2088
2092
|
*/
|
|
@@ -3394,10 +3398,24 @@ var OverlayScene = class {
|
|
|
3394
3398
|
this.updateCallbacks.forEach((cb) => cb(data));
|
|
3395
3399
|
}
|
|
3396
3400
|
};
|
|
3401
|
+
|
|
3402
|
+
// src/tags.ts
|
|
3403
|
+
var TAG_FALLING = "falling";
|
|
3404
|
+
var TAG_FOLLOW_WINDOW = "follow_window";
|
|
3405
|
+
var TAG_GRABABLE = "grabable";
|
|
3406
|
+
var TAGS = {
|
|
3407
|
+
FALLING: TAG_FALLING,
|
|
3408
|
+
FOLLOW_WINDOW: TAG_FOLLOW_WINDOW,
|
|
3409
|
+
GRABABLE: TAG_GRABABLE
|
|
3410
|
+
};
|
|
3397
3411
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3398
3412
|
0 && (module.exports = {
|
|
3399
3413
|
BackgroundManager,
|
|
3400
3414
|
OverlayScene,
|
|
3415
|
+
TAGS,
|
|
3416
|
+
TAG_FALLING,
|
|
3417
|
+
TAG_FOLLOW_WINDOW,
|
|
3418
|
+
TAG_GRABABLE,
|
|
3401
3419
|
clearFontCache,
|
|
3402
3420
|
getGlyphData,
|
|
3403
3421
|
getKerning,
|