@rezless/vm 0.6.2 → 0.8.0
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/dist/builtins/agents.d.ts +14 -0
- package/dist/builtins/agents.d.ts.map +1 -0
- package/dist/builtins/agents.js +117 -0
- package/dist/builtins/agents.js.map +1 -0
- package/dist/builtins/animation.d.ts +46 -0
- package/dist/builtins/animation.d.ts.map +1 -0
- package/dist/builtins/animation.js +316 -0
- package/dist/builtins/animation.js.map +1 -0
- package/dist/builtins/attachments.d.ts +9 -0
- package/dist/builtins/attachments.d.ts.map +1 -0
- package/dist/builtins/attachments.js +127 -0
- package/dist/builtins/attachments.js.map +1 -0
- package/dist/builtins/base64.d.ts +13 -2
- package/dist/builtins/base64.d.ts.map +1 -1
- package/dist/builtins/base64.js +8 -6
- package/dist/builtins/base64.js.map +1 -1
- package/dist/builtins/camera.d.ts +35 -0
- package/dist/builtins/camera.d.ts.map +1 -0
- package/dist/builtins/camera.js +104 -0
- package/dist/builtins/camera.js.map +1 -0
- package/dist/builtins/collision.d.ts +21 -0
- package/dist/builtins/collision.d.ts.map +1 -0
- package/dist/builtins/collision.js +44 -0
- package/dist/builtins/collision.js.map +1 -0
- package/dist/builtins/controls.d.ts +19 -0
- package/dist/builtins/controls.d.ts.map +1 -0
- package/dist/builtins/controls.js +27 -0
- package/dist/builtins/controls.js.map +1 -0
- package/dist/builtins/damage.d.ts +24 -0
- package/dist/builtins/damage.d.ts.map +1 -0
- package/dist/builtins/damage.js +166 -0
- package/dist/builtins/damage.js.map +1 -0
- package/dist/builtins/detected.d.ts +22 -1
- package/dist/builtins/detected.d.ts.map +1 -1
- package/dist/builtins/detected.js +28 -2
- package/dist/builtins/detected.js.map +1 -1
- package/dist/builtins/dialog.d.ts +23 -0
- package/dist/builtins/dialog.d.ts.map +1 -0
- package/dist/builtins/dialog.js +69 -0
- package/dist/builtins/dialog.js.map +1 -0
- package/dist/builtins/email.d.ts +61 -0
- package/dist/builtins/email.d.ts.map +1 -0
- package/dist/builtins/email.js +121 -0
- package/dist/builtins/email.js.map +1 -0
- package/dist/builtins/environment.d.ts +27 -0
- package/dist/builtins/environment.d.ts.map +1 -0
- package/dist/builtins/environment.js +126 -0
- package/dist/builtins/environment.js.map +1 -0
- package/dist/builtins/experience.d.ts +51 -0
- package/dist/builtins/experience.d.ts.map +1 -0
- package/dist/builtins/experience.js +202 -0
- package/dist/builtins/experience.js.map +1 -0
- package/dist/builtins/game-control.d.ts +17 -0
- package/dist/builtins/game-control.d.ts.map +1 -0
- package/dist/builtins/game-control.js +21 -0
- package/dist/builtins/game-control.js.map +1 -0
- package/dist/builtins/give.d.ts +16 -0
- package/dist/builtins/give.d.ts.map +1 -0
- package/dist/builtins/give.js +137 -0
- package/dist/builtins/give.js.map +1 -0
- package/dist/builtins/ground.d.ts +18 -0
- package/dist/builtins/ground.d.ts.map +1 -0
- package/dist/builtins/ground.js +83 -0
- package/dist/builtins/ground.js.map +1 -0
- package/dist/builtins/hash.d.ts +1 -0
- package/dist/builtins/hash.d.ts.map +1 -1
- package/dist/builtins/hash.js +12 -2
- package/dist/builtins/hash.js.map +1 -1
- package/dist/builtins/http.d.ts +99 -4
- package/dist/builtins/http.d.ts.map +1 -1
- package/dist/builtins/http.js +216 -6
- package/dist/builtins/http.js.map +1 -1
- package/dist/builtins/index.d.ts.map +1 -1
- package/dist/builtins/index.js +250 -14
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/inventory.d.ts +8 -5
- package/dist/builtins/inventory.d.ts.map +1 -1
- package/dist/builtins/inventory.js +37 -15
- package/dist/builtins/inventory.js.map +1 -1
- package/dist/builtins/json.d.ts.map +1 -1
- package/dist/builtins/json.js +45 -34
- package/dist/builtins/json.js.map +1 -1
- package/dist/builtins/land.d.ts +29 -0
- package/dist/builtins/land.d.ts.map +1 -0
- package/dist/builtins/land.js +339 -0
- package/dist/builtins/land.js.map +1 -0
- package/dist/builtins/link-info.js +2 -2
- package/dist/builtins/link-info.js.map +1 -1
- package/dist/builtins/links.d.ts +20 -0
- package/dist/builtins/links.d.ts.map +1 -0
- package/dist/builtins/links.js +53 -0
- package/dist/builtins/links.js.map +1 -0
- package/dist/builtins/linksetdata.d.ts +5 -0
- package/dist/builtins/linksetdata.d.ts.map +1 -1
- package/dist/builtins/linksetdata.js +22 -9
- package/dist/builtins/linksetdata.js.map +1 -1
- package/dist/builtins/lists.d.ts +21 -0
- package/dist/builtins/lists.d.ts.map +1 -1
- package/dist/builtins/lists.js +137 -17
- package/dist/builtins/lists.js.map +1 -1
- package/dist/builtins/math.d.ts +18 -0
- package/dist/builtins/math.d.ts.map +1 -1
- package/dist/builtins/math.js +104 -5
- package/dist/builtins/math.js.map +1 -1
- package/dist/builtins/media.d.ts +8 -0
- package/dist/builtins/media.d.ts.map +1 -0
- package/dist/builtins/media.js +167 -0
- package/dist/builtins/media.js.map +1 -0
- package/dist/builtins/motion.d.ts +79 -0
- package/dist/builtins/motion.d.ts.map +1 -0
- package/dist/builtins/motion.js +396 -0
- package/dist/builtins/motion.js.map +1 -0
- package/dist/builtins/notecard-search.d.ts +15 -0
- package/dist/builtins/notecard-search.d.ts.map +1 -0
- package/dist/builtins/notecard-search.js +374 -0
- package/dist/builtins/notecard-search.js.map +1 -0
- package/dist/builtins/object-animation.d.ts +21 -0
- package/dist/builtins/object-animation.d.ts.map +1 -0
- package/dist/builtins/object-animation.js +193 -0
- package/dist/builtins/object-animation.js.map +1 -0
- package/dist/builtins/object-reads.d.ts +39 -0
- package/dist/builtins/object-reads.d.ts.map +1 -0
- package/dist/builtins/object-reads.js +332 -0
- package/dist/builtins/object-reads.js.map +1 -0
- package/dist/builtins/object.d.ts +11 -2
- package/dist/builtins/object.d.ts.map +1 -1
- package/dist/builtins/object.js +32 -8
- package/dist/builtins/object.js.map +1 -1
- package/dist/builtins/particles.d.ts +4 -0
- package/dist/builtins/particles.d.ts.map +1 -0
- package/dist/builtins/particles.js +65 -0
- package/dist/builtins/particles.js.map +1 -0
- package/dist/builtins/pathfinding.d.ts +39 -0
- package/dist/builtins/pathfinding.d.ts.map +1 -0
- package/dist/builtins/pathfinding.js +83 -0
- package/dist/builtins/pathfinding.js.map +1 -0
- package/dist/builtins/permissions.d.ts.map +1 -1
- package/dist/builtins/permissions.js +6 -0
- package/dist/builtins/permissions.js.map +1 -1
- package/dist/builtins/physics.d.ts +49 -0
- package/dist/builtins/physics.d.ts.map +1 -0
- package/dist/builtins/physics.js +47 -0
- package/dist/builtins/physics.js.map +1 -0
- package/dist/builtins/prim-accessors.d.ts +4 -0
- package/dist/builtins/prim-accessors.d.ts.map +1 -1
- package/dist/builtins/prim-accessors.js +75 -28
- package/dist/builtins/prim-accessors.js.map +1 -1
- package/dist/builtins/prim-params.d.ts.map +1 -1
- package/dist/builtins/prim-params.js +6 -2
- package/dist/builtins/prim-params.js.map +1 -1
- package/dist/builtins/raycast.d.ts +3 -0
- package/dist/builtins/raycast.d.ts.map +1 -0
- package/dist/builtins/raycast.js +65 -0
- package/dist/builtins/raycast.js.map +1 -0
- package/dist/builtins/region.d.ts +31 -0
- package/dist/builtins/region.d.ts.map +1 -0
- package/dist/builtins/region.js +125 -0
- package/dist/builtins/region.js.map +1 -0
- package/dist/builtins/remote-load.d.ts +3 -0
- package/dist/builtins/remote-load.d.ts.map +1 -0
- package/dist/builtins/remote-load.js +53 -0
- package/dist/builtins/remote-load.js.map +1 -0
- package/dist/builtins/rez.d.ts +10 -0
- package/dist/builtins/rez.d.ts.map +1 -0
- package/dist/builtins/rez.js +255 -0
- package/dist/builtins/rez.js.map +1 -0
- package/dist/builtins/rsa.d.ts +4 -0
- package/dist/builtins/rsa.d.ts.map +1 -0
- package/dist/builtins/rsa.js +44 -0
- package/dist/builtins/rsa.js.map +1 -0
- package/dist/builtins/script-control.d.ts +8 -3
- package/dist/builtins/script-control.d.ts.map +1 -1
- package/dist/builtins/script-control.js +27 -8
- package/dist/builtins/script-control.js.map +1 -1
- package/dist/builtins/sensor.d.ts +11 -0
- package/dist/builtins/sensor.d.ts.map +1 -0
- package/dist/builtins/sensor.js +145 -0
- package/dist/builtins/sensor.js.map +1 -0
- package/dist/builtins/sit.d.ts +23 -0
- package/dist/builtins/sit.d.ts.map +1 -0
- package/dist/builtins/sit.js +150 -0
- package/dist/builtins/sit.js.map +1 -0
- package/dist/builtins/sound.d.ts +19 -0
- package/dist/builtins/sound.d.ts.map +1 -0
- package/dist/builtins/sound.js +113 -0
- package/dist/builtins/sound.js.map +1 -0
- package/dist/builtins/strings.d.ts +6 -0
- package/dist/builtins/strings.d.ts.map +1 -1
- package/dist/builtins/strings.js +47 -6
- package/dist/builtins/strings.js.map +1 -1
- package/dist/builtins/targets.d.ts +12 -0
- package/dist/builtins/targets.d.ts.map +1 -0
- package/dist/builtins/targets.js +121 -0
- package/dist/builtins/targets.js.map +1 -0
- package/dist/builtins/time.d.ts +15 -5
- package/dist/builtins/time.d.ts.map +1 -1
- package/dist/builtins/time.js +36 -11
- package/dist/builtins/time.js.map +1 -1
- package/dist/builtins/vehicles.d.ts +22 -0
- package/dist/builtins/vehicles.d.ts.map +1 -0
- package/dist/builtins/vehicles.js +78 -0
- package/dist/builtins/vehicles.js.map +1 -0
- package/dist/builtins/viewer.d.ts +39 -0
- package/dist/builtins/viewer.d.ts.map +1 -0
- package/dist/builtins/viewer.js +74 -0
- package/dist/builtins/viewer.js.map +1 -0
- package/dist/clock.d.ts +45 -7
- package/dist/clock.d.ts.map +1 -1
- package/dist/clock.js +125 -14
- package/dist/clock.js.map +1 -1
- package/dist/dispatch.d.ts +3 -2
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +15 -10
- package/dist/dispatch.js.map +1 -1
- package/dist/experience.d.ts +39 -0
- package/dist/experience.d.ts.map +1 -0
- package/dist/experience.js +38 -0
- package/dist/experience.js.map +1 -0
- package/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interpreter.d.ts +5 -10
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +143 -70
- package/dist/interpreter.js.map +1 -1
- package/dist/inventory.d.ts +2 -0
- package/dist/inventory.d.ts.map +1 -1
- package/dist/inventory.js +2 -0
- package/dist/inventory.js.map +1 -1
- package/dist/linkset.d.ts +147 -11
- package/dist/linkset.d.ts.map +1 -1
- package/dist/linkset.js +401 -28
- package/dist/linkset.js.map +1 -1
- package/dist/memory.d.ts +5 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +5 -2
- package/dist/memory.js.map +1 -1
- package/dist/prim-params.d.ts +27 -10
- package/dist/prim-params.d.ts.map +1 -1
- package/dist/prim-params.js +209 -125
- package/dist/prim-params.js.map +1 -1
- package/dist/prim.d.ts +95 -5
- package/dist/prim.d.ts.map +1 -1
- package/dist/prim.js +96 -7
- package/dist/prim.js.map +1 -1
- package/dist/runtime.d.ts +52 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/script.d.ts +171 -12
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +480 -73
- package/dist/script.js.map +1 -1
- package/dist/typecheck.d.ts +3 -1
- package/dist/typecheck.d.ts.map +1 -1
- package/dist/typecheck.js +25 -5
- package/dist/typecheck.js.map +1 -1
- package/dist/values/coerce.d.ts +1 -1
- package/dist/values/coerce.d.ts.map +1 -1
- package/dist/values/coerce.js +10 -6
- package/dist/values/coerce.js.map +1 -1
- package/dist/values/format.d.ts +3 -1
- package/dist/values/format.d.ts.map +1 -1
- package/dist/values/format.js +10 -6
- package/dist/values/format.js.map +1 -1
- package/dist/values/ops.d.ts +3 -0
- package/dist/values/ops.d.ts.map +1 -1
- package/dist/values/ops.js +2 -2
- package/dist/values/ops.js.map +1 -1
- package/dist/world.d.ts +247 -1
- package/dist/world.d.ts.map +1 -1
- package/dist/world.js +318 -6
- package/dist/world.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { sayError } from './debug.js';
|
|
2
|
+
const vector = (x = 0, y = x, z = x) => ({ x, y, z });
|
|
3
|
+
/**
|
|
4
|
+
* https://wiki.secondlife.com/wiki/VEHICLE_TYPE_{SLED,CAR,BOAT,AIRPLANE,BALLOON}
|
|
5
|
+
* No LSL vehicle parameter getters exist. These are the documented presets;
|
|
6
|
+
* observable motion comparisons are cited in vehicles.test.ts.
|
|
7
|
+
*/
|
|
8
|
+
function defaults(type) {
|
|
9
|
+
if (type < 1 || type > 5)
|
|
10
|
+
return {};
|
|
11
|
+
const linearFriction = [vector(), vector(30, 1, 1000), vector(100, 2, 1000), vector(10, 3, 2), vector(200, 10, 5), vector(5)];
|
|
12
|
+
// Columns are vehicle types 1 through 5; rows use their public parameter IDs.
|
|
13
|
+
const floats = {
|
|
14
|
+
24: [0, 0, 0, 0, 5], 25: [10, 0, .5, .5, .8], 26: [10, 1000, 2, 1000, 10],
|
|
15
|
+
27: [0, 0, 1, 0, 1], 28: [1, 1, .5, .5, 0], 29: [1, 2, 3, .5, 5],
|
|
16
|
+
30: [1000, 1, 5, 2, 5], 31: [120, 60, 60, 60, 60],
|
|
17
|
+
32: [0, 0, .5, 1, 0], 33: [10, 10, 5, 2, 5],
|
|
18
|
+
34: [1000, 1, 4, 4, 6], 35: [120, .8, 4, 8, 10],
|
|
19
|
+
36: [1, 1, .5, .9, 1], 37: [1000, 10, 5, 2, 1000],
|
|
20
|
+
38: [0, -.2, -.3, 1, 0], 39: [1, 1, .8, .7, .7], 40: [10, 1, 1, 2, 5],
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
...Object.fromEntries(Object.entries(floats).map(([id, values]) => [id, values[type - 1]])),
|
|
24
|
+
16: linearFriction[type], 17: vector([0, 1000, 1000, 10, 20, 10][type]),
|
|
25
|
+
18: vector(), 19: vector(), 20: vector(), 44: { x: 0, y: 0, z: 0, s: 1 },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function setter(name, apply) {
|
|
29
|
+
return (ctx, args) => {
|
|
30
|
+
const state = ctx.prim.vehicle;
|
|
31
|
+
state.requests.push({ name, args: structuredClone(args) });
|
|
32
|
+
apply(state, args, ctx);
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const llSetVehicleType = setter('llSetVehicleType', (state, args) => {
|
|
37
|
+
const requested = args[0];
|
|
38
|
+
state.type = requested;
|
|
39
|
+
state.flags = [0, 67, 99, 101, 2, 0][state.type] ?? 0;
|
|
40
|
+
state.params = defaults(state.type);
|
|
41
|
+
});
|
|
42
|
+
export const llSetVehicleFlags = setter('llSetVehicleFlags', (state, args) => {
|
|
43
|
+
if (state.type)
|
|
44
|
+
state.flags |= args[0];
|
|
45
|
+
});
|
|
46
|
+
export const llRemoveVehicleFlags = setter('llRemoveVehicleFlags', (state, args) => {
|
|
47
|
+
if (state.type)
|
|
48
|
+
state.flags &= ~args[0];
|
|
49
|
+
});
|
|
50
|
+
export const llSetVehicleFloatParam = setter('llSetVehicleFloatParam', (state, args, ctx) => {
|
|
51
|
+
if (!state.type)
|
|
52
|
+
return;
|
|
53
|
+
const id = args[0], value = args[1];
|
|
54
|
+
if (id === 16 || id === 17)
|
|
55
|
+
state.params[id] = vector(value);
|
|
56
|
+
else if (id >= 24 && id <= 40)
|
|
57
|
+
state.params[id] = value;
|
|
58
|
+
else
|
|
59
|
+
sayError(ctx, `Unknown vehicle float parameter ${id}`);
|
|
60
|
+
});
|
|
61
|
+
export const llSetVehicleVectorParam = setter('llSetVehicleVectorParam', (state, args, ctx) => {
|
|
62
|
+
if (!state.type)
|
|
63
|
+
return;
|
|
64
|
+
const id = args[0];
|
|
65
|
+
if (id >= 16 && id <= 20)
|
|
66
|
+
state.params[id] = { ...args[1] };
|
|
67
|
+
else
|
|
68
|
+
sayError(ctx, `Unknown vehicle vector parameter ${id}`);
|
|
69
|
+
});
|
|
70
|
+
export const llSetVehicleRotationParam = setter('llSetVehicleRotationParam', (state, args, ctx) => {
|
|
71
|
+
if (!state.type)
|
|
72
|
+
return;
|
|
73
|
+
if (args[0] === 44)
|
|
74
|
+
state.params[44] = { ...args[1] };
|
|
75
|
+
else
|
|
76
|
+
sayError(ctx, `Unknown vehicle rotation parameter ${args[0]}`);
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=vehicles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vehicles.js","sourceRoot":"","sources":["../../src/builtins/vehicles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAoBrC,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AAE7D;;;;GAIG;AACH,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,EAAE,CAAA;IACnC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7H,8EAA8E;IAC9E,MAAM,MAAM,GAA6B;QACvC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,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C,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAC5F,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAM;IACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAW,CAAA;IAC5B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;QAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAW,EAAE,CAAA;;QAChE,QAAQ,CAAC,GAAG,EAAE,oCAAoC,EAAE,EAAE,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAChG,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAM;IACvB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAa,EAAE,CAAA;;QAC5D,QAAQ,CAAC,GAAG,EAAE,sCAAsC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AACrE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BuiltinImpl, CallContext } from '../runtime.js';
|
|
2
|
+
import type { LslValue, Vector } from '../values/types.js';
|
|
3
|
+
import type { Linkset } from '../linkset.js';
|
|
4
|
+
/** Requests made by the script. Floater requests include the simulator's rejection code. */
|
|
5
|
+
export type ViewerRequest = {
|
|
6
|
+
readonly kind: 'loadURL';
|
|
7
|
+
readonly agent: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'mapDestination';
|
|
12
|
+
readonly agent: string;
|
|
13
|
+
readonly region: string;
|
|
14
|
+
readonly position: Vector;
|
|
15
|
+
readonly lookAt: Vector;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'mapBeacon';
|
|
18
|
+
readonly agent: string;
|
|
19
|
+
readonly region: string;
|
|
20
|
+
readonly position: Vector;
|
|
21
|
+
readonly options: ReadonlyArray<LslValue>;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'openFloater';
|
|
24
|
+
readonly agent: string;
|
|
25
|
+
readonly floater: string;
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly params: ReadonlyArray<LslValue>;
|
|
28
|
+
readonly result: number;
|
|
29
|
+
};
|
|
30
|
+
/** Region-presence overrides supplied by tests, shared by scripts in that region. */
|
|
31
|
+
export declare function agentPresence(linkset: Linkset): Map<string, boolean>;
|
|
32
|
+
export declare function isAgentInRegion(ctx: CallContext, agent: string): boolean;
|
|
33
|
+
export declare function isKey(key: string): boolean;
|
|
34
|
+
export declare const llLoadURL: BuiltinImpl;
|
|
35
|
+
export declare const llMapDestination: BuiltinImpl;
|
|
36
|
+
export declare const llMapBeacon: BuiltinImpl;
|
|
37
|
+
/** Linden-owned privileged experiences cannot be represented by the current Experience fixture. */
|
|
38
|
+
export declare const llOpenFloater: BuiltinImpl;
|
|
39
|
+
//# sourceMappingURL=viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../src/builtins/viewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG5C,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC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B,CAAA;AAOD,eAAO,MAAM,gBAAgB,EAAE,WAO9B,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,WAQzB,CAAA;AAED,mGAAmG;AACnG,eAAO,MAAM,aAAa,EAAE,WAK3B,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { truncateUtf8 } from '../values/utf8.js';
|
|
2
|
+
import { NULL_KEY } from '../values/types.js';
|
|
3
|
+
import { sayError } from './debug.js';
|
|
4
|
+
const regions = new WeakMap();
|
|
5
|
+
/** Region-presence overrides supplied by tests, shared by scripts in that region. */
|
|
6
|
+
export function agentPresence(linkset) {
|
|
7
|
+
let regionsForClock = regions.get(linkset.clock);
|
|
8
|
+
if (!regionsForClock)
|
|
9
|
+
regions.set(linkset.clock, regionsForClock = new Map());
|
|
10
|
+
let agents = regionsForClock.get(linkset.region);
|
|
11
|
+
if (!agents)
|
|
12
|
+
regionsForClock.set(linkset.region, agents = new Map());
|
|
13
|
+
return agents;
|
|
14
|
+
}
|
|
15
|
+
export function isAgentInRegion(ctx, agent) {
|
|
16
|
+
agent = agent.toLowerCase();
|
|
17
|
+
if (agent === NULL_KEY || !isKey(agent))
|
|
18
|
+
return false;
|
|
19
|
+
const explicit = ctx.state.agentPresence.get(agent);
|
|
20
|
+
if (explicit !== undefined)
|
|
21
|
+
return explicit;
|
|
22
|
+
const avatar = ctx.linkset.world?.avatars.find(a => a.key.toLowerCase() === agent.toLowerCase());
|
|
23
|
+
if (avatar)
|
|
24
|
+
return avatar.region === ctx.linkset.region;
|
|
25
|
+
if (agent === ctx.linkset.owner.toLowerCase())
|
|
26
|
+
return true;
|
|
27
|
+
return ctx.state.detectedStack.at(-1)?.entries.some(e => e.key.toLowerCase() === agent && ((e.type ?? 1) & 1) !== 0) ?? false;
|
|
28
|
+
}
|
|
29
|
+
export function isKey(key) {
|
|
30
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(key);
|
|
31
|
+
}
|
|
32
|
+
export const llLoadURL = (ctx, args) => {
|
|
33
|
+
const agent = args[0].toLowerCase();
|
|
34
|
+
const message = truncateUtf8(args[1], 255);
|
|
35
|
+
const url = truncateUtf8(args[2], 255);
|
|
36
|
+
if (!isAgentInRegion(ctx, agent))
|
|
37
|
+
sayError(ctx, 'llLoadURL - cannot find avatar');
|
|
38
|
+
else if (!url.startsWith('http://') && !url.startsWith('https://'))
|
|
39
|
+
sayError(ctx, 'llLoadURL - invalid or unsupported scheme.');
|
|
40
|
+
else
|
|
41
|
+
ctx.state.viewerRequests.push({ kind: 'loadURL', agent, message, url });
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
function mapAgent(ctx) {
|
|
45
|
+
const detected = ctx.state.detectedStack.at(-1);
|
|
46
|
+
return (detected?.event?.startsWith('touch') ? (detected.entries[0]?.key ?? ctx.linkset.owner) : ctx.linkset.owner).toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
export const llMapDestination = (ctx, args) => {
|
|
49
|
+
const agent = mapAgent(ctx);
|
|
50
|
+
if (isAgentInRegion(ctx, agent))
|
|
51
|
+
ctx.state.viewerRequests.push({
|
|
52
|
+
kind: 'mapDestination', agent, region: args[0],
|
|
53
|
+
position: { ...args[1] }, lookAt: { ...args[2] },
|
|
54
|
+
});
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
export const llMapBeacon = (ctx, args) => {
|
|
58
|
+
const agent = mapAgent(ctx);
|
|
59
|
+
const options = args[2];
|
|
60
|
+
if (isAgentInRegion(ctx, agent))
|
|
61
|
+
ctx.state.viewerRequests.push({
|
|
62
|
+
kind: 'mapBeacon', agent, region: args[0],
|
|
63
|
+
position: { ...args[1] }, options: [...options],
|
|
64
|
+
});
|
|
65
|
+
return undefined;
|
|
66
|
+
};
|
|
67
|
+
/** Linden-owned privileged experiences cannot be represented by the current Experience fixture. */
|
|
68
|
+
export const llOpenFloater = (ctx, args) => {
|
|
69
|
+
const result = -1;
|
|
70
|
+
ctx.state.viewerRequests.push({ kind: 'openFloater', agent: ctx.linkset.owner,
|
|
71
|
+
floater: args[0], url: args[1], params: [...args[2]], result });
|
|
72
|
+
return result;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/builtins/viewer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AASrC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAyD,CAAA;AAEpF,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,IAAI,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAChD,IAAI,CAAC,eAAe;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC,CAAA;IAC7E,IAAI,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,IAAI,CAAC,MAAM;QAAE,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,CAAA;IACpE,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAgB,EAAE,KAAa;IAC7D,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;IAC3B,IAAI,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CA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,CAAA;IACF,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAA4B,CAAA;IAClD,IAAI,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC;QAAE,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;YAC7D,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAW;YACnD,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAW,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;SAC1D,CAAC,CAAA;IACF,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,mGAAmG;AACnG,MAAM,CAAC,MAAM,aAAa,GAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;IACtD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAA;IACjB,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK;QAC3E,OAAO,EAAE,IAAI,CAAC,CAAC,CAAW,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAW,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAA4B,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAChH,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/dist/clock.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Virtual clock + event queue.
|
|
3
3
|
*
|
|
4
4
|
* The clock is the only source of "time" in the VM. Tests advance it
|
|
5
|
-
* explicitly (`vm.advanceTime` / `linkset.advanceTime`);
|
|
6
|
-
*
|
|
7
|
-
* never read.
|
|
5
|
+
* explicitly (`vm.advanceTime` / `linkset.advanceTime`); a script in
|
|
6
|
+
* `llSleep` or a builtin delay is suspended until its wake time while the
|
|
7
|
+
* clock runs other scripts' events. Real wall-clock time is never read.
|
|
8
8
|
*
|
|
9
9
|
* The queue is **linkset-wide**, or world-wide for linksets in a `World`:
|
|
10
10
|
* every script shares one `now` and one event queue. Each queued event carries a `target: Script`
|
|
@@ -21,17 +21,27 @@ export interface QueuedEvent {
|
|
|
21
21
|
readonly event: string;
|
|
22
22
|
readonly payload: Record<string, unknown>;
|
|
23
23
|
}
|
|
24
|
+
/** Events llMinEventDelay spaces out; other events are not delayed. */
|
|
25
|
+
export declare const DELAYED_EVENTS: ReadonlySet<string>;
|
|
24
26
|
/** Events a script can hold in its queue; more are dropped, as in Second Life. */
|
|
25
27
|
export declare const MAX_PENDING_EVENTS = 64;
|
|
26
28
|
/** Linkset-wide clock. One instance per Linkset. */
|
|
27
29
|
export declare class LinksetClock {
|
|
28
30
|
readonly startUnixTime: number;
|
|
29
31
|
/** Virtual milliseconds since linkset construction. Strictly monotonic. */
|
|
30
|
-
|
|
32
|
+
private time;
|
|
33
|
+
private readonly timeListeners;
|
|
34
|
+
get now(): number;
|
|
35
|
+
set now(value: number);
|
|
36
|
+
/** Continuous simulator properties update before scripts observe the new time. */
|
|
37
|
+
onAdvance(update: (now: number) => void): () => void;
|
|
31
38
|
/** @param startUnixTime Unix time in seconds when `now` is 0. */
|
|
32
39
|
constructor(startUnixTime?: number);
|
|
33
40
|
/** Wall-clock time in microseconds since the Unix epoch, floored. */
|
|
34
41
|
unixMicros(): number;
|
|
42
|
+
private readonly tasks;
|
|
43
|
+
/** Simulator work that completes even while its script's handler sleeps. */
|
|
44
|
+
scheduleTask(target: Script, at: number, run: () => void): () => void;
|
|
35
45
|
private readonly queue;
|
|
36
46
|
/**
|
|
37
47
|
* Schedule a one-shot event on `target`'s handler at virtual time `at`.
|
|
@@ -39,28 +49,46 @@ export declare class LinksetClock {
|
|
|
39
49
|
* parked while it is stopped; further events are dropped.
|
|
40
50
|
*/
|
|
41
51
|
schedule(target: Script, at: number, event: string, payload?: Record<string, unknown>): void;
|
|
52
|
+
/** Whether `target` has a queued `event` that has not been delivered yet. */
|
|
53
|
+
hasPending(target: Script, event: string): boolean;
|
|
42
54
|
/** Move the clock forward unconditionally; does not drain queues. */
|
|
43
55
|
advance(ms: number): void;
|
|
44
56
|
/**
|
|
45
57
|
* Pop and return the next due event (`at <= horizon`, default `now`) considering all queued
|
|
46
|
-
* one-shots
|
|
47
|
-
* event is ready.
|
|
58
|
+
* one-shots, every script's recurring timer and every sleeping script's wake
|
|
59
|
+
* (a synthetic `__wake` event). Returns `null` when no event is ready. A
|
|
60
|
+
* sleeping script gets no events but `__reset` until it finishes, and wakes
|
|
61
|
+
* at its wake time or, if paused past it, on resume. At the same instant a
|
|
62
|
+
* queued event comes first, then a timer, then a wake.
|
|
48
63
|
*
|
|
49
64
|
* Recurring timers fire once per script per interval; their next fire
|
|
50
65
|
* timestamp is advanced by `at + interval` (not `now + interval`) so that
|
|
51
66
|
* long advances catch up on every missed fire. Ticks that fall due while
|
|
52
67
|
* the script is busy (e.g. in llSleep) collapse into one event delivered
|
|
53
68
|
* when it finishes, and the interval restarts from there.
|
|
69
|
+
*
|
|
70
|
+
* Under llMinEventDelay, a timer or touch_start waits until the delay since
|
|
71
|
+
* the last of them has passed, and the events queued behind it wait too.
|
|
54
72
|
*/
|
|
55
73
|
takeNextDue(scripts: ReadonlyArray<Script>, horizon?: number): QueuedEvent | null;
|
|
74
|
+
private takeNextEventOrTask;
|
|
56
75
|
/** Snapshot of the pending one-shot queue. Read-only; for inspection/tests. */
|
|
57
76
|
pendingEvents(): readonly QueuedEvent[];
|
|
77
|
+
/**
|
|
78
|
+
* Move `script`'s events that are due by now behind every other queued
|
|
79
|
+
* event, in their order. Called when a handler that took time finishes,
|
|
80
|
+
* so the events that waited for it follow other scripts' events at that
|
|
81
|
+
* instant.
|
|
82
|
+
*/
|
|
83
|
+
requeue(script: Script): void;
|
|
58
84
|
/**
|
|
59
85
|
* Remove every queued event whose target is `script` and that is due by
|
|
60
86
|
* `upTo` (default: all of them), except events named `keep`. Used on reset
|
|
61
87
|
* and state change.
|
|
62
88
|
*/
|
|
63
89
|
purgeTarget(script: Script, upTo?: number, keep?: string): void;
|
|
90
|
+
/** Remove every queued `event` whose target is `script`. */
|
|
91
|
+
purgeEvent(script: Script, event: string): void;
|
|
64
92
|
}
|
|
65
93
|
/**
|
|
66
94
|
* Per-script clock facade. Builtins read `ctx.state.clock` and call
|
|
@@ -72,21 +100,31 @@ export declare class ScriptClockView {
|
|
|
72
100
|
private readonly self;
|
|
73
101
|
/** Reference time for `llGetTime`/`llResetTime` (virtual ms); the script's creation, reset or last llResetTime. */
|
|
74
102
|
timeReferenceMs: number;
|
|
103
|
+
/** Monotonic completed-handler count used to bound synchronous settling. */
|
|
104
|
+
completedHandlers: number;
|
|
75
105
|
/** Recurring timer interval in ms; 0 = no timer. */
|
|
76
106
|
timerIntervalMs: number;
|
|
77
107
|
/** Virtual time at which the next timer event fires. */
|
|
78
108
|
timerNextFireMs: number;
|
|
79
109
|
/** Virtual time at which the script's last handler finished, when it took time (llSleep, delays). */
|
|
80
110
|
busyUntilMs: number;
|
|
111
|
+
/** llMinEventDelay in ms; 0 = none. */
|
|
112
|
+
minEventDelayMs: number;
|
|
113
|
+
/** Earliest virtual time the next timer or touch_start may start, under llMinEventDelay. */
|
|
114
|
+
delayedUntilMs: number;
|
|
81
115
|
constructor(linksetClock: LinksetClock, self: () => Script);
|
|
82
116
|
get now(): number;
|
|
83
117
|
/** Schedule a one-shot event on this script. */
|
|
84
118
|
schedule(at: number, event: string, payload?: Record<string, unknown>): void;
|
|
85
119
|
/** Schedule a one-shot event on a specific script. */
|
|
86
120
|
scheduleOn(target: Script, at: number, event: string, payload?: Record<string, unknown>): void;
|
|
121
|
+
/** A reset chain finishes when its replacement state_entry finishes. */
|
|
122
|
+
finishHandler(restarting: boolean): void;
|
|
87
123
|
cancelTimer(): void;
|
|
88
124
|
setTimer(intervalMs: number): void;
|
|
89
|
-
/**
|
|
125
|
+
/** llMinEventDelay: `ms` below 0 counts as 0, and the delay starts now. */
|
|
126
|
+
setMinEventDelay(ms: number): void;
|
|
127
|
+
/** Advances the linkset clock. */
|
|
90
128
|
advance(ms: number): void;
|
|
91
129
|
/** Wall-clock time in microseconds since the Unix epoch, floored. */
|
|
92
130
|
unixMicros(): number;
|
package/dist/clock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAED,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC,oDAAoD;AACpD,qBAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CA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CAEjG;IAED,wEAAwE;IACxE,aAAa,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAEvC;IAED,WAAW,IAAI,IAAI,CAGlB;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAOjC;IAED,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAGjC;IAED,kCAAkC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAExB;IAED,qEAAqE;IACrE,UAAU,IAAI,MAAM,CAEnB;IAED,cAAc,IAAI,MAAM,CAEvB;IAED,cAAc,IAAI,IAAI,CAErB;CACF"}
|
package/dist/clock.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
/** Events llMinEventDelay spaces out; other events are not delayed. */
|
|
2
|
+
export const DELAYED_EVENTS = new Set(['timer', 'touch_start']);
|
|
1
3
|
/** Events a script can hold in its queue; more are dropped, as in Second Life. */
|
|
2
4
|
export const MAX_PENDING_EVENTS = 64;
|
|
3
5
|
/** Linkset-wide clock. One instance per Linkset. */
|
|
4
6
|
export class LinksetClock {
|
|
5
7
|
startUnixTime;
|
|
6
8
|
/** Virtual milliseconds since linkset construction. Strictly monotonic. */
|
|
7
|
-
|
|
9
|
+
time = 0;
|
|
10
|
+
timeListeners = new Set();
|
|
11
|
+
get now() { return this.time; }
|
|
12
|
+
set now(value) {
|
|
13
|
+
this.time = value;
|
|
14
|
+
for (const update of this.timeListeners)
|
|
15
|
+
update(value);
|
|
16
|
+
}
|
|
17
|
+
/** Continuous simulator properties update before scripts observe the new time. */
|
|
18
|
+
onAdvance(update) {
|
|
19
|
+
this.timeListeners.add(update);
|
|
20
|
+
return () => { this.timeListeners.delete(update); };
|
|
21
|
+
}
|
|
8
22
|
/** @param startUnixTime Unix time in seconds when `now` is 0. */
|
|
9
23
|
constructor(startUnixTime = 0) {
|
|
10
24
|
this.startUnixTime = startUnixTime;
|
|
@@ -13,6 +27,13 @@ export class LinksetClock {
|
|
|
13
27
|
unixMicros() {
|
|
14
28
|
return Math.floor(this.startUnixTime * 1e6 + this.now * 1000);
|
|
15
29
|
}
|
|
30
|
+
tasks = new Set();
|
|
31
|
+
/** Simulator work that completes even while its script's handler sleeps. */
|
|
32
|
+
scheduleTask(target, at, run) {
|
|
33
|
+
const task = { target, at, run };
|
|
34
|
+
this.tasks.add(task);
|
|
35
|
+
return () => { this.tasks.delete(task); };
|
|
36
|
+
}
|
|
16
37
|
queue = [];
|
|
17
38
|
/**
|
|
18
39
|
* Schedule a one-shot event on `target`'s handler at virtual time `at`.
|
|
@@ -30,6 +51,10 @@ export class LinksetClock {
|
|
|
30
51
|
}
|
|
31
52
|
this.queue.push({ at, target, event, payload });
|
|
32
53
|
}
|
|
54
|
+
/** Whether `target` has a queued `event` that has not been delivered yet. */
|
|
55
|
+
hasPending(target, event) {
|
|
56
|
+
return this.queue.some((e) => e.target === target && e.event === event);
|
|
57
|
+
}
|
|
33
58
|
/** Move the clock forward unconditionally; does not drain queues. */
|
|
34
59
|
advance(ms) {
|
|
35
60
|
if (ms < 0)
|
|
@@ -38,58 +63,120 @@ export class LinksetClock {
|
|
|
38
63
|
}
|
|
39
64
|
/**
|
|
40
65
|
* Pop and return the next due event (`at <= horizon`, default `now`) considering all queued
|
|
41
|
-
* one-shots
|
|
42
|
-
* event is ready.
|
|
66
|
+
* one-shots, every script's recurring timer and every sleeping script's wake
|
|
67
|
+
* (a synthetic `__wake` event). Returns `null` when no event is ready. A
|
|
68
|
+
* sleeping script gets no events but `__reset` until it finishes, and wakes
|
|
69
|
+
* at its wake time or, if paused past it, on resume. At the same instant a
|
|
70
|
+
* queued event comes first, then a timer, then a wake.
|
|
43
71
|
*
|
|
44
72
|
* Recurring timers fire once per script per interval; their next fire
|
|
45
73
|
* timestamp is advanced by `at + interval` (not `now + interval`) so that
|
|
46
74
|
* long advances catch up on every missed fire. Ticks that fall due while
|
|
47
75
|
* the script is busy (e.g. in llSleep) collapse into one event delivered
|
|
48
76
|
* when it finishes, and the interval restarts from there.
|
|
77
|
+
*
|
|
78
|
+
* Under llMinEventDelay, a timer or touch_start waits until the delay since
|
|
79
|
+
* the last of them has passed, and the events queued behind it wait too.
|
|
49
80
|
*/
|
|
50
81
|
takeNextDue(scripts, horizon = this.now) {
|
|
82
|
+
for (;;) {
|
|
83
|
+
const next = this.takeNextEventOrTask(scripts, horizon);
|
|
84
|
+
if (next !== 'task')
|
|
85
|
+
return next;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
takeNextEventOrTask(scripts, horizon) {
|
|
89
|
+
const heldFrom = new Map();
|
|
90
|
+
for (let i = 0; i < this.queue.length; i++) {
|
|
91
|
+
const e = this.queue[i];
|
|
92
|
+
if (DELAYED_EVENTS.has(e.event) && e.target.clockView.delayedUntilMs > e.at && !heldFrom.has(e.target)) {
|
|
93
|
+
heldFrom.set(e.target, i);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
51
96
|
let bestIdx = -1;
|
|
52
97
|
let bestAt = Infinity;
|
|
53
98
|
for (let i = 0; i < this.queue.length; i++) {
|
|
54
99
|
const e = this.queue[i];
|
|
55
|
-
|
|
56
|
-
|
|
100
|
+
const v = e.target.clockView;
|
|
101
|
+
// An event that waited for its target's handler is due when that handler finished.
|
|
102
|
+
let due = Math.max(e.at, v.busyUntilMs);
|
|
103
|
+
if (e.event !== '__reset' && i >= (heldFrom.get(e.target) ?? Infinity))
|
|
104
|
+
due = Math.max(due, v.delayedUntilMs);
|
|
105
|
+
if (due <= horizon && due < bestAt && (e.event === '__reset' || e.target.wakeAt === undefined)) {
|
|
106
|
+
bestAt = due;
|
|
57
107
|
bestIdx = i;
|
|
58
108
|
}
|
|
59
109
|
}
|
|
60
110
|
let bestTimerScript = null;
|
|
61
111
|
let bestTimerAt = Infinity;
|
|
112
|
+
let waking = null;
|
|
113
|
+
let wakeAt = Infinity;
|
|
62
114
|
for (const s of scripts) {
|
|
63
115
|
// Per LSL: dead and stopped scripts don't generate timer events. Skip
|
|
64
116
|
// their timer state so we don't waste catch-up iterations or accumulate
|
|
65
117
|
// back-logged events that flood the script on resume.
|
|
66
118
|
if (s.dead || !s.running)
|
|
67
119
|
continue;
|
|
120
|
+
const w = s.wakeAt === undefined ? undefined : Math.max(s.wakeAt, this.now);
|
|
121
|
+
if (w !== undefined) {
|
|
122
|
+
if (w <= horizon && w < wakeAt) {
|
|
123
|
+
wakeAt = w;
|
|
124
|
+
waking = s;
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
68
128
|
const v = s.clockView;
|
|
69
129
|
if (v.timerIntervalMs > 0 && v.timerNextFireMs <= horizon) {
|
|
70
|
-
const due = Math.max(v.timerNextFireMs, v.busyUntilMs);
|
|
71
|
-
if (due < bestTimerAt) {
|
|
130
|
+
const due = Math.max(v.timerNextFireMs, v.busyUntilMs, v.delayedUntilMs);
|
|
131
|
+
if (due <= horizon && due < bestTimerAt) {
|
|
72
132
|
bestTimerAt = due;
|
|
73
133
|
bestTimerScript = s;
|
|
74
134
|
}
|
|
75
135
|
}
|
|
76
136
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
137
|
+
let task;
|
|
138
|
+
for (const candidate of this.tasks) {
|
|
139
|
+
if (candidate.target.dead) {
|
|
140
|
+
this.tasks.delete(candidate);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (candidate.at <= horizon && (!task || candidate.at < task.at))
|
|
144
|
+
task = candidate;
|
|
145
|
+
}
|
|
146
|
+
if (task && task.at <= Math.min(bestAt, bestTimerAt, wakeAt)) {
|
|
147
|
+
this.tasks.delete(task);
|
|
148
|
+
this.now = Math.max(this.now, task.at);
|
|
149
|
+
task.run();
|
|
150
|
+
return 'task';
|
|
151
|
+
}
|
|
152
|
+
if (bestIdx !== -1 && bestAt <= bestTimerAt && bestAt <= wakeAt) {
|
|
153
|
+
const ev = this.queue[bestIdx];
|
|
154
|
+
this.queue.splice(bestIdx, 1);
|
|
155
|
+
return bestAt > ev.at ? { ...ev, at: bestAt } : ev;
|
|
156
|
+
}
|
|
157
|
+
if (bestTimerScript && bestTimerAt <= wakeAt) {
|
|
80
158
|
const at = bestTimerAt;
|
|
81
159
|
const v = bestTimerScript.clockView;
|
|
82
160
|
v.timerNextFireMs = at + v.timerIntervalMs;
|
|
83
161
|
return { at, target: bestTimerScript, event: 'timer', payload: {} };
|
|
84
162
|
}
|
|
85
|
-
|
|
86
|
-
this.queue.splice(bestIdx, 1);
|
|
87
|
-
return ev;
|
|
163
|
+
return waking && { at: wakeAt, target: waking, event: '__wake', payload: {} };
|
|
88
164
|
}
|
|
89
165
|
/** Snapshot of the pending one-shot queue. Read-only; for inspection/tests. */
|
|
90
166
|
pendingEvents() {
|
|
91
167
|
return this.queue.slice();
|
|
92
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Move `script`'s events that are due by now behind every other queued
|
|
171
|
+
* event, in their order. Called when a handler that took time finishes,
|
|
172
|
+
* so the events that waited for it follow other scripts' events at that
|
|
173
|
+
* instant.
|
|
174
|
+
*/
|
|
175
|
+
requeue(script) {
|
|
176
|
+
const waited = this.queue.filter((e) => e.target === script && e.at <= this.now);
|
|
177
|
+
this.purgeTarget(script, this.now);
|
|
178
|
+
this.queue.push(...waited);
|
|
179
|
+
}
|
|
93
180
|
/**
|
|
94
181
|
* Remove every queued event whose target is `script` and that is due by
|
|
95
182
|
* `upTo` (default: all of them), except events named `keep`. Used on reset
|
|
@@ -102,6 +189,14 @@ export class LinksetClock {
|
|
|
102
189
|
this.queue.splice(i, 1);
|
|
103
190
|
}
|
|
104
191
|
}
|
|
192
|
+
/** Remove every queued `event` whose target is `script`. */
|
|
193
|
+
purgeEvent(script, event) {
|
|
194
|
+
for (let i = this.queue.length - 1; i >= 0; i--) {
|
|
195
|
+
const e = this.queue[i];
|
|
196
|
+
if (e.target === script && e.event === event)
|
|
197
|
+
this.queue.splice(i, 1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
105
200
|
}
|
|
106
201
|
/**
|
|
107
202
|
* Per-script clock facade. Builtins read `ctx.state.clock` and call
|
|
@@ -113,12 +208,18 @@ export class ScriptClockView {
|
|
|
113
208
|
self;
|
|
114
209
|
/** Reference time for `llGetTime`/`llResetTime` (virtual ms); the script's creation, reset or last llResetTime. */
|
|
115
210
|
timeReferenceMs;
|
|
211
|
+
/** Monotonic completed-handler count used to bound synchronous settling. */
|
|
212
|
+
completedHandlers = 0;
|
|
116
213
|
/** Recurring timer interval in ms; 0 = no timer. */
|
|
117
214
|
timerIntervalMs = 0;
|
|
118
215
|
/** Virtual time at which the next timer event fires. */
|
|
119
216
|
timerNextFireMs = 0;
|
|
120
217
|
/** Virtual time at which the script's last handler finished, when it took time (llSleep, delays). */
|
|
121
218
|
busyUntilMs = 0;
|
|
219
|
+
/** llMinEventDelay in ms; 0 = none. */
|
|
220
|
+
minEventDelayMs = 0;
|
|
221
|
+
/** Earliest virtual time the next timer or touch_start may start, under llMinEventDelay. */
|
|
222
|
+
delayedUntilMs = 0;
|
|
122
223
|
constructor(linksetClock, self) {
|
|
123
224
|
this.linksetClock = linksetClock;
|
|
124
225
|
this.self = self;
|
|
@@ -135,6 +236,11 @@ export class ScriptClockView {
|
|
|
135
236
|
scheduleOn(target, at, event, payload = {}) {
|
|
136
237
|
this.linksetClock.schedule(target, at, event, payload);
|
|
137
238
|
}
|
|
239
|
+
/** A reset chain finishes when its replacement state_entry finishes. */
|
|
240
|
+
finishHandler(restarting) {
|
|
241
|
+
if (!restarting)
|
|
242
|
+
this.completedHandlers++;
|
|
243
|
+
}
|
|
138
244
|
cancelTimer() {
|
|
139
245
|
this.timerIntervalMs = 0;
|
|
140
246
|
this.timerNextFireMs = 0;
|
|
@@ -147,7 +253,12 @@ export class ScriptClockView {
|
|
|
147
253
|
this.timerIntervalMs = intervalMs;
|
|
148
254
|
this.timerNextFireMs = this.now + intervalMs;
|
|
149
255
|
}
|
|
150
|
-
/**
|
|
256
|
+
/** llMinEventDelay: `ms` below 0 counts as 0, and the delay starts now. */
|
|
257
|
+
setMinEventDelay(ms) {
|
|
258
|
+
this.minEventDelayMs = Math.max(0, ms);
|
|
259
|
+
this.delayedUntilMs = this.now + this.minEventDelayMs;
|
|
260
|
+
}
|
|
261
|
+
/** Advances the linkset clock. */
|
|
151
262
|
advance(ms) {
|
|
152
263
|
this.linksetClock.advance(ms);
|
|
153
264
|
}
|
package/dist/clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAyBA,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEpC,oDAAoD;AACpD,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAyBA,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAA;AAEpF,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEpC,oDAAoD;AACpD,MAAM,OAAO,YAAY;IAkBF,aAAa;IAjBlC,2EAA2E;IACnE,IAAI,GAAG,CAAC,CAAA;IACC,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAA;IAEjE,IAAI,GAAG,KAAa,OAAO,IAAI,CAAC,IAAI,CAAA,CAAC,CAAC;IACtC,IAAI,GAAG,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QACjB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IACxD,CAAC;IAED,kFAAkF;IAClF,SAAS,CAAC,MAA6B;QACrC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC9B,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,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Q,CAAC,UAAkB;QACzB,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,EAAE,CAAA;YAClB,OAAM;QACR,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,UAAU,CAAA;QACjC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,GAAG,UAAU,CAAA;IAC9C,CAAC;IAED,2EAA2E;IAC3E,gBAAgB,CAAC,EAAU;QACzB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAA;IACvD,CAAC;IAED,kCAAkC;IAClC,OAAO,CAAC,EAAU;QAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;IAED,qEAAqE;IACrE,UAAU;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAA;IACvC,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;IACjD,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAA;IACjC,CAAC;CACF"}
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuiltinImpl, ScriptState } from './runtime.js';
|
|
1
|
+
import type { BuiltinImpl, Run, ScriptState } from './runtime.js';
|
|
2
2
|
import type { LslValue } from './values/types.js';
|
|
3
3
|
import type { BuiltinSpec } from './generated/functions.js';
|
|
4
4
|
import type { Script } from './script.js';
|
|
@@ -14,6 +14,7 @@ export interface DispatchContext {
|
|
|
14
14
|
*
|
|
15
15
|
* Resolution order: user mock > real built-in > generated stub > error.
|
|
16
16
|
* Every successful call (including stubs) is appended to ScriptState.calls.
|
|
17
|
+
* A builtin that sleeps or has a delay suspends the script after it returns.
|
|
17
18
|
*/
|
|
18
|
-
export declare function callBuiltin(dctx: DispatchContext, name: string, args: ReadonlyArray<LslValue>): LslValue | undefined
|
|
19
|
+
export declare function callBuiltin(dctx: DispatchContext, name: string, args: ReadonlyArray<LslValue>): Run<LslValue | undefined>;
|
|
19
20
|
//# sourceMappingURL=dispatch.d.ts.map
|