@modlock/modlock 0.1.88 → 0.1.89
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/index.js +79 -29
- package/package.json +6 -6
- package/ui.d.ts +6 -1
package/index.js
CHANGED
|
@@ -16106,23 +16106,22 @@ var Entry = class {
|
|
|
16106
16106
|
constructor(delay, run) {
|
|
16107
16107
|
this.delay = delay;
|
|
16108
16108
|
this.run = run;
|
|
16109
|
-
this.at = now === void 0 ? void 0 : now + delay;
|
|
16110
16109
|
}
|
|
16111
16110
|
delay;
|
|
16112
16111
|
run;
|
|
16113
16112
|
finished = false;
|
|
16114
|
-
/** at is the game time the entry next runs
|
|
16115
|
-
at;
|
|
16116
|
-
/**
|
|
16117
|
-
|
|
16118
|
-
this.at ??= seconds + this.delay;
|
|
16119
|
-
}
|
|
16113
|
+
/** at is the game time the entry next runs. */
|
|
16114
|
+
at = 0;
|
|
16115
|
+
/** order breaks ties in at, so timers due together run in schedule order. */
|
|
16116
|
+
order = 0;
|
|
16120
16117
|
cancel() {
|
|
16121
16118
|
this.finished = true;
|
|
16122
16119
|
}
|
|
16123
16120
|
};
|
|
16124
16121
|
var now;
|
|
16125
|
-
var
|
|
16122
|
+
var waiting2 = [];
|
|
16123
|
+
var heap = [];
|
|
16124
|
+
var scheduled = 0;
|
|
16126
16125
|
function after(seconds, fn) {
|
|
16127
16126
|
return schedule(seconds, () => {
|
|
16128
16127
|
fn();
|
|
@@ -16141,23 +16140,34 @@ function sequence(fn) {
|
|
|
16141
16140
|
}
|
|
16142
16141
|
function schedule(delay, run) {
|
|
16143
16142
|
const entry2 = new Entry(delay, run);
|
|
16144
|
-
|
|
16143
|
+
if (now === void 0) {
|
|
16144
|
+
waiting2.push(entry2);
|
|
16145
|
+
} else {
|
|
16146
|
+
push(entry2, now + delay);
|
|
16147
|
+
}
|
|
16145
16148
|
return entry2;
|
|
16146
16149
|
}
|
|
16147
16150
|
function advance(seconds) {
|
|
16148
16151
|
if (now !== void 0 && seconds < now) {
|
|
16149
16152
|
const shift = seconds - now;
|
|
16150
|
-
for (const entry2 of
|
|
16151
|
-
|
|
16152
|
-
entry2.at += shift;
|
|
16153
|
-
}
|
|
16153
|
+
for (const entry2 of heap) {
|
|
16154
|
+
entry2.at += shift;
|
|
16154
16155
|
}
|
|
16155
16156
|
}
|
|
16156
16157
|
now = seconds;
|
|
16157
|
-
|
|
16158
|
-
entry2
|
|
16158
|
+
if (waiting2.length !== 0) {
|
|
16159
|
+
for (const entry2 of waiting2) {
|
|
16160
|
+
push(entry2, seconds + entry2.delay);
|
|
16161
|
+
}
|
|
16162
|
+
waiting2 = [];
|
|
16163
|
+
}
|
|
16164
|
+
const due = [];
|
|
16165
|
+
for (let top = heap[0]; top !== void 0 && top.at <= seconds; top = heap[0]) {
|
|
16166
|
+
pop();
|
|
16167
|
+
if (!top.finished) {
|
|
16168
|
+
due.push(top);
|
|
16169
|
+
}
|
|
16159
16170
|
}
|
|
16160
|
-
const due = entries.filter((entry2) => !entry2.finished && entry2.at <= seconds).sort((a, b) => a.at - b.at);
|
|
16161
16171
|
for (const entry2 of due) {
|
|
16162
16172
|
if (entry2.finished) {
|
|
16163
16173
|
continue;
|
|
@@ -16166,20 +16176,60 @@ function advance(seconds) {
|
|
|
16166
16176
|
const wait = entry2.run();
|
|
16167
16177
|
if (wait === void 0) {
|
|
16168
16178
|
entry2.finished = true;
|
|
16169
|
-
} else {
|
|
16179
|
+
} else if (!entry2.finished) {
|
|
16170
16180
|
const next = entry2.at + wait;
|
|
16171
|
-
entry2
|
|
16181
|
+
push(entry2, next > seconds ? next : seconds + wait);
|
|
16172
16182
|
}
|
|
16173
16183
|
} catch (error) {
|
|
16174
16184
|
entry2.finished = true;
|
|
16175
16185
|
log(`timer failed: ${String(error)}`);
|
|
16176
16186
|
}
|
|
16177
16187
|
}
|
|
16178
|
-
|
|
16188
|
+
}
|
|
16189
|
+
function push(entry2, at3) {
|
|
16190
|
+
entry2.at = at3;
|
|
16191
|
+
entry2.order = scheduled++;
|
|
16192
|
+
heap.push(entry2);
|
|
16193
|
+
let index = heap.length - 1;
|
|
16194
|
+
for (; ; ) {
|
|
16195
|
+
const parent = index - 1 >> 1;
|
|
16196
|
+
const above = heap[parent];
|
|
16197
|
+
if (index === 0 || above === void 0 || !before(entry2, above)) {
|
|
16198
|
+
break;
|
|
16199
|
+
}
|
|
16200
|
+
heap[index] = above;
|
|
16201
|
+
index = parent;
|
|
16202
|
+
}
|
|
16203
|
+
heap[index] = entry2;
|
|
16204
|
+
}
|
|
16205
|
+
function pop() {
|
|
16206
|
+
const last = heap.pop();
|
|
16207
|
+
if (last === void 0 || heap.length === 0) {
|
|
16208
|
+
return;
|
|
16209
|
+
}
|
|
16210
|
+
let index = 0;
|
|
16211
|
+
for (; ; ) {
|
|
16212
|
+
let child = 2 * index + 1;
|
|
16213
|
+
let below = heap[child];
|
|
16214
|
+
const right = heap[child + 1];
|
|
16215
|
+
if (below !== void 0 && right !== void 0 && before(right, below)) {
|
|
16216
|
+
child++;
|
|
16217
|
+
below = right;
|
|
16218
|
+
}
|
|
16219
|
+
if (below === void 0 || !before(below, last)) {
|
|
16220
|
+
break;
|
|
16221
|
+
}
|
|
16222
|
+
heap[index] = below;
|
|
16223
|
+
index = child;
|
|
16224
|
+
}
|
|
16225
|
+
heap[index] = last;
|
|
16226
|
+
}
|
|
16227
|
+
function before(a, b) {
|
|
16228
|
+
return a.at < b.at || a.at === b.at && a.order < b.order;
|
|
16179
16229
|
}
|
|
16180
16230
|
|
|
16181
16231
|
// js/src/service-later.ts
|
|
16182
|
-
var
|
|
16232
|
+
var waiting3 = /* @__PURE__ */ new Map();
|
|
16183
16233
|
function callServiceLater(service3, method, payload, done, timeoutMilliseconds = 0) {
|
|
16184
16234
|
const call2 = startServiceCall(service3, method, payload, timeoutMilliseconds);
|
|
16185
16235
|
if (call2 === void 0) {
|
|
@@ -16193,14 +16243,14 @@ function callServiceLater(service3, method, payload, done, timeoutMilliseconds =
|
|
|
16193
16243
|
);
|
|
16194
16244
|
return;
|
|
16195
16245
|
}
|
|
16196
|
-
|
|
16246
|
+
waiting3.set(call2, done);
|
|
16197
16247
|
}
|
|
16198
16248
|
function endServiceCall(event) {
|
|
16199
|
-
const done =
|
|
16249
|
+
const done = waiting3.get(event.call);
|
|
16200
16250
|
if (!done) {
|
|
16201
16251
|
return;
|
|
16202
16252
|
}
|
|
16203
|
-
|
|
16253
|
+
waiting3.delete(event.call);
|
|
16204
16254
|
if (event.failure && event.failure !== "none") {
|
|
16205
16255
|
done(void 0, event.error, event.failure);
|
|
16206
16256
|
return;
|
|
@@ -16396,7 +16446,7 @@ function change(player, node, value) {
|
|
|
16396
16446
|
function tick(seconds) {
|
|
16397
16447
|
now2 = seconds;
|
|
16398
16448
|
for (const current of views.values()) {
|
|
16399
|
-
if (current.notices.
|
|
16449
|
+
if (!current.notices.some((notice) => notice.until <= now2)) {
|
|
16400
16450
|
continue;
|
|
16401
16451
|
}
|
|
16402
16452
|
current.notices = current.notices.filter((notice) => notice.until > now2);
|
|
@@ -17189,11 +17239,11 @@ function keyframes(keys, options = {}) {
|
|
|
17189
17239
|
spans.push(...line(from.value, to.value, duration, shape));
|
|
17190
17240
|
return;
|
|
17191
17241
|
}
|
|
17192
|
-
const
|
|
17242
|
+
const before2 = keys[i - 2]?.value ?? from.value;
|
|
17193
17243
|
const after2 = keys[i + 1]?.value ?? to.value;
|
|
17194
17244
|
spans.push({
|
|
17195
17245
|
duration,
|
|
17196
|
-
at: (u) => spline(
|
|
17246
|
+
at: (u) => spline(before2, from.value, to.value, after2, shape.at(u))
|
|
17197
17247
|
});
|
|
17198
17248
|
});
|
|
17199
17249
|
return spans;
|
|
@@ -19988,13 +20038,13 @@ var UpdateReply = /* @__PURE__ */ createMessageType(
|
|
|
19988
20038
|
|
|
19989
20039
|
// js/src/persist.ts
|
|
19990
20040
|
var service = "persist";
|
|
19991
|
-
var
|
|
20041
|
+
var entries = /* @__PURE__ */ new WeakMap();
|
|
19992
20042
|
var requests = 0;
|
|
19993
20043
|
function entry(player, type) {
|
|
19994
|
-
let records =
|
|
20044
|
+
let records = entries.get(player);
|
|
19995
20045
|
if (!records) {
|
|
19996
20046
|
records = /* @__PURE__ */ new Map();
|
|
19997
|
-
|
|
20047
|
+
entries.set(player, records);
|
|
19998
20048
|
}
|
|
19999
20049
|
let known2 = records.get(type);
|
|
20000
20050
|
if (!known2) {
|
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"name": "@modlock/modlock",
|
|
9
9
|
"optionalDependencies": {
|
|
10
|
-
"@modlock/darwin-arm64": "0.1.
|
|
11
|
-
"@modlock/darwin-x64": "0.1.
|
|
12
|
-
"@modlock/linux-arm64": "0.1.
|
|
13
|
-
"@modlock/linux-x64": "0.1.
|
|
14
|
-
"@modlock/win32-x64": "0.1.
|
|
10
|
+
"@modlock/darwin-arm64": "0.1.89",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.89",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.89",
|
|
13
|
+
"@modlock/linux-x64": "0.1.89",
|
|
14
|
+
"@modlock/win32-x64": "0.1.89"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"type": "module",
|
|
22
22
|
"types": "index.d.ts",
|
|
23
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.89"
|
|
24
24
|
}
|
package/ui.d.ts
CHANGED
|
@@ -537,6 +537,11 @@ export declare function press(player: Player, node: string, action?: string, pay
|
|
|
537
537
|
* the host checked it.
|
|
538
538
|
*/
|
|
539
539
|
export declare function change(player: Player, node: string, value: string | number | boolean | Wheel | undefined): void;
|
|
540
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* tick advances the clock to the frame at seconds and fades expiring notices.
|
|
542
|
+
* It redraws a player only on the frame one of their notices expires, since
|
|
543
|
+
* the renderer animates the fade itself; a frame with no expiry renders
|
|
544
|
+
* nothing.
|
|
545
|
+
*/
|
|
541
546
|
export declare function tick(seconds: number): void;
|
|
542
547
|
export {};
|