@mavonengine/editor 0.0.9 → 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.
@@ -0,0 +1,75 @@
1
+ import { Mesh as e, MeshBasicMaterial as t } from "three";
2
+ // src/Editor/applyShadeMode.ts
3
+ function n(n, r, i, a, o) {
4
+ n.traverse((n) => {
5
+ if (n instanceof e) {
6
+ if (r === "solid") {
7
+ a.get(n.uuid)?.dispose(), a.delete(n.uuid);
8
+ let e = i.get(n.uuid);
9
+ e && (n.material = e, i.delete(n.uuid));
10
+ } else {
11
+ i.has(n.uuid) || i.set(n.uuid, n.material), a.get(n.uuid)?.dispose(), o.has(n.uuid) || o.set(n.uuid, Math.random() * 16777215);
12
+ let e = o.get(n.uuid), s = new t(r === "wireframe" ? {
13
+ wireframe: !0,
14
+ color: e
15
+ } : { color: e });
16
+ a.set(n.uuid, s), n.material = s;
17
+ }
18
+ }
19
+ });
20
+ }
21
+ var r = /\/$/;
22
+ function i() {
23
+ try {
24
+ return (localStorage.getItem("mavonengine:server-url") ?? "").replace(r, "");
25
+ } catch {
26
+ return "";
27
+ }
28
+ }
29
+ async function a(e, t = {}, n = fetch) {
30
+ let r = new URLSearchParams();
31
+ for (let [e, n] of Object.entries(t)) n !== void 0 && n !== "" && r.set(e, String(n));
32
+ let a = r.toString(), o;
33
+ try {
34
+ o = await n(`${i()}/api/game/dev/net/${e}${a ? `?${a}` : ""}`);
35
+ } catch {
36
+ throw Error("The game server is not reachable");
37
+ }
38
+ if (o.status === 404 || !o.headers.get("content-type")?.includes("application/json")) throw Error("The game server has no network debug endpoints here. They are served in development, on the origin of this page");
39
+ if (!o.ok) throw Error(`The game server answered ${o.status} ${o.statusText}`);
40
+ return o.json();
41
+ }
42
+ function o(e) {
43
+ return a("sync", {}, e);
44
+ }
45
+ function s(e, t) {
46
+ return a("packets", { ...e }, t);
47
+ }
48
+ async function c(e, t) {
49
+ return (await a(`packets/${e}`, {}, t)).record;
50
+ }
51
+ // src/Editor/panels.ts
52
+ var l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = [];
53
+ function f() {
54
+ d = [...l.values()], u.forEach((e) => e());
55
+ }
56
+ function p(e) {
57
+ if (!e.component && !e.mount) throw Error(`Editor panel ${e.id} needs a component or a mount function`);
58
+ let t = e;
59
+ return l.set(t.id, t), f(), () => {
60
+ l.get(t.id) === t && m(t.id);
61
+ };
62
+ }
63
+ function m(e) {
64
+ l.delete(e) && f();
65
+ }
66
+ function h() {
67
+ return d;
68
+ }
69
+ function g(e) {
70
+ return u.add(e), () => u.delete(e);
71
+ }
72
+ function _(e, t) {
73
+ return e.filter((e) => e.location === t).sort((e, t) => (e.order ?? 0) - (t.order ?? 0));
74
+ }
75
+ export { m as a, o as c, g as i, n as l, _ as n, c as o, p as r, s, h as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mavonengine/editor",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",