@state-of-geneva/bim-ecs-devtools-plugin 0.0.0-stage → 0.0.11
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 +201 -0
- package/README.md +52 -3
- package/dist/build-graph.d.ts +11 -0
- package/dist/devtools-bridge.d.ts +33 -0
- package/dist/devtools-hook.d.ts +11 -0
- package/dist/devtools-plugin.d.ts +18 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +423 -0
- package/dist/index.es.js.map +1 -0
- package/dist/inspect-entities.d.ts +28 -0
- package/dist/protocol.d.ts +206 -0
- package/dist/serialize-value.d.ts +18 -0
- package/package.json +43 -3
- package/src/build-graph.spec.ts +169 -0
- package/src/build-graph.ts +123 -0
- package/src/devtools-bridge.ts +104 -0
- package/src/devtools-hook.ts +58 -0
- package/src/devtools-plugin.spec.ts +155 -0
- package/src/devtools-plugin.ts +43 -0
- package/src/index.ts +4 -0
- package/src/inspect-entities.spec.ts +161 -0
- package/src/inspect-entities.ts +137 -0
- package/src/protocol.ts +225 -0
- package/src/serialize-value.spec.ts +139 -0
- package/src/serialize-value.ts +145 -0
- package/tsconfig-build.json +4 -0
- package/tsconfig.json +24 -0
- package/tsconfig.vitest.json +9 -0
- package/vite.config.ts +20 -0
- package/vitest.config.ts +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @state-of-geneva/bim-ecs-devtools-plugin
|
|
2
|
+
|
|
3
|
+
[bim-ecs](https://www.npmjs.com/package/@state-of-geneva/bim-ecs) plugin exposing a world to developer tools: the systems graph, the components, the entities and the resources.
|
|
4
|
+
|
|
5
|
+
It is **tool agnostic**: it publishes plain JSON through a global hook, it knows nothing about how the data is displayed. The BIM ECS DevTools extension (`packages/ecs-chrome-extension` of the repository) is one consumer; an in-page overlay or a test could be others.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { EcsWorld } from '@state-of-geneva/bim-ecs';
|
|
11
|
+
import { devtoolsPlugin } from '@state-of-geneva/bim-ecs-devtools-plugin';
|
|
12
|
+
|
|
13
|
+
const world = new EcsWorld();
|
|
14
|
+
// ...systems, plugins...
|
|
15
|
+
|
|
16
|
+
world.use(devtoolsPlugin({ name: 'My game' }));
|
|
17
|
+
world.run();
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Install it for development builds only:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
if (import.meta.env.DEV) world.use(devtoolsPlugin());
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Cost
|
|
27
|
+
|
|
28
|
+
Nothing is computed until a tool asks. While nobody does, the only runtime cost is a counter bumped when a system is registered or disposed, and when the world starts or stops. Systems processing, entities and queries are never instrumented.
|
|
29
|
+
|
|
30
|
+
Requests are answered on demand, with a bounded cost:
|
|
31
|
+
|
|
32
|
+
| Request | Cost |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `info` | O(archetypes) |
|
|
35
|
+
| `systems` | O(systems + schedulers) |
|
|
36
|
+
| `components` | O(archetypes) |
|
|
37
|
+
| `entities` | O(archetypes + page size) |
|
|
38
|
+
| `entity`, `resource` | bounded by the serializer limits (depth, entries, nodes) |
|
|
39
|
+
|
|
40
|
+
## The hook
|
|
41
|
+
|
|
42
|
+
The plugin registers the worlds on `globalThis.__BIM_ECS_DEVTOOLS__`:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
hook.protocol; // version of the contract
|
|
46
|
+
hook.worlds(); // [{ id, name }]
|
|
47
|
+
hook.call(worldId, 'systems'); // { ok: true, value } | { ok: false, error }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Every value is JSON-safe: results can be read from another context (e.g. `chrome.devtools.inspectedWindow.eval`). The contract is documented by the types of [`src/protocol.ts`](./src/protocol.ts), which are exported by the package.
|
|
51
|
+
|
|
52
|
+
`world.use(devtoolsPlugin())` returns the bridge answering to tools, which exposes the same methods directly (useful for tests and custom transports).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SystemDescriptor } from '@state-of-geneva/bim-ecs';
|
|
2
|
+
import { SystemsGraph } from './protocol';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the systems graph from the systems descriptors.
|
|
5
|
+
*
|
|
6
|
+
* - Events, commands, components and queries are shared nodes, so the graph shows which systems react to the same thing
|
|
7
|
+
* - Modifiers (`when`, `debounce`...) are private to the system they belong to
|
|
8
|
+
* - The result only depends on the descriptors: registration order does not matter
|
|
9
|
+
* @param systems The systems descriptors
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildSystemsGraph(systems: readonly SystemDescriptor[]): SystemsGraph;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EcsWorld } from '@state-of-geneva/bim-ecs';
|
|
2
|
+
import { ComponentsSnapshot, DevtoolsApi, EntitiesPage, EntitiesQuery, EntityDetail, ResourceDetail, ResourceInfo, SystemsSnapshot, WorldInfo, WorldState } from './protocol';
|
|
3
|
+
/**
|
|
4
|
+
* Answers the questions of a devtools consumer about a world.
|
|
5
|
+
*
|
|
6
|
+
* Everything is computed on demand: while nobody asks, the only runtime cost is a revision counter bumped on the few
|
|
7
|
+
* events altering the systems structure or state. Systems processing, entities and queries are never instrumented.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DevtoolsBridge implements DevtoolsApi, Disposable {
|
|
10
|
+
#private;
|
|
11
|
+
private readonly world;
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
constructor(world: EcsWorld, id: string, name: string);
|
|
15
|
+
/** Identifies the world */
|
|
16
|
+
get worldInfo(): WorldInfo;
|
|
17
|
+
/** @inheritdoc */
|
|
18
|
+
info(): WorldState;
|
|
19
|
+
/** @inheritdoc */
|
|
20
|
+
systems(): SystemsSnapshot;
|
|
21
|
+
/** @inheritdoc */
|
|
22
|
+
components(): ComponentsSnapshot;
|
|
23
|
+
/** @inheritdoc */
|
|
24
|
+
entities(query?: EntitiesQuery): EntitiesPage;
|
|
25
|
+
/** @inheritdoc */
|
|
26
|
+
entity(id: number): EntityDetail | null;
|
|
27
|
+
/** @inheritdoc */
|
|
28
|
+
resources(): ResourceInfo[];
|
|
29
|
+
/** @inheritdoc */
|
|
30
|
+
resource(key: string): ResourceDetail | null;
|
|
31
|
+
/** @inheritdoc */
|
|
32
|
+
[Symbol.dispose](): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DevtoolsHook } from './protocol';
|
|
2
|
+
import { DevtoolsBridge } from './devtools-bridge';
|
|
3
|
+
/** The hook, with the members only plugin instances are expected to use */
|
|
4
|
+
export interface DevtoolsHostHook extends DevtoolsHook {
|
|
5
|
+
/** Registers a bridge, returns the function unregistering it */
|
|
6
|
+
attach(bridge: DevtoolsBridge): () => void;
|
|
7
|
+
/** Provides the next world number: a hook shared by several plugin copies must keep identifiers unique */
|
|
8
|
+
nextWorldNumber(): number;
|
|
9
|
+
}
|
|
10
|
+
/** Provides the hook of the page, creating it when it does not exist yet */
|
|
11
|
+
export declare function getOrCreateHook(): DevtoolsHostHook;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EcsWorld } from '@state-of-geneva/bim-ecs';
|
|
2
|
+
import { DevtoolsBridge } from './devtools-bridge';
|
|
3
|
+
export interface DevtoolsPluginOptions {
|
|
4
|
+
/** The name displayed by devtools to identify the world (default: `World <n>`) */
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Exposes the systems, components, entities and resources of the world to devtools (e.g. the browser extension),
|
|
9
|
+
* through the `__BIM_ECS_DEVTOOLS__` global. Nothing is computed until devtools ask for it.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* if (import.meta.env.DEV) world.use(devtoolsPlugin({ name: 'Game' }));
|
|
13
|
+
*
|
|
14
|
+
* @param options The plugin options
|
|
15
|
+
* @returns The plugin, which returns the bridge answering to devtools when applied (useful for tests and custom
|
|
16
|
+
* transports)
|
|
17
|
+
*/
|
|
18
|
+
export declare const devtoolsPlugin: (options?: DevtoolsPluginOptions) => (world: EcsWorld) => DevtoolsBridge;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@state-of-geneva/bim-ecs");var t=new Set([`startup`,`frame`,`component-added`,`component-removed`,`component-value-changed`,`entity-spawned`,`entity-removed`]);function n(e){let n=new Map,i=new Map,a=e=>`system:${e}`,o=e=>(n.has(e.id)||n.set(e.id,e),e.id),s=(e,t,n)=>{let r=`${e}>${t}:${n}`;i.has(r)||i.set(r,{id:r,from:e,to:t,kind:n})},c=e=>o({id:a(e),kind:`system`,label:`#${e}`,detail:`not registered`}),l=(e,n,i)=>{switch(e.kind){case`on`:case`at-command`:{let t=e.kind===`on`?`event`:`command`;for(let r of e.labels??[])s(o({id:`${t}:${r}`,kind:t,label:r}),n,`schedule`);return}case`after`:{let t=(e.systems??[]).map(c);if(t.length===1)s(t[0],n,`after`);else{let r=o({id:i,kind:`after`,label:String(e.params?.combination??`or`)});for(let e of t)s(e,r,`after`);s(r,n,`schedule`)}return}default:{let a=e.without?.length?`without ${e.without.join(`, `)}`:void 0,c=r(e),u=t.has(e.kind)?`${e.kind}:${c}${a?`|${a}`:``}`:i,d=o({id:u,kind:e.kind,label:c,...a&&{detail:a}});s(d,n,`schedule`),e.children?.forEach((e,t)=>l(e,d,`${i}/${t}`))}}};for(let t of e)o({id:a(t.id),kind:`system`,label:t.name,system:{id:t.id,running:t.running,disposed:t.disposed}});for(let t of e){let e=a(t.id);l(t.scheduler,e,`${e}/scheduler`),t.then?.publish&&s(e,o({id:`event:${t.then.publish}`,kind:`event`,label:t.then.publish}),`publish`),t.then?.trigger&&s(e,o({id:`command:${t.then.trigger}`,kind:`command`,label:t.then.trigger}),`trigger`)}return{nodes:[...n.values()],edges:[...i.values()]}}function r({kind:e,labels:t,params:n}){if(t?.length)return t.join(`, `);switch(e){case`timer`:case`debounce`:return`${n?.delay??`?`}ms`;case`when`:return String(n?.predicate??e);default:return e}}var i={maxDepth:4,maxEntries:50,maxStringLength:300,maxNodes:1e3};function a(e,t){let n={...i,...t};return o(e,0,new Set,{remaining:n.maxNodes},n)}function o(e,t,n,r,i){switch(typeof e){case`string`:return e.length>i.maxStringLength?`${e.slice(0,i.maxStringLength)}…`:e;case`number`:return Number.isFinite(e)?e:{$:`number`,v:Number.isNaN(e)?`NaN`:e>0?`Infinity`:`-Infinity`};case`boolean`:return e;case`undefined`:return{$:`undefined`};case`bigint`:return{$:`bigint`,v:e.toString()};case`symbol`:return{$:`symbol`,v:e.toString()};case`function`:return{$:`function`,name:e.name||`(anonymous)`}}if(e===null)return null;let a=e;if(n.has(a))return{$:`circular`};let d=s(a);if(--r.remaining<0)return{$:`truncated`,cls:d};if(a instanceof Date)return{$:`date`,v:Number.isNaN(a.getTime())?`Invalid Date`:a.toISOString()};let f=u(a);if(f)return{$:`opaque`,cls:d,...f.desc!==void 0&&{desc:f.desc}};let p=Array.isArray(a)||a instanceof Map||a instanceof Set;if(t>=i.maxDepth)return{$:`truncated`,cls:d,...p&&{size:c(a)}};n.add(a);try{let e=e=>o(e,t+1,n,r,i);if(Array.isArray(a))return{$:`array`,size:a.length,items:a.slice(0,i.maxEntries).map(e)};if(a instanceof Set)return{$:`set`,size:a.size,items:l(a.values(),i.maxEntries).map(e)};if(a instanceof Map)return{$:`map`,size:a.size,entries:l(a.entries(),i.maxEntries).map(([t,n])=>[e(t),e(n)])};let s=Object.keys(a);return{$:`object`,cls:d,size:s.length,entries:s.slice(0,i.maxEntries).map(t=>{let n=Object.getOwnPropertyDescriptor(a,t);return[t,n&&`value`in n?e(n.value):{$:`opaque`,cls:`Getter`}]})}}catch(e){return{$:`opaque`,cls:d,desc:`unreadable: ${String(e)}`}}finally{n.delete(a)}}function s(e){try{return Object.getPrototypeOf(e)?.constructor?.name||`Object`}catch{return`Object`}}function c(e){return Array.isArray(e)?e.length:e.size}function l(e,t){let n=[];for(let r=e.next();!r.done&&n.length<t;r=e.next())n.push(r.value);return n}function u(e){if(typeof Node<`u`&&e instanceof Node)return{desc:e.nodeName};if(typeof Window<`u`&&e instanceof Window)return{};if(e instanceof Error)return{desc:e.message};if(e instanceof RegExp)return{desc:String(e)};if(e instanceof Promise||e instanceof WeakMap||e instanceof WeakSet||typeof WeakRef<`u`&&e instanceof WeakRef)return{};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{desc:`${e.byteLength} bytes`}}var d=100,f=new WeakMap,p=0;function m(e){let t=f.get(e);return t===void 0&&f.set(e,t=`c${p++}`),t}function h(t){return t.prototype instanceof e.EcsMutableComponent?`mutable`:t.prototype instanceof e.EcsIndexedComponent?`indexed`:`component`}function g(e){let t=new Map,n=[],r=0;for(let i of e.entities.archetypes()){let e=i.entities.size;r+=e;for(let n of i.components)t.set(n,(t.get(n)??0)+e);let a=i.components.map(m).sort();n.push({key:a.join(`+`),components:a,entities:e})}let i=[...t].map(([e,t])=>({key:m(e),name:e.name,kind:h(e),entities:t}));return i.sort((e,t)=>t.entities-e.entities||e.name.localeCompare(t.name)),n.sort((e,t)=>t.entities-e.entities||e.key.localeCompare(t.key)),{entities:r,types:i,archetypes:n}}function _(e,t={}){let{with:n=[],without:r=[],limit:i=d}=t,a=[],o=Math.max(0,t.offset??0),s=0;for(let t of e.entities.archetypes()){let e=t.components.map(m);if(!n.every(t=>e.includes(t))||r.some(t=>e.includes(t)))continue;let c=t.entities.size;if(s+=c,a.length>=i)continue;if(o>=c){o-=c;continue}let l=0;for(let n of t.entities)if(!(l++<o)&&(a.push({id:n,components:e}),a.length>=i))break;o=0}return{total:s,entities:a}}function v(e,t){let n=e.entities.pool.componentsByEntity.get(t);return n?{id:t,components:[...n].map(e=>{let t=e.constructor,n=Object.keys(e).filter(e=>e!==`_value`);return{key:m(t),name:t.name,kind:h(t),value:a(e.value),...n.length&&{fields:a(Object.fromEntries(n.map(t=>[t,e[t]])))}}})}:null}var y=class{world;id;name;#e=0;#t=[];constructor(t,n,r){this.world=t,this.id=n,this.name=r;let i=()=>void this.#e++,a=e=>this.#t.push(t.bus.subscribe(e,i));a(e.ECS_SYSTEM_REGISTERED_EVENT),a(e.ECS_SYSTEM_DISPOSED_EVENT),a(e.ECS_WORLD_RUNNING_EVENT),a(e.ECS_WORLD_STOPPING_EVENT)}get worldInfo(){return{id:this.id,name:this.name}}info(){let e=0;for(let t of this.world.entities.archetypes())e+=t.entities.size;return{...this.worldInfo,running:this.world.running,revision:this.#e,systems:this.world.systems.size,entities:e}}systems(){return{revision:this.#e,graph:n(this.world.systems.describe())}}components(){return g(this.world)}entities(e){return _(this.world,e)}entity(e){return v(this.world,e)}resources(){return this.world.container.list().map(({name:e},t)=>({key:String(t),name:e}))}resource(e){let t=this.world.container.list()[Number(e)];return t?{key:e,name:t.name,value:a(t.resource)}:null}[Symbol.dispose](){this.#t.splice(0).forEach(e=>e())}},b=1,x=`__BIM_ECS_DEVTOOLS__`,S=[`info`,`systems`,`components`,`entities`,`entity`,`resources`,`resource`];function C(){let e=globalThis,t=e[x];if(t&&typeof t.attach==`function`)return t;let n=new Map,r=0,i={protocol:1,worlds(){return[...n.values()].map(e=>e.worldInfo)},call(e,t,r=[]){let i=n.get(e);if(!i)return{ok:!1,error:`Unknown world "${e}"`};if(!S.includes(t))return{ok:!1,error:`Unknown method "${t}"`};try{return{ok:!0,value:i[t](...r)}}catch(e){return{ok:!1,error:String(e)}}},attach(e){return n.set(e.id,e),()=>void n.delete(e.id)},nextWorldNumber:()=>++r};return e[x]=i,i}var w=new WeakMap,T=(t={})=>n=>{let r=w.get(n);if(r)return r;let i=C(),a=i.nextWorldNumber(),o=new y(n,`world-${a}`,t.name??`World ${a}`);w.set(n,o);let s=i.attach(o);return n.bus.subscribe(e.ECS_WORLD_DISPOSING_EVENT,()=>{s(),o[Symbol.dispose](),w.delete(n)}),o};exports.DEVTOOLS_API_METHODS=S,exports.DEVTOOLS_HOOK_KEY=x,exports.DEVTOOLS_PROTOCOL_VERSION=b,exports.devtoolsPlugin=T,exports.serializeValue=a;
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","names":[],"sources":["../src/build-graph.ts","../src/serialize-value.ts","../src/inspect-entities.ts","../src/devtools-bridge.ts","../src/protocol.ts","../src/devtools-hook.ts","../src/devtools-plugin.ts"],"sourcesContent":["import type { SchedulerDescriptor, SystemDescriptor } from '@state-of-geneva/bim-ecs';\r\nimport type { GraphEdge, GraphEdgeKind, GraphNode, SystemsGraph } from './protocol';\r\n\r\n/** Kinds of schedulers whose nodes are shared: every system bound to the same thing is connected to the same node */\r\nconst SHARED_KINDS = new Set([\r\n 'startup',\r\n 'frame',\r\n 'component-added',\r\n 'component-removed',\r\n 'component-value-changed',\r\n 'entity-spawned',\r\n 'entity-removed',\r\n]);\r\n\r\n/**\r\n * Builds the systems graph from the systems descriptors.\r\n *\r\n * - Events, commands, components and queries are shared nodes, so the graph shows which systems react to the same thing\r\n * - Modifiers (`when`, `debounce`...) are private to the system they belong to\r\n * - The result only depends on the descriptors: registration order does not matter\r\n * @param systems The systems descriptors\r\n */\r\nexport function buildSystemsGraph(systems: readonly SystemDescriptor[]): SystemsGraph {\r\n const nodes = new Map<string, GraphNode>();\r\n const edges = new Map<string, GraphEdge>();\r\n\r\n const systemNodeId = (id: number) => `system:${id}`;\r\n\r\n const addNode = (node: GraphNode) => {\r\n if (!nodes.has(node.id)) nodes.set(node.id, node);\r\n return node.id;\r\n };\r\n\r\n const link = (from: string, to: string, kind: GraphEdgeKind) => {\r\n const id = `${from}>${to}:${kind}`;\r\n if (!edges.has(id)) edges.set(id, { id, from, to, kind });\r\n };\r\n\r\n /** Provides the node of a system, a placeholder is created when the system is not registered */\r\n const systemNode = (id: number) =>\r\n addNode({ id: systemNodeId(id), kind: 'system', label: `#${id}`, detail: 'not registered' });\r\n\r\n const addScheduler = (descriptor: SchedulerDescriptor, parent: string, path: string) => {\r\n switch (descriptor.kind) {\r\n case 'on':\r\n case 'at-command': {\r\n // One node per bound event / command\r\n const kind = descriptor.kind === 'on' ? 'event' : 'command';\r\n for (const label of descriptor.labels ?? []) {\r\n link(addNode({ id: `${kind}:${label}`, kind, label }), parent, 'schedule');\r\n }\r\n return;\r\n }\r\n\r\n case 'after': {\r\n const upstream = (descriptor.systems ?? []).map(systemNode);\r\n if (upstream.length === 1) {\r\n link(upstream[0], parent, 'after');\r\n } else {\r\n const junction = addNode({ id: path, kind: 'after', label: String(descriptor.params?.combination ?? 'or') });\r\n for (const source of upstream) link(source, junction, 'after');\r\n link(junction, parent, 'schedule');\r\n }\r\n return;\r\n }\r\n\r\n default: {\r\n const detail = descriptor.without?.length ? `without ${descriptor.without.join(', ')}` : undefined;\r\n const label = labelOf(descriptor);\r\n const id = SHARED_KINDS.has(descriptor.kind)\r\n ? `${descriptor.kind}:${label}${detail ? `|${detail}` : ''}`\r\n : path;\r\n\r\n const node = addNode({ id, kind: descriptor.kind, label, ...(detail && { detail }) });\r\n link(node, parent, 'schedule');\r\n descriptor.children?.forEach((child, index) => addScheduler(child, node, `${path}/${index}`));\r\n }\r\n }\r\n };\r\n\r\n // System nodes come first: placeholders are only created for missing upstream systems\r\n for (const system of systems) {\r\n addNode({\r\n id: systemNodeId(system.id),\r\n kind: 'system',\r\n label: system.name,\r\n system: { id: system.id, running: system.running, disposed: system.disposed },\r\n });\r\n }\r\n\r\n for (const system of systems) {\r\n const node = systemNodeId(system.id);\r\n addScheduler(system.scheduler, node, `${node}/scheduler`);\r\n\r\n if (system.then?.publish) {\r\n link(node, addNode({ id: `event:${system.then.publish}`, kind: 'event', label: system.then.publish }), 'publish');\r\n }\r\n if (system.then?.trigger) {\r\n link(\r\n node,\r\n addNode({ id: `command:${system.then.trigger}`, kind: 'command', label: system.then.trigger }),\r\n 'trigger',\r\n );\r\n }\r\n }\r\n\r\n return { nodes: [...nodes.values()], edges: [...edges.values()] };\r\n}\r\n\r\n/** Provides the name of the scheduler thing */\r\nfunction labelOf({ kind, labels, params }: SchedulerDescriptor) {\r\n if (labels?.length) return labels.join(', ');\r\n\r\n switch (kind) {\r\n case 'timer':\r\n case 'debounce':\r\n return `${params?.delay ?? '?'}ms`;\r\n case 'when':\r\n return String(params?.predicate ?? kind);\r\n default:\r\n return kind;\r\n }\r\n}\r\n","import type { SerializedValue } from './protocol';\r\n\r\nexport interface SerializeOptions {\r\n /** Maximum nesting depth (default: 4) */\r\n maxDepth?: number;\r\n /** Maximum number of entries/items kept per collection or object (default: 50) */\r\n maxEntries?: number;\r\n /** Maximum length of a string (default: 300) */\r\n maxStringLength?: number;\r\n /** Maximum number of nodes of the whole result (default: 1000), bounds the cost whatever the shape of the data is */\r\n maxNodes?: number;\r\n}\r\n\r\ntype Limits = Required<SerializeOptions>;\r\n\r\nconst DEFAULT_LIMITS: Limits = { maxDepth: 4, maxEntries: 50, maxStringLength: 300, maxNodes: 1000 };\r\n\r\n/**\r\n * Converts any value to a JSON-safe and bounded representation: it is safe to call on arbitrary application data\r\n * (cycles, DOM nodes, huge collections, throwing getters...) and its cost is capped by `maxNodes`.\r\n * @param value The value to serialize\r\n * @param options The limits\r\n */\r\nexport function serializeValue(value: unknown, options?: SerializeOptions): SerializedValue {\r\n const limits = { ...DEFAULT_LIMITS, ...options };\r\n return serialize(value, 0, new Set(), { remaining: limits.maxNodes }, limits);\r\n}\r\n\r\nfunction serialize(\r\n value: unknown,\r\n depth: number,\r\n ancestors: Set<object>,\r\n budget: { remaining: number },\r\n limits: Limits,\r\n): SerializedValue {\r\n switch (typeof value) {\r\n case 'string':\r\n return value.length > limits.maxStringLength ? `${value.slice(0, limits.maxStringLength)}…` : value;\r\n case 'number':\r\n if (Number.isFinite(value)) return value;\r\n return { $: 'number', v: Number.isNaN(value) ? 'NaN' : value > 0 ? 'Infinity' : '-Infinity' };\r\n case 'boolean':\r\n return value;\r\n case 'undefined':\r\n return { $: 'undefined' };\r\n case 'bigint':\r\n return { $: 'bigint', v: value.toString() };\r\n case 'symbol':\r\n return { $: 'symbol', v: value.toString() };\r\n case 'function':\r\n return { $: 'function', name: value.name || '(anonymous)' };\r\n }\r\n\r\n if (value === null) return null;\r\n\r\n const object = value as object;\r\n if (ancestors.has(object)) return { $: 'circular' };\r\n\r\n const cls = classNameOf(object);\r\n if (--budget.remaining < 0) return { $: 'truncated', cls };\r\n\r\n if (object instanceof Date) {\r\n return { $: 'date', v: Number.isNaN(object.getTime()) ? 'Invalid Date' : object.toISOString() };\r\n }\r\n const opaque = describeOpaque(object);\r\n if (opaque) return { $: 'opaque', cls, ...(opaque.desc !== undefined && { desc: opaque.desc }) };\r\n\r\n const isCollection = Array.isArray(object) || object instanceof Map || object instanceof Set;\r\n if (depth >= limits.maxDepth) {\r\n return { $: 'truncated', cls, ...(isCollection && { size: collectionSize(object) }) };\r\n }\r\n\r\n ancestors.add(object);\r\n try {\r\n const child = (item: unknown) => serialize(item, depth + 1, ancestors, budget, limits);\r\n\r\n if (Array.isArray(object)) {\r\n return { $: 'array', size: object.length, items: object.slice(0, limits.maxEntries).map(child) };\r\n }\r\n\r\n if (object instanceof Set) {\r\n return { $: 'set', size: object.size, items: take(object.values(), limits.maxEntries).map(child) };\r\n }\r\n\r\n if (object instanceof Map) {\r\n return {\r\n $: 'map',\r\n size: object.size,\r\n entries: take(object.entries(), limits.maxEntries).map(([k, v]) => [child(k), child(v)]),\r\n };\r\n }\r\n\r\n const keys = Object.keys(object);\r\n return {\r\n $: 'object',\r\n cls,\r\n size: keys.length,\r\n entries: keys.slice(0, limits.maxEntries).map((key): [string, SerializedValue] => {\r\n // Accessors are not invoked: they could have side effects or throw\r\n const descriptor = Object.getOwnPropertyDescriptor(object, key);\r\n return [key, descriptor && 'value' in descriptor ? child(descriptor.value) : { $: 'opaque', cls: 'Getter' }];\r\n }),\r\n };\r\n } catch (error) {\r\n // Exotic objects (revoked proxies...)\r\n return { $: 'opaque', cls, desc: `unreadable: ${String(error)}` };\r\n } finally {\r\n ancestors.delete(object);\r\n }\r\n}\r\n\r\n/** Provides the constructor name of an object, `Object` when it has no prototype */\r\nfunction classNameOf(object: object) {\r\n try {\r\n return (Object.getPrototypeOf(object)?.constructor?.name as string | undefined) || 'Object';\r\n } catch {\r\n return 'Object';\r\n }\r\n}\r\n\r\nfunction collectionSize(object: object) {\r\n return Array.isArray(object) ? object.length : (object as Map<unknown, unknown> | Set<unknown>).size;\r\n}\r\n\r\n/** Takes up to `count` items of an iterator */\r\nfunction take<T>(iterator: Iterator<T>, count: number) {\r\n const items: T[] = [];\r\n for (let item = iterator.next(); !item.done && items.length < count; item = iterator.next()) items.push(item.value);\r\n return items;\r\n}\r\n\r\n/** Determines whether the object is not worth (or not safe) to inspect, and provides a short description if so */\r\nfunction describeOpaque(object: object): { desc?: string } | undefined {\r\n if (typeof Node !== 'undefined' && object instanceof Node) return { desc: object.nodeName };\r\n if (typeof Window !== 'undefined' && object instanceof Window) return {};\r\n if (object instanceof Error) return { desc: object.message };\r\n if (object instanceof RegExp) return { desc: String(object) };\r\n if (object instanceof Promise) return {};\r\n if (object instanceof WeakMap || object instanceof WeakSet) return {};\r\n if (typeof WeakRef !== 'undefined' && object instanceof WeakRef) return {};\r\n if (object instanceof ArrayBuffer) return { desc: `${object.byteLength} bytes` };\r\n if (ArrayBuffer.isView(object)) return { desc: `${object.byteLength} bytes` };\r\n\r\n return undefined;\r\n}\r\n","import { EcsIndexedComponent, EcsMutableComponent, type EcsComponent, type EcsWorld } from '@state-of-geneva/bim-ecs';\r\nimport type {\r\n ArchetypeInfo,\r\n ComponentKind,\r\n ComponentsSnapshot,\r\n ComponentTypeInfo,\r\n EntitiesPage,\r\n EntitiesQuery,\r\n EntityDetail,\r\n EntitySummary,\r\n} from './protocol';\r\nimport { serializeValue } from './serialize-value';\r\n\r\ntype ComponentType = typeof EcsComponent<any>;\r\n\r\nconst DEFAULT_PAGE_SIZE = 100;\r\n\r\n/** Component type keys: component classes are global, so are their keys */\r\nconst componentTypeKeys = new WeakMap<ComponentType, string>();\r\nlet componentTypeKeyCounter = 0;\r\n\r\n/**\r\n * Provides the stable identifier of a component type. Names are not identifiers: two classes can share the same one.\r\n * @param type The component type\r\n */\r\nexport function componentTypeKey(type: ComponentType) {\r\n let key = componentTypeKeys.get(type);\r\n if (key === undefined) componentTypeKeys.set(type, (key = `c${componentTypeKeyCounter++}`));\r\n return key;\r\n}\r\n\r\nfunction componentKindOf(type: ComponentType): ComponentKind {\r\n if (type.prototype instanceof EcsMutableComponent) return 'mutable';\r\n if (type.prototype instanceof EcsIndexedComponent) return 'indexed';\r\n return 'component';\r\n}\r\n\r\n/**\r\n * Describes the component types and the archetypes of the world.\r\n * The cost is proportional to the number of archetypes, not to the number of entities.\r\n * @param world The world\r\n */\r\nexport function inspectComponents(world: EcsWorld): ComponentsSnapshot {\r\n const countsByType = new Map<ComponentType, number>();\r\n const archetypes: ArchetypeInfo[] = [];\r\n let entities = 0;\r\n\r\n for (const archetype of world.entities.archetypes()) {\r\n const count = archetype.entities.size;\r\n entities += count;\r\n\r\n for (const type of archetype.components) countsByType.set(type, (countsByType.get(type) ?? 0) + count);\r\n\r\n const components = archetype.components.map(componentTypeKey).sort();\r\n archetypes.push({ key: components.join('+'), components, entities: count });\r\n }\r\n\r\n const types: ComponentTypeInfo[] = [...countsByType].map(([type, count]) => ({\r\n key: componentTypeKey(type),\r\n name: type.name,\r\n kind: componentKindOf(type),\r\n entities: count,\r\n }));\r\n\r\n types.sort((a, b) => b.entities - a.entities || a.name.localeCompare(b.name));\r\n archetypes.sort((a, b) => b.entities - a.entities || a.key.localeCompare(b.key));\r\n\r\n return { entities, types, archetypes };\r\n}\r\n\r\n/**\r\n * Lists the entities matching the query, page by page.\r\n * Archetypes are filtered first, so the cost does not depend on the number of entities outside the requested page.\r\n * @param world The world\r\n * @param query The filter and the page\r\n */\r\nexport function inspectEntities(world: EcsWorld, query: EntitiesQuery = {}): EntitiesPage {\r\n const { with: required = [], without: excluded = [], limit = DEFAULT_PAGE_SIZE } = query;\r\n const entities: EntitySummary[] = [];\r\n let remainingOffset = Math.max(0, query.offset ?? 0);\r\n let total = 0;\r\n\r\n for (const archetype of world.entities.archetypes()) {\r\n const components = archetype.components.map(componentTypeKey);\r\n if (!required.every((key) => components.includes(key)) || excluded.some((key) => components.includes(key)))\r\n continue;\r\n\r\n const size = archetype.entities.size;\r\n total += size;\r\n\r\n if (entities.length >= limit) continue;\r\n if (remainingOffset >= size) {\r\n remainingOffset -= size;\r\n continue;\r\n }\r\n\r\n let skipped = 0;\r\n for (const id of archetype.entities) {\r\n if (skipped++ < remainingOffset) continue;\r\n entities.push({ id, components });\r\n if (entities.length >= limit) break;\r\n }\r\n remainingOffset = 0;\r\n }\r\n\r\n return { total, entities };\r\n}\r\n\r\n/**\r\n * Details an entity: its components and their values\r\n * @param world The world\r\n * @param id The entity identifier\r\n */\r\nexport function inspectEntity(world: EcsWorld, id: number): EntityDetail | null {\r\n const components = world.entities.pool.componentsByEntity.get(id);\r\n if (!components) return null;\r\n\r\n return {\r\n id,\r\n components: [...components].map((component) => {\r\n const type = component.constructor as ComponentType;\r\n\r\n // Own fields other than the value (components can be extended with some)\r\n const extra = Object.keys(component).filter((key) => key !== '_value');\r\n\r\n return {\r\n key: componentTypeKey(type),\r\n name: type.name,\r\n kind: componentKindOf(type),\r\n value: serializeValue(component.value),\r\n ...(extra.length && {\r\n fields: serializeValue(Object.fromEntries(extra.map((key) => [key, (component as any)[key]]))),\r\n }),\r\n };\r\n }),\r\n };\r\n}\r\n","import {\r\n ECS_SYSTEM_DISPOSED_EVENT,\r\n ECS_SYSTEM_REGISTERED_EVENT,\r\n ECS_WORLD_RUNNING_EVENT,\r\n ECS_WORLD_STOPPING_EVENT,\r\n type EcsEvent,\r\n type EcsWorld,\r\n} from '@state-of-geneva/bim-ecs';\r\nimport type {\r\n ComponentsSnapshot,\r\n DevtoolsApi,\r\n EntitiesPage,\r\n EntitiesQuery,\r\n EntityDetail,\r\n ResourceDetail,\r\n ResourceInfo,\r\n SystemsSnapshot,\r\n WorldInfo,\r\n WorldState,\r\n} from './protocol';\r\nimport { buildSystemsGraph } from './build-graph';\r\nimport { inspectComponents, inspectEntities, inspectEntity } from './inspect-entities';\r\nimport { serializeValue } from './serialize-value';\r\n\r\n/**\r\n * Answers the questions of a devtools consumer about a world.\r\n *\r\n * Everything is computed on demand: while nobody asks, the only runtime cost is a revision counter bumped on the few\r\n * events altering the systems structure or state. Systems processing, entities and queries are never instrumented.\r\n */\r\nexport class DevtoolsBridge implements DevtoolsApi, Disposable {\r\n #revision = 0;\r\n readonly #unsubscribes: Array<() => void> = [];\r\n\r\n constructor(\r\n private readonly world: EcsWorld,\r\n public readonly id: string,\r\n public readonly name: string,\r\n ) {\r\n const bump = () => void this.#revision++;\r\n const watch = (event: EcsEvent<any>) => this.#unsubscribes.push(world.bus.subscribe(event, bump));\r\n\r\n watch(ECS_SYSTEM_REGISTERED_EVENT);\r\n watch(ECS_SYSTEM_DISPOSED_EVENT);\r\n watch(ECS_WORLD_RUNNING_EVENT);\r\n watch(ECS_WORLD_STOPPING_EVENT);\r\n }\r\n\r\n /** Identifies the world */\r\n public get worldInfo(): WorldInfo {\r\n return { id: this.id, name: this.name };\r\n }\r\n\r\n /** @inheritdoc */\r\n public info(): WorldState {\r\n let entities = 0;\r\n for (const archetype of this.world.entities.archetypes()) entities += archetype.entities.size;\r\n\r\n return {\r\n ...this.worldInfo,\r\n running: this.world.running,\r\n revision: this.#revision,\r\n systems: this.world.systems.size,\r\n entities,\r\n };\r\n }\r\n\r\n /** @inheritdoc */\r\n public systems(): SystemsSnapshot {\r\n return { revision: this.#revision, graph: buildSystemsGraph(this.world.systems.describe()) };\r\n }\r\n\r\n /** @inheritdoc */\r\n public components(): ComponentsSnapshot {\r\n return inspectComponents(this.world);\r\n }\r\n\r\n /** @inheritdoc */\r\n public entities(query?: EntitiesQuery): EntitiesPage {\r\n return inspectEntities(this.world, query);\r\n }\r\n\r\n /** @inheritdoc */\r\n public entity(id: number): EntityDetail | null {\r\n return inspectEntity(this.world, id);\r\n }\r\n\r\n /** @inheritdoc */\r\n public resources(): ResourceInfo[] {\r\n return this.world.container.list().map(({ name }, index) => ({ key: String(index), name }));\r\n }\r\n\r\n /** @inheritdoc */\r\n public resource(key: string): ResourceDetail | null {\r\n // Resources are only appended: indexes are stable keys\r\n const entry = this.world.container.list()[Number(key)];\r\n return entry ? { key, name: entry.name, value: serializeValue(entry.resource) } : null;\r\n }\r\n\r\n /** @inheritdoc */\r\n [Symbol.dispose]() {\r\n this.#unsubscribes.splice(0).forEach((unsubscribe) => unsubscribe());\r\n }\r\n}\r\n","/**\r\n * The contract between the devtools plugin and any consumer (browser extension, in-page overlay, tests...).\r\n * Everything crossing this boundary is plain JSON: no class instance, no symbol, no presentation concern.\r\n */\r\n\r\n/** Version of the contract. Incremented on breaking changes, consumers are expected to check it. */\r\nexport const DEVTOOLS_PROTOCOL_VERSION = 1;\r\n\r\n/** Name of the global through which consumers discover the registered worlds */\r\nexport const DEVTOOLS_HOOK_KEY = '__BIM_ECS_DEVTOOLS__';\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// Values\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\n/** A JSON-safe, bounded representation of any runtime value */\r\nexport type SerializedValue =\r\n | null\r\n | boolean\r\n | number\r\n | string\r\n | { $: 'undefined' }\r\n | { $: 'number'; v: 'NaN' | 'Infinity' | '-Infinity' }\r\n | { $: 'bigint'; v: string }\r\n | { $: 'symbol'; v: string }\r\n | { $: 'function'; name: string }\r\n | { $: 'date'; v: string }\r\n /** `size` is the real size: it is greater than the number of items when the collection has been truncated */\r\n | { $: 'array'; size: number; items: SerializedValue[] }\r\n | { $: 'set'; size: number; items: SerializedValue[] }\r\n | { $: 'map'; size: number; entries: [SerializedValue, SerializedValue][] }\r\n | { $: 'object'; cls: string; size: number; entries: [string, SerializedValue][] }\r\n /** A value which is not inspected: DOM nodes, promises, weak collections, getters... */\r\n | { $: 'opaque'; cls: string; desc?: string }\r\n | { $: 'circular' }\r\n /** The depth or the node budget has been reached */\r\n | { $: 'truncated'; cls?: string; size?: number };\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// Worlds\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\n/** Identifies a world registered on the hook */\r\nexport interface WorldInfo {\r\n id: string;\r\n name: string;\r\n}\r\n\r\n/** The state of a world: cheap to compute, meant to be polled */\r\nexport interface WorldState extends WorldInfo {\r\n running: boolean;\r\n /** Changes whenever the systems structure or state changes: the cue to fetch `systems()` again */\r\n revision: number;\r\n systems: number;\r\n entities: number;\r\n}\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// Systems\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\n/**\r\n * Kind of a graph node: `system`, `event`, `command` or the kind of a scheduler (`startup`, `frame`, `timer`,\r\n * `component-added`, `component-removed`, `component-value-changed`, `entity-spawned`, `entity-removed`, `after`,\r\n * `when`, `debounce`, `debounce-frame`, `compose`, `custom`...). Consumers must tolerate unknown kinds.\r\n */\r\nexport type GraphNodeKind = string;\r\n\r\nexport interface GraphNode {\r\n /** Unique, stable across snapshots as long as the structure does not change */\r\n id: string;\r\n kind: GraphNodeKind;\r\n /** The name of the thing: system name, event name, component name, delay... */\r\n label: string;\r\n /** Secondary information, e.g. the components a query excludes */\r\n detail?: string;\r\n /** Only for `system` nodes registered in the world */\r\n system?: { id: number; running: boolean; disposed: boolean };\r\n}\r\n\r\n/**\r\n * - `schedule`: the source triggers the target (event, command, component change, startup... or a modifier chain)\r\n * - `after`: the target runs once the source system has been processed\r\n * - `publish`: the system publishes the event when processed\r\n * - `trigger`: the system triggers the command when processed\r\n */\r\nexport type GraphEdgeKind = 'schedule' | 'after' | 'publish' | 'trigger';\r\n\r\nexport interface GraphEdge {\r\n id: string;\r\n from: string;\r\n to: string;\r\n kind: GraphEdgeKind;\r\n}\r\n\r\nexport interface SystemsGraph {\r\n nodes: GraphNode[];\r\n edges: GraphEdge[];\r\n}\r\n\r\nexport interface SystemsSnapshot {\r\n revision: number;\r\n graph: SystemsGraph;\r\n}\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// Components & entities\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\nexport type ComponentKind = 'component' | 'mutable' | 'indexed';\r\n\r\nexport interface ComponentTypeInfo {\r\n /** Stable identifier of the component type, used to filter entities */\r\n key: string;\r\n name: string;\r\n kind: ComponentKind;\r\n /** The number of entities holding the component type */\r\n entities: number;\r\n}\r\n\r\nexport interface ArchetypeInfo {\r\n key: string;\r\n /** The component type keys of the archetype */\r\n components: string[];\r\n entities: number;\r\n}\r\n\r\nexport interface ComponentsSnapshot {\r\n /** The total number of entities */\r\n entities: number;\r\n types: ComponentTypeInfo[];\r\n archetypes: ArchetypeInfo[];\r\n}\r\n\r\nexport interface EntitiesQuery {\r\n /** Component type keys the entities must hold */\r\n with?: string[];\r\n /** Component type keys the entities must not hold */\r\n without?: string[];\r\n /** Defaults to 0 */\r\n offset?: number;\r\n /** Defaults to 100 */\r\n limit?: number;\r\n}\r\n\r\nexport interface EntitySummary {\r\n id: number;\r\n /** The component type keys of the entity */\r\n components: string[];\r\n}\r\n\r\nexport interface EntitiesPage {\r\n /** The number of entities matching the query, whatever the page is */\r\n total: number;\r\n entities: EntitySummary[];\r\n}\r\n\r\nexport interface EntityComponentDetail {\r\n key: string;\r\n name: string;\r\n kind: ComponentKind;\r\n value: SerializedValue;\r\n /** Additional own fields of the component, when it defines some */\r\n fields?: SerializedValue;\r\n}\r\n\r\nexport interface EntityDetail {\r\n id: number;\r\n components: EntityComponentDetail[];\r\n}\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// Resources\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\nexport interface ResourceInfo {\r\n key: string;\r\n name: string;\r\n}\r\n\r\nexport interface ResourceDetail extends ResourceInfo {\r\n value: SerializedValue;\r\n}\r\n\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n// API\r\n// ---------------------------------------------------------------------------------------------------------------------\r\n\r\n/** What a consumer can ask to a world. Every method is synchronous and returns JSON-safe data. */\r\nexport interface DevtoolsApi {\r\n info(): WorldState;\r\n systems(): SystemsSnapshot;\r\n components(): ComponentsSnapshot;\r\n entities(query?: EntitiesQuery): EntitiesPage;\r\n /** `null` when the entity does not exist */\r\n entity(id: number): EntityDetail | null;\r\n resources(): ResourceInfo[];\r\n /** `null` when the resource does not exist anymore */\r\n resource(key: string): ResourceDetail | null;\r\n}\r\n\r\n/** Names of the `DevtoolsApi` methods */\r\nexport const DEVTOOLS_API_METHODS = [\r\n 'info',\r\n 'systems',\r\n 'components',\r\n 'entities',\r\n 'entity',\r\n 'resources',\r\n 'resource',\r\n] as const satisfies ReadonlyArray<keyof DevtoolsApi>;\r\n\r\nexport type DevtoolsApiMethod = (typeof DEVTOOLS_API_METHODS)[number];\r\n\r\n/** Outcome of a call through the hook: errors travel as data, so they are never lost between contexts */\r\nexport type DevtoolsCallResult<T = unknown> = { ok: true; value: T } | { ok: false; error: string };\r\n\r\n/** The global object registered on `globalThis[DEVTOOLS_HOOK_KEY]` */\r\nexport interface DevtoolsHook {\r\n readonly protocol: number;\r\n /** The worlds currently registered */\r\n worlds(): WorldInfo[];\r\n /** The single entry point for consumers evaluating code in the page */\r\n call(worldId: string, method: DevtoolsApiMethod, args?: unknown[]): DevtoolsCallResult;\r\n}\r\n","import {\r\n DEVTOOLS_API_METHODS,\r\n DEVTOOLS_HOOK_KEY,\r\n DEVTOOLS_PROTOCOL_VERSION,\r\n type DevtoolsApiMethod,\r\n type DevtoolsCallResult,\r\n type DevtoolsHook,\r\n type WorldInfo,\r\n} from './protocol';\r\nimport type { DevtoolsBridge } from './devtools-bridge';\r\n\r\n/** The hook, with the members only plugin instances are expected to use */\r\nexport interface DevtoolsHostHook extends DevtoolsHook {\r\n /** Registers a bridge, returns the function unregistering it */\r\n attach(bridge: DevtoolsBridge): () => void;\r\n /** Provides the next world number: a hook shared by several plugin copies must keep identifiers unique */\r\n nextWorldNumber(): number;\r\n}\r\n\r\n/** Provides the hook of the page, creating it when it does not exist yet */\r\nexport function getOrCreateHook(): DevtoolsHostHook {\r\n const host = globalThis as Record<string, any>;\r\n const existing = host[DEVTOOLS_HOOK_KEY] as DevtoolsHostHook | undefined;\r\n if (existing && typeof existing.attach === 'function') return existing;\r\n\r\n const bridges = new Map<string, DevtoolsBridge>();\r\n let worldCounter = 0;\r\n\r\n const hook: DevtoolsHostHook = {\r\n protocol: DEVTOOLS_PROTOCOL_VERSION,\r\n\r\n worlds(): WorldInfo[] {\r\n return [...bridges.values()].map((bridge) => bridge.worldInfo);\r\n },\r\n\r\n call(worldId, method, args = []): DevtoolsCallResult {\r\n const bridge = bridges.get(worldId);\r\n if (!bridge) return { ok: false, error: `Unknown world \"${worldId}\"` };\r\n if (!DEVTOOLS_API_METHODS.includes(method)) return { ok: false, error: `Unknown method \"${method}\"` };\r\n\r\n try {\r\n return { ok: true, value: (bridge[method as DevtoolsApiMethod] as (...args: unknown[]) => unknown)(...args) };\r\n } catch (error) {\r\n return { ok: false, error: String(error) };\r\n }\r\n },\r\n\r\n attach(bridge) {\r\n bridges.set(bridge.id, bridge);\r\n return () => void bridges.delete(bridge.id);\r\n },\r\n\r\n nextWorldNumber: () => ++worldCounter,\r\n };\r\n\r\n host[DEVTOOLS_HOOK_KEY] = hook;\r\n return hook;\r\n}\r\n","import { ECS_WORLD_DISPOSING_EVENT, type EcsWorld } from '@state-of-geneva/bim-ecs';\r\nimport { DevtoolsBridge } from './devtools-bridge';\r\nimport { getOrCreateHook } from './devtools-hook';\r\n\r\nexport interface DevtoolsPluginOptions {\r\n /** The name displayed by devtools to identify the world (default: `World <n>`) */\r\n name?: string;\r\n}\r\n\r\n/** Bridges already installed: installing the plugin twice on a world must not register it twice */\r\nconst installedBridges = new WeakMap<EcsWorld, DevtoolsBridge>();\r\n\r\n/**\r\n * Exposes the systems, components, entities and resources of the world to devtools (e.g. the browser extension),\r\n * through the `__BIM_ECS_DEVTOOLS__` global. Nothing is computed until devtools ask for it.\r\n *\r\n * @example\r\n * if (import.meta.env.DEV) world.use(devtoolsPlugin({ name: 'Game' }));\r\n *\r\n * @param options The plugin options\r\n * @returns The plugin, which returns the bridge answering to devtools when applied (useful for tests and custom\r\n * transports)\r\n */\r\nexport const devtoolsPlugin =\r\n (options: DevtoolsPluginOptions = {}) =>\r\n (world: EcsWorld): DevtoolsBridge => {\r\n const installed = installedBridges.get(world);\r\n if (installed) return installed;\r\n\r\n const hook = getOrCreateHook();\r\n const worldNumber = hook.nextWorldNumber();\r\n const bridge = new DevtoolsBridge(world, `world-${worldNumber}`, options.name ?? `World ${worldNumber}`);\r\n installedBridges.set(world, bridge);\r\n\r\n const detach = hook.attach(bridge);\r\n world.bus.subscribe(ECS_WORLD_DISPOSING_EVENT, () => {\r\n detach();\r\n bridge[Symbol.dispose]();\r\n installedBridges.delete(world);\r\n });\r\n\r\n return bridge;\r\n };\r\n"],"mappings":"6GAIA,IAAM,EAAe,IAAI,IAAI,CAC3B,UACA,QACA,kBACA,oBACA,0BACA,iBACA,gBACF,CAAC,EAUD,SAAgB,EAAkB,EAAoD,CACpF,IAAM,EAAQ,IAAI,IACZ,EAAQ,IAAI,IAEZ,EAAgB,GAAe,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