bevy-ts 0.1.0-alpha.7 → 0.1.0-alpha.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/package.json +6 -6
- package/protocol.d.ts +98 -4
- package/runtime/jsx-runtime.js +15 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bevy-ts",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
4
|
"description": "TypeScript for Bevy: components, systems and hot reload without recompiling Rust",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"examples"
|
|
60
60
|
],
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@bevy-ts/darwin-arm64": "0.1.0-alpha.
|
|
63
|
-
"@bevy-ts/darwin-x64": "0.1.0-alpha.
|
|
64
|
-
"@bevy-ts/linux-arm64": "0.1.0-alpha.
|
|
65
|
-
"@bevy-ts/linux-x64": "0.1.0-alpha.
|
|
66
|
-
"@bevy-ts/win32-x64": "0.1.0-alpha.
|
|
62
|
+
"@bevy-ts/darwin-arm64": "0.1.0-alpha.9",
|
|
63
|
+
"@bevy-ts/darwin-x64": "0.1.0-alpha.9",
|
|
64
|
+
"@bevy-ts/linux-arm64": "0.1.0-alpha.9",
|
|
65
|
+
"@bevy-ts/linux-x64": "0.1.0-alpha.9",
|
|
66
|
+
"@bevy-ts/win32-x64": "0.1.0-alpha.9"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"json-schema-to-typescript": "^15.0.4",
|
package/protocol.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @generated by packages/bevy-ts/scripts/gen-protocol.mjs from protocol/bevy-ts.openrpc.json. Do not edit.
|
|
2
2
|
|
|
3
3
|
/** The protocol version these types describe. */
|
|
4
|
-
export const PROTOCOL_VERSION: "1.
|
|
4
|
+
export const PROTOCOL_VERSION: "1.23.0";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* An entity id: Entity::to_bits.
|
|
@@ -52,6 +52,13 @@ export type TsxNodeId = string;
|
|
|
52
52
|
* via the `definition` "TsxProvenance".
|
|
53
53
|
*/
|
|
54
54
|
export type TsxProvenance = "controlled" | "initial" | "default" | "bound" | "override";
|
|
55
|
+
/**
|
|
56
|
+
* (1.21) Why a level entry is a placeholder: no live code registers the type (`unregistered`), its code threw or the TS build failed (`failed`), or saved fields or props do not fit live code (`mismatch`).
|
|
57
|
+
*
|
|
58
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
59
|
+
* via the `definition` "MissingReason".
|
|
60
|
+
*/
|
|
61
|
+
export type MissingReason = "unregistered" | "failed" | "mismatch";
|
|
55
62
|
/**
|
|
56
63
|
* A ViewportInput type.
|
|
57
64
|
*
|
|
@@ -842,6 +849,20 @@ export interface TsxTreeNode {
|
|
|
842
849
|
* Written in that file, rather than coming from a prefab, an included level or the scene's TSX.
|
|
843
850
|
*/
|
|
844
851
|
written: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* (1.21) One per placeholder entry on the entity: a component the level writes whose code is missing, failed or does not fit. Absent when there is none.
|
|
854
|
+
*/
|
|
855
|
+
missing?: {
|
|
856
|
+
/**
|
|
857
|
+
* The name the level writes.
|
|
858
|
+
*/
|
|
859
|
+
component: string;
|
|
860
|
+
reason: MissingReason;
|
|
861
|
+
/**
|
|
862
|
+
* (1.23) True when the component is the entity's own scene component, the one its row instances; absent for a patch component.
|
|
863
|
+
*/
|
|
864
|
+
scene?: boolean;
|
|
865
|
+
}[];
|
|
845
866
|
};
|
|
846
867
|
/**
|
|
847
868
|
* (1.15) The root the node is in.
|
|
@@ -2029,7 +2050,7 @@ export interface LevelNodeResult {
|
|
|
2029
2050
|
source?: SourceLocation[];
|
|
2030
2051
|
overrides: LevelOverride[];
|
|
2031
2052
|
/**
|
|
2032
|
-
* The scene component the entity instances, if any.
|
|
2053
|
+
* The scene component the entity instances, if any; still named when it is a placeholder (1.21).
|
|
2033
2054
|
*/
|
|
2034
2055
|
prefab?: string | null;
|
|
2035
2056
|
/**
|
|
@@ -2037,9 +2058,13 @@ export interface LevelNodeResult {
|
|
|
2037
2058
|
*/
|
|
2038
2059
|
props?: LevelProp[];
|
|
2039
2060
|
/**
|
|
2040
|
-
* (1.12) Components the file adds that the entity's prefab does not give, named as LevelOverride.component names them.
|
|
2061
|
+
* (1.12) Components the file adds that the entity's prefab does not give, named as LevelOverride.component names them. (1.23) A placeholder patch component the file writes is listed too, by the name the file writes; the entity's own scene component never is.
|
|
2041
2062
|
*/
|
|
2042
2063
|
patches?: string[];
|
|
2064
|
+
/**
|
|
2065
|
+
* (1.21) The entity's placeholder entries; absent when there is none.
|
|
2066
|
+
*/
|
|
2067
|
+
missing?: MissingComponent[];
|
|
2043
2068
|
}
|
|
2044
2069
|
/**
|
|
2045
2070
|
* One @prop of a scene component instance: its type, the value it takes, and whether the level sets it.
|
|
@@ -2074,6 +2099,72 @@ export interface SourceLocation1 {
|
|
|
2074
2099
|
line: number;
|
|
2075
2100
|
column: number;
|
|
2076
2101
|
}
|
|
2102
|
+
/**
|
|
2103
|
+
* (1.21) A component a level writes whose code is missing, failed or does not fit. Its saved text is kept in the file.
|
|
2104
|
+
*
|
|
2105
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
2106
|
+
* via the `definition` "MissingComponent".
|
|
2107
|
+
*/
|
|
2108
|
+
export interface MissingComponent {
|
|
2109
|
+
/**
|
|
2110
|
+
* The name the level writes (`game::Loot`).
|
|
2111
|
+
*/
|
|
2112
|
+
component: string;
|
|
2113
|
+
reason: MissingReason;
|
|
2114
|
+
/**
|
|
2115
|
+
* (1.23) True when the component is the entity's own scene component, the one it instances; absent for a patch component.
|
|
2116
|
+
*/
|
|
2117
|
+
scene?: boolean;
|
|
2118
|
+
/**
|
|
2119
|
+
* One line of why.
|
|
2120
|
+
*/
|
|
2121
|
+
message?: string;
|
|
2122
|
+
/**
|
|
2123
|
+
* Saved fields and props as written, each value its saved text; a prop keeps its `@`. A mismatch lists only the misfits.
|
|
2124
|
+
*/
|
|
2125
|
+
fields: {
|
|
2126
|
+
[k: string]: string;
|
|
2127
|
+
};
|
|
2128
|
+
location: SourceLocation2;
|
|
2129
|
+
expected?: SourceLocation3;
|
|
2130
|
+
/**
|
|
2131
|
+
* mismatch: why each listed field or prop does not fit.
|
|
2132
|
+
*/
|
|
2133
|
+
misfit?: {
|
|
2134
|
+
[k: string]: string;
|
|
2135
|
+
};
|
|
2136
|
+
/**
|
|
2137
|
+
* A missing scene component: the entries below it with no base of their own, kept and not spawned.
|
|
2138
|
+
*/
|
|
2139
|
+
overrides?: {
|
|
2140
|
+
/**
|
|
2141
|
+
* The name path below the instance.
|
|
2142
|
+
*/
|
|
2143
|
+
path: string[];
|
|
2144
|
+
/**
|
|
2145
|
+
* Its patches' saved text, keyed `Component.field`.
|
|
2146
|
+
*/
|
|
2147
|
+
fields: {
|
|
2148
|
+
[k: string]: string;
|
|
2149
|
+
};
|
|
2150
|
+
}[];
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Where the level writes it.
|
|
2154
|
+
*/
|
|
2155
|
+
export interface SourceLocation2 {
|
|
2156
|
+
file: string;
|
|
2157
|
+
line: number;
|
|
2158
|
+
column: number;
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Where its code was expected: the throw, the file that did not build, or the declaration this process last saw live. Absent when unknown, as after a restart.
|
|
2162
|
+
*/
|
|
2163
|
+
export interface SourceLocation3 {
|
|
2164
|
+
file: string;
|
|
2165
|
+
line: number;
|
|
2166
|
+
column: number;
|
|
2167
|
+
}
|
|
2077
2168
|
/**
|
|
2078
2169
|
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
2079
2170
|
* via the `definition` "LevelWriteParams".
|
|
@@ -2096,7 +2187,7 @@ export interface LevelWriteResult {
|
|
|
2096
2187
|
file: string;
|
|
2097
2188
|
status: "written" | "rebased" | "conflict" | "refused";
|
|
2098
2189
|
/**
|
|
2099
|
-
* conflict: `target removed` or `changed on disk`; refused: `not-found`, `prefab-internal`, `exists`, `invalid`, `internal` or `io
|
|
2190
|
+
* conflict: `target removed` or `changed on disk`; refused: `not-found`, `prefab-internal`, `exists`, `invalid`, `internal` or `io`; (1.21) `missing`: a set, revert, set_prop or revert_prop on a placeholder component, `unknown`: a write of a type no live code registers.
|
|
2100
2191
|
*/
|
|
2101
2192
|
reason?: string | null;
|
|
2102
2193
|
message?: string | null;
|
|
@@ -2178,6 +2269,9 @@ export interface LevelWatchMessage {
|
|
|
2178
2269
|
*/
|
|
2179
2270
|
id?: number | null;
|
|
2180
2271
|
reason?: string | null;
|
|
2272
|
+
/**
|
|
2273
|
+
* failed: the errors; loaded (1.21): the level's diagnostics, a `warning:` per placeholder entry among them.
|
|
2274
|
+
*/
|
|
2181
2275
|
diagnostics?: LevelDiagnostic[];
|
|
2182
2276
|
opener?: LevelOpener1;
|
|
2183
2277
|
}
|
package/runtime/jsx-runtime.js
CHANGED
|
@@ -376,6 +376,11 @@ class Computation extends Owner {
|
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/** An error as it crosses to Rust. */
|
|
380
|
+
function errorRecord(e, location) {
|
|
381
|
+
return { message: e && e.message ? `${e.name || "Error"}: ${e.message}` : String(e), location: location || null, stack: e && e.stack ? String(e.stack) : null };
|
|
382
|
+
}
|
|
383
|
+
|
|
379
384
|
function reportError(e) {
|
|
380
385
|
console.error(e && e.stack ? e.stack : String(e));
|
|
381
386
|
}
|
|
@@ -702,19 +707,15 @@ export class TsxContext {
|
|
|
702
707
|
return { $b: id, $s: site.id };
|
|
703
708
|
}
|
|
704
709
|
|
|
705
|
-
/** One scene component instance, by name or `module#export`: its description, or
|
|
710
|
+
/** One scene component instance, by name or `module#export`: its description, or the error it raised. */
|
|
706
711
|
expand(name, props, at) {
|
|
707
712
|
const C = hostSceneComponent ? hostSceneComponent(name) : null;
|
|
708
|
-
if (!C || typeof C.scene !== "function") {
|
|
709
|
-
this.error(new Error(`no scene component named ${name}`), at || null);
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
713
|
+
if (!C || typeof C.scene !== "function") return { failure: errorRecord(new Error(`no scene component named ${name}`), at) };
|
|
712
714
|
try {
|
|
713
715
|
const nodes = runScene(this, () => describe(create(C, props || {}, undefined, at, false), this));
|
|
714
|
-
return nodes[0] || null;
|
|
716
|
+
return { node: nodes[0] || null };
|
|
715
717
|
} catch (e) {
|
|
716
|
-
|
|
717
|
-
return null;
|
|
718
|
+
return { failure: errorRecord(e, (e && e.bevyTsLocation) || at) };
|
|
718
719
|
}
|
|
719
720
|
}
|
|
720
721
|
|
|
@@ -757,7 +758,7 @@ export class TsxContext {
|
|
|
757
758
|
}
|
|
758
759
|
|
|
759
760
|
error(e, location) {
|
|
760
|
-
this.errors.push(
|
|
761
|
+
this.errors.push(errorRecord(e, location));
|
|
761
762
|
}
|
|
762
763
|
|
|
763
764
|
/**
|
|
@@ -836,9 +837,13 @@ export class TsxContext {
|
|
|
836
837
|
});
|
|
837
838
|
// Scene component instances a Rust plugin (levels) asks for: described after this call's
|
|
838
839
|
// computations started, so their bindings wait until the plugin has mounted them.
|
|
840
|
+
// Each failed item's own error goes beside it, not among the call's.
|
|
839
841
|
const expanded = (payload.expand || []).map(([name, props, at]) => this.expand(name, props, at));
|
|
840
842
|
const out = this.output();
|
|
841
|
-
if (payload.expand)
|
|
843
|
+
if (payload.expand) {
|
|
844
|
+
out.expanded = expanded.map((x) => x.node || null);
|
|
845
|
+
out.failures = expanded.map((x) => x.failure || null);
|
|
846
|
+
}
|
|
842
847
|
return out;
|
|
843
848
|
} finally {
|
|
844
849
|
this.inCall = false;
|