Preserve declared Eve control payloads
This commit is contained in:
parent
3ede0799ab
commit
7f9b5f63ed
3 changed files with 30 additions and 6 deletions
9
packages/eve-browser-lowering/dist/index.js
vendored
9
packages/eve-browser-lowering/dist/index.js
vendored
|
|
@ -1178,8 +1178,8 @@ export function createInventoryDropIntent(source, target, destinationX, destinat
|
|||
const targetIndex = numberProp(target.targetIndex, -1);
|
||||
const targetKind = firstString(target.targetKind, "");
|
||||
const payload = {};
|
||||
copyInventoryPayloadProps(source, payload);
|
||||
copyInventoryPayloadProps(target, payload);
|
||||
copyPayloadProps(source, payload);
|
||||
copyPayloadProps(target, payload);
|
||||
Object.assign(payload, {
|
||||
sourceKind,
|
||||
originEntityKey: firstString(source.sourceEntityKey, source.entityKey, ""),
|
||||
|
|
@ -1252,7 +1252,7 @@ function parseInventoryCells(value) {
|
|||
return Number.isInteger(x) && Number.isInteger(y) ? [{ x, y }] : [];
|
||||
});
|
||||
}
|
||||
function copyInventoryPayloadProps(source, payload) {
|
||||
function copyPayloadProps(source, payload) {
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
if (key.startsWith("payload.") && key.length > "payload.".length)
|
||||
payload[key.slice("payload.".length)] = value;
|
||||
|
|
@ -1590,6 +1590,8 @@ export function createEveCommandIntent(commandId, props = {}, options = {}) {
|
|||
const worldInteraction = resolveAdvertisedWorldInteraction(options, surfaceId);
|
||||
const commandBoundary = firstString(worldInteraction.commandBoundary, props.commandBoundary, action.commandBoundary, action.target);
|
||||
const receiptSchema = firstString(worldInteraction.receiptSchema, props.receiptSchema, action.receiptSchema);
|
||||
const declaredPayload = {};
|
||||
copyPayloadProps(props, declaredPayload);
|
||||
const intent = {
|
||||
type: "surface-command",
|
||||
schema: "gamecult.eve.command_invocation.v1",
|
||||
|
|
@ -1597,6 +1599,7 @@ export function createEveCommandIntent(commandId, props = {}, options = {}) {
|
|||
surfaceId,
|
||||
command: commandId || stringProp(action.type, "invoke"),
|
||||
payload: {
|
||||
...declaredPayload,
|
||||
...action,
|
||||
transport: props.transport ?? null,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1400,8 +1400,8 @@ export function createInventoryDropIntent(
|
|||
const targetIndex = numberProp(target.targetIndex, -1);
|
||||
const targetKind = firstString(target.targetKind, "");
|
||||
const payload: Record<string, unknown> = {};
|
||||
copyInventoryPayloadProps(source, payload);
|
||||
copyInventoryPayloadProps(target, payload);
|
||||
copyPayloadProps(source, payload);
|
||||
copyPayloadProps(target, payload);
|
||||
Object.assign(payload, {
|
||||
sourceKind,
|
||||
originEntityKey: firstString(source.sourceEntityKey, source.entityKey, ""),
|
||||
|
|
@ -1490,7 +1490,7 @@ function parseInventoryCells(value: unknown): InventoryPlacementCell[] {
|
|||
});
|
||||
}
|
||||
|
||||
function copyInventoryPayloadProps(source: Record<string, unknown>, payload: Record<string, unknown>): void {
|
||||
function copyPayloadProps(source: Record<string, unknown>, payload: Record<string, unknown>): void {
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
if (key.startsWith("payload.") && key.length > "payload.".length)
|
||||
payload[key.slice("payload.".length)] = value;
|
||||
|
|
@ -1870,6 +1870,8 @@ export function createEveCommandIntent(
|
|||
const worldInteraction = resolveAdvertisedWorldInteraction(options, surfaceId);
|
||||
const commandBoundary = firstString(worldInteraction.commandBoundary, props.commandBoundary, action.commandBoundary, action.target);
|
||||
const receiptSchema = firstString(worldInteraction.receiptSchema, props.receiptSchema, action.receiptSchema);
|
||||
const declaredPayload: Record<string, unknown> = {};
|
||||
copyPayloadProps(props, declaredPayload);
|
||||
const intent: EveCommandIntent = {
|
||||
type: "surface-command",
|
||||
schema: "gamecult.eve.command_invocation.v1",
|
||||
|
|
@ -1877,6 +1879,7 @@ export function createEveCommandIntent(
|
|||
surfaceId,
|
||||
command: commandId || stringProp(action.type, "invoke"),
|
||||
payload: {
|
||||
...declaredPayload,
|
||||
...action,
|
||||
transport: props.transport ?? null,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -56,6 +56,24 @@ test("world interactions emit provider-routed command intents without local auth
|
|||
assert.equal(intent.payload.directionX, 1);
|
||||
});
|
||||
|
||||
test("ordinary controls preserve provider-declared payload fields", () => {
|
||||
const intent = createEveCommandIntent("aetheria.hangar.launch", {
|
||||
label: "LAUNCH",
|
||||
command: "aetheria.hangar.launch",
|
||||
"payload.expectedProgressionVerseId": "gamecult.aetheria",
|
||||
"payload.expectedProgressionSourceRevision": "7",
|
||||
}, {
|
||||
activeSurfaceId: "aetheria.hangar",
|
||||
clientId: "browser.hangar-test",
|
||||
provider: { providerId: "aetheria", surfaces: [{ surfaceId: "aetheria.hangar" }] },
|
||||
});
|
||||
|
||||
assert.equal(intent.payload.expectedProgressionVerseId, "gamecult.aetheria");
|
||||
assert.equal(intent.payload.expectedProgressionSourceRevision, "7");
|
||||
assert.equal(intent.payload.label, undefined);
|
||||
assert.equal(intent.payload.command, undefined);
|
||||
});
|
||||
|
||||
test("inventory drops select the provider-advertised operation and preserve spatial identity", () => {
|
||||
const intent = createInventoryDropIntent({
|
||||
sourceKind: "cargo",
|
||||
|
|
|
|||
Loading…
Reference in a new issue