mirror of
https://github.com/motajs/template.git
synced 2026-09-12 17:58:51 +08:00
fix(03-13): execute single event bodies directly
- Accept anon-tokyo Statement[] bodies for eventInsertEvent - Execute bodies through the existing interpreter without event-store lookup - Preserve eventInsertEvents as the ordered id-sequence path
This commit is contained in:
parent
fcff1c57af
commit
2f14d8a0ae
@ -205,15 +205,6 @@ export async function eventInsertEvents(
|
||||
}
|
||||
}
|
||||
|
||||
/** 临时执行指定事件 */
|
||||
export async function eventInsertEvent(
|
||||
param: IInsertEventEventParam,
|
||||
env: IBlockEventEnv
|
||||
): Promise<void> {
|
||||
if (!param.id) return;
|
||||
await eventInsertEvents({ ids: [param.id] }, env);
|
||||
}
|
||||
|
||||
/** 创建事件控制事件的内建函数注册项 */
|
||||
export function createControlEventBuiltinRegistrations(): ReadonlyArray<BuiltInFunction> {
|
||||
return [
|
||||
@ -228,3 +219,23 @@ export function createControlEventBuiltinRegistrations(): ReadonlyArray<BuiltInF
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/** 临时直接执行一段事件语句 */
|
||||
export async function eventInsertEvent(
|
||||
param: IInsertEventEventParam,
|
||||
env: IBlockEventEnv
|
||||
): Promise<void> {
|
||||
if (param.length === 0 || !hasEventSystem(env.state)) return;
|
||||
const depth = eventInsertDepth.get(env) ?? 0;
|
||||
if (depth >= EVENT_INSERT_MAX_DEPTH) return;
|
||||
eventInsertDepth.set(env, depth + 1);
|
||||
try {
|
||||
await env.state.eventSystem.executor.interpreter.exec(
|
||||
param,
|
||||
{ custom: {} },
|
||||
env
|
||||
);
|
||||
} finally {
|
||||
eventInsertDepth.delete(env);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { ObjectMoveStep } from '@user/data-common';
|
||||
import { Statement } from 'anon-tokyo';
|
||||
|
||||
//#region 地图控制
|
||||
|
||||
@ -58,11 +59,8 @@ export interface IInsertEventsEventParam {
|
||||
readonly ids: readonly string[];
|
||||
}
|
||||
|
||||
/** 事件:临时插入一个事件 */
|
||||
export interface IInsertEventEventParam {
|
||||
/** 事件 id */
|
||||
readonly id: string;
|
||||
}
|
||||
/** 事件:临时执行一段事件语句 */
|
||||
export type IInsertEventEventParam = Statement[];
|
||||
|
||||
/** 内建函数的稳定注册名称 */
|
||||
export const enum EventBuiltinName {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user