Socket
Socket
Sign inDemoInstall

@empirica/core

Package Overview
Dependencies
43
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta.1 to 1.0.0-rc.1

dist/admin-classic.cjs

453

dist/admin-classic.js

@@ -1,419 +0,36 @@

import {z as $7r8z8$z} from "zod";
import {BehaviorSubject as $7r8z8$BehaviorSubject} from "rxjs";
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $c28a976f3a596127$exports = {};
$parcel$export($c28a976f3a596127$exports, "captureLogs", () => $c28a976f3a596127$export$a3c48a6e34bb2eb9);
$parcel$export($c28a976f3a596127$exports, "mockLogging", () => $c28a976f3a596127$export$394c203869fd6992);
$parcel$export($c28a976f3a596127$exports, "stopMockLogging", () => $c28a976f3a596127$export$7f9160e76073e3f2);
$parcel$export($c28a976f3a596127$exports, "captureLogsAsync", () => $c28a976f3a596127$export$c7683502519ee876);
$parcel$export($c28a976f3a596127$exports, "levels", () => $c28a976f3a596127$export$cc32c6afed33d362);
$parcel$export($c28a976f3a596127$exports, "setLogLevel", () => $c28a976f3a596127$export$c622e99c0ce7b1c9);
$parcel$export($c28a976f3a596127$exports, "trace", () => $c28a976f3a596127$export$357889f174732d38);
$parcel$export($c28a976f3a596127$exports, "debug", () => $c28a976f3a596127$export$1c9f709888824e05);
$parcel$export($c28a976f3a596127$exports, "log", () => $c28a976f3a596127$export$bef1f36f5486a6a3);
$parcel$export($c28a976f3a596127$exports, "info", () => $c28a976f3a596127$export$a80b3bd66acc52ff);
$parcel$export($c28a976f3a596127$exports, "warn", () => $c28a976f3a596127$export$c106dd0671a0fc2d);
$parcel$export($c28a976f3a596127$exports, "error", () => $c28a976f3a596127$export$a3bc9b8ed74fc);
/* c8 ignore start */ const $c28a976f3a596127$var$isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
let $c28a976f3a596127$var$Color;
(function(Color1) {
Color1[Color1["Bold"] = 1] = "Bold";
Color1[Color1["Black"] = 30] = "Black";
Color1[Color1["Red"] = 31] = "Red";
Color1[Color1["Green"] = 32] = "Green";
Color1[Color1["Yellow"] = 33] = "Yellow";
Color1[Color1["Blue"] = 34] = "Blue";
Color1[Color1["Magenta"] = 35] = "Magenta";
Color1[Color1["Cyan"] = 36] = "Cyan";
Color1[Color1["White"] = 37] = "White";
Color1[Color1["DarkGray"] = 90] = "DarkGray";
})($c28a976f3a596127$var$Color || ($c28a976f3a596127$var$Color = {}));
class $c28a976f3a596127$var$LogsMock {
logs = [];
log(line) {
this.logs.push(line);
}
clear() {
this.logs = [];
}
}
let $c28a976f3a596127$var$logsMock;
function $c28a976f3a596127$export$a3c48a6e34bb2eb9(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
async function $c28a976f3a596127$export$c7683502519ee876(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
await cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
function $c28a976f3a596127$export$394c203869fd6992() {
if (!$c28a976f3a596127$var$logsMock) $c28a976f3a596127$var$logsMock = new $c28a976f3a596127$var$LogsMock();
return $c28a976f3a596127$var$logsMock;
}
function $c28a976f3a596127$export$7f9160e76073e3f2() {
$c28a976f3a596127$var$logsMock = undefined;
}
const $c28a976f3a596127$var$colorHex = {
[$c28a976f3a596127$var$Color.Bold]: "font-weight: bold",
[$c28a976f3a596127$var$Color.Black]: "color: #000000",
[$c28a976f3a596127$var$Color.Red]: "color: #cc0000",
[$c28a976f3a596127$var$Color.Green]: "color: #4e9a06",
[$c28a976f3a596127$var$Color.Yellow]: "color: #c4a000",
[$c28a976f3a596127$var$Color.Blue]: "color: #729fcf",
[$c28a976f3a596127$var$Color.Magenta]: "color: #75507b",
[$c28a976f3a596127$var$Color.Cyan]: "color: #06989a",
[$c28a976f3a596127$var$Color.White]: "color: #d3d7cf",
[$c28a976f3a596127$var$Color.DarkGray]: "color: #555753"
"use strict";
import {
Batch,
Classic,
ClassicListenersCollector,
ClassicLoader,
Context,
Game,
Player,
PlayerGame,
PlayerRound,
PlayerStage,
Round,
Stage,
classicKinds
} from "./chunk-LDQGGTZP.js";
import "./chunk-K4R5M4YR.js";
import "./chunk-VUXXG5C5.js";
import "./chunk-C67KEMIV.js";
import "./chunk-EOO2SMP4.js";
export {
Batch,
Classic,
ClassicListenersCollector,
ClassicLoader,
Context,
Game,
Player,
PlayerGame,
PlayerRound,
PlayerStage,
Round,
Stage,
classicKinds
};
const $c28a976f3a596127$export$cc32c6afed33d362 = {
trace: 0,
debug: 1,
log: 2,
info: 2,
warn: 3,
error: 4
};
const $c28a976f3a596127$var$reversLevels = {};
for(const key in $c28a976f3a596127$export$cc32c6afed33d362)$c28a976f3a596127$var$reversLevels[$c28a976f3a596127$export$cc32c6afed33d362[key]] = key;
let $c28a976f3a596127$var$currentLevel = 2;
function $c28a976f3a596127$export$c622e99c0ce7b1c9(level) {
const lvl = $c28a976f3a596127$export$cc32c6afed33d362[level];
if (lvl === undefined) return;
$c28a976f3a596127$var$currentLevel = lvl;
}
function $c28a976f3a596127$var$formatConsoleDate(date, level) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
const str = (hour < 10 ? "0" + hour : hour) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "." + ("00" + milliseconds).slice(-3);
if ($c28a976f3a596127$var$isBrowser) {
const ts = $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
return [
ts[0] + " " + level[0],
ts[1],
level[1]
];
}
return $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
}
const $c28a976f3a596127$var$createLogger = (lvl, level)=>{
return (...args)=>{
if (lvl < $c28a976f3a596127$var$currentLevel) return;
if ($c28a976f3a596127$var$logsMock) {
$c28a976f3a596127$var$logsMock.log({
level: $c28a976f3a596127$var$reversLevels[lvl],
args: args
});
return;
}
console.log(...$c28a976f3a596127$var$formatConsoleDate(new Date(), level).concat(args));
};
};
function $c28a976f3a596127$var$colorize(s, ...cc) {
if ($c28a976f3a596127$var$isBrowser) {
const attr = [];
for (const c of cc)attr.push($c28a976f3a596127$var$colorHex[c]);
return [
`%c${s}`,
attr.join("; ")
];
}
let out = "";
for (const c of cc)out += `\x1b[${c}m`;
out += `${s}\x1b[0m`;
return [
out
];
}
const $c28a976f3a596127$export$357889f174732d38 = $c28a976f3a596127$var$createLogger(0, $c28a976f3a596127$var$colorize("TRC", $c28a976f3a596127$var$Color.Magenta));
const $c28a976f3a596127$export$1c9f709888824e05 = $c28a976f3a596127$var$createLogger(1, $c28a976f3a596127$var$colorize("DBG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$bef1f36f5486a6a3 = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("LOG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$a80b3bd66acc52ff = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("INF", $c28a976f3a596127$var$Color.Green));
const $c28a976f3a596127$export$c106dd0671a0fc2d = $c28a976f3a596127$var$createLogger(3, $c28a976f3a596127$var$colorize("WRN", $c28a976f3a596127$var$Color.Cyan));
const $c28a976f3a596127$export$a3bc9b8ed74fc = $c28a976f3a596127$var$createLogger(4, $c28a976f3a596127$var$colorize("ERR", $c28a976f3a596127$var$Color.Red, $c28a976f3a596127$var$Color.Bold)); // export {
// trace,
// debug,
// log,
// info,
// warn,
// error,
// };
// export function warn(...args: string[]) {}
class $b1aa8155cc096fb6$export$8546186883d6ff3e {
constructor(scopesObs, donesObs, ctx, kinds, attributes){
this.ctx = ctx;
this.kinds = kinds;
this.attributes = attributes;
this.scopes = new Map();
this.scopesByKind = new Map();
this.kindUpdated = new Set();
scopesObs.subscribe({
next: ({ scope: scope , removed: removed })=>{
this.update(scope, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
scope(id) {
return this.scopes.get(id)?.getValue();
}
scopeObs(id) {
return this.scopes.get(id);
}
byKind(kind) {
let map = this.scopesByKind.get(kind);
if (!map) {
map = new Map();
this.scopesByKind.set(kind, map);
}
return map;
}
kindWasUpdated(kind) {
return this.kindUpdated.has(kind);
}
next() {
this.kindUpdated.clear();
for (const [_, scopeSubject] of this.scopes){
const scope = scopeSubject.getValue();
if (scope._updated || this.attributes.scopeWasUpdated(scope.id)) {
scope._updated = false;
scopeSubject.next(scope);
}
}
}
update(scope, removed) {
const existing = this.scopes.get(scope.id)?.getValue();
if (removed) {
if (!existing) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: missing scope on removal");
return;
}
existing._deleted = true;
existing._updated = true;
this.scopes.delete(scope.id);
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope on removal");
return;
}
const kind = scope.kind;
// Using ! because scopes by kind must exist, since this scope was found.
this.scopesByKind.get(kind).delete(scope.id);
this.kindUpdated.add(kind);
return;
}
if (existing) {
existing._deleted = false;
return;
}
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope");
return;
}
const kind = scope.kind;
const scopeClass = this.kinds[kind];
if (!scopeClass) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)(`scopes: unknown scope kind: ${scope.kind}`);
return;
}
const obj = this.create(scopeClass, scope);
const subj = new (0, $7r8z8$BehaviorSubject)(obj);
this.scopes.set(scope.id, subj);
let skm = this.scopesByKind.get(kind);
if (!skm) {
skm = new Map();
this.scopesByKind.set(kind, skm);
}
skm.set(scope.id, obj);
obj._updated = true;
this.kindUpdated.add(kind);
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes);
}
}
class $b1aa8155cc096fb6$export$775b6bb06e53a214 {
constructor(ctx, scope, scopes, attributes){
this.ctx = ctx;
this.scope = scope;
this.scopes = scopes;
this.attributes = attributes;
this._deleted = false;
this._updated = false;
}
get id() {
return this.scope.id;
}
get kind() {
// Using ! because we don't allow scopes without kind
return this.scope.kind;
}
get(key) {
return this.attributes.attribute(this.scope.id, key).value;
}
obs(key) {
return this.attributes.attribute(this.scope.id, key).obs;
}
set(key, value, ao) {
return this.attributes.attribute(this.scope.id, key).set(value, ao);
}
scopeByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.scopes.scope(id);
}
hasUpdated() {
return this._updated || this.attributes.scopeWasUpdated(this.id);
}
}
const $8f0ff0943640d18a$var$stringArray = (0, $7r8z8$z).string().array();
const $8f0ff0943640d18a$var$string = (0, $7r8z8$z).string();
function $8f0ff0943640d18a$export$26dca5657e22ec71(subs) {
subs.on("start", function(ctx) {
ctx.scopeSub({
kinds: [
"Batch"
]
});
ctx.participantsSub();
});
subs.on("batch", "gameIDs", function(ctx, { gameIDs: gameIDs }) {
ctx.scopeSub({
ids: $8f0ff0943640d18a$var$stringArray.parse(gameIDs)
});
});
subs.on("game", "playerIDs", function(ctx, { playerIDs: playerIDs }) {
ctx.scopeSub({
ids: $8f0ff0943640d18a$var$stringArray.parse(playerIDs)
});
});
subs.on("game", "stageIDs", function(ctx, { stageIDs: stageIDs }) {
ctx.scopeSub({
ids: $8f0ff0943640d18a$var$stringArray.parse(stageIDs)
});
});
subs.on("stage", "roundID", function(ctx, { roundID: roundID }) {
ctx.scopeSub({
ids: [
$8f0ff0943640d18a$var$string.parse(roundID)
]
});
});
subs.on("stage", "roundID", function(ctx, { roundID: roundID }) {
ctx.scopeSub({
ids: [
$8f0ff0943640d18a$var$string.parse(roundID)
]
});
});
subs.on("stage", "timerID", function(ctx, { timerID: timerID }) {
ctx.transitionsSub(timerID);
});
subs.on("player", "playerGameID*", function(ctx, { playerGameID: playerGameID }) {
ctx.scopeSub({
ids: [
$8f0ff0943640d18a$var$string.parse(playerGameID)
]
});
});
subs.on("player", "playerRoundID*", function(ctx, { playerRoundID: playerRoundID }) {
ctx.scopeSub({
ids: [
$8f0ff0943640d18a$var$string.parse(playerRoundID)
]
});
});
subs.on("player", "playerStageID*", function(ctx, { playerStageID: playerStageID }) {
ctx.scopeSub({
ids: [
$8f0ff0943640d18a$var$string.parse(playerStageID)
]
});
});
}
class $8f0ff0943640d18a$export$33b107562567fc47 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
}
class $8f0ff0943640d18a$export$985739bfa5723e08 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
get stage() {
return this.scopeByKey("stageID");
}
get round() {
return this.stage?.round;
}
}
class $8f0ff0943640d18a$export$2616165974278734 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
get game() {
const { game: game } = this.ctx;
if (!game) return;
const key = `playerGameID-${game.id}`;
return this.scopeByKey(key);
}
get round() {
const { stage: stage } = this.ctx;
if (!stage) return;
const { round: round } = stage;
if (!round) return;
const key = `playerRoundID-${round.id}`;
return this.scopeByKey(key);
}
get stage() {
const { stage: stage } = this.ctx;
if (!stage) return;
const key = `playerStageID-${stage.id}`;
return this.scopeByKey(key);
}
hasUpdated() {
if (super.hasUpdated()) return true;
return Boolean(this.round?.hasUpdated() || this.stage?.hasUpdated() || this.game?.hasUpdated());
}
}
class $8f0ff0943640d18a$export$82841d2a59838c0a extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
}
class $8f0ff0943640d18a$export$a108a2b722838976 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
}
class $8f0ff0943640d18a$export$a613b4df4b6a4e3a extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
}
class $8f0ff0943640d18a$export$c5ed3eef16c0612f extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
}
class $8f0ff0943640d18a$export$208cd1682bd0e4b6 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
get round() {
return this.scopeByKey("roundID");
}
}
// TODO update context
class $8f0ff0943640d18a$var$Context {
}
const $8f0ff0943640d18a$export$44a4c3ea8e6f9c8a = {
batch: $8f0ff0943640d18a$export$33b107562567fc47,
game: $8f0ff0943640d18a$export$985739bfa5723e08,
player: $8f0ff0943640d18a$export$2616165974278734,
playerGame: $8f0ff0943640d18a$export$82841d2a59838c0a,
playerRound: $8f0ff0943640d18a$export$a108a2b722838976,
playerStage: $8f0ff0943640d18a$export$a613b4df4b6a4e3a,
round: $8f0ff0943640d18a$export$c5ed3eef16c0612f,
stage: $8f0ff0943640d18a$export$208cd1682bd0e4b6
};
export {$8f0ff0943640d18a$export$33b107562567fc47 as Batch, $8f0ff0943640d18a$export$26dca5657e22ec71 as ClassicLoader, $8f0ff0943640d18a$export$985739bfa5723e08 as Game, $8f0ff0943640d18a$export$2616165974278734 as Player, $8f0ff0943640d18a$export$82841d2a59838c0a as PlayerGame, $8f0ff0943640d18a$export$a108a2b722838976 as PlayerRound, $8f0ff0943640d18a$export$a613b4df4b6a4e3a as PlayerStage, $8f0ff0943640d18a$export$c5ed3eef16c0612f as Round, $8f0ff0943640d18a$export$208cd1682bd0e4b6 as Stage, $8f0ff0943640d18a$export$44a4c3ea8e6f9c8a as classicKinds};
//# sourceMappingURL=admin-classic.js.map
//# sourceMappingURL=admin-classic.js.map

@@ -1,1216 +0,52 @@

import {BehaviorSubject as $aNx9N$BehaviorSubject, Subject as $aNx9N$Subject, merge as $aNx9N$merge} from "rxjs";
import {Tajriba as $aNx9N$Tajriba, EventType as $aNx9N$EventType} from "@empirica/tajriba";
import $aNx9N$fspromises from "fs/promises";
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $c28a976f3a596127$exports = {};
$parcel$export($c28a976f3a596127$exports, "captureLogs", () => $c28a976f3a596127$export$a3c48a6e34bb2eb9);
$parcel$export($c28a976f3a596127$exports, "mockLogging", () => $c28a976f3a596127$export$394c203869fd6992);
$parcel$export($c28a976f3a596127$exports, "stopMockLogging", () => $c28a976f3a596127$export$7f9160e76073e3f2);
$parcel$export($c28a976f3a596127$exports, "captureLogsAsync", () => $c28a976f3a596127$export$c7683502519ee876);
$parcel$export($c28a976f3a596127$exports, "levels", () => $c28a976f3a596127$export$cc32c6afed33d362);
$parcel$export($c28a976f3a596127$exports, "setLogLevel", () => $c28a976f3a596127$export$c622e99c0ce7b1c9);
$parcel$export($c28a976f3a596127$exports, "trace", () => $c28a976f3a596127$export$357889f174732d38);
$parcel$export($c28a976f3a596127$exports, "debug", () => $c28a976f3a596127$export$1c9f709888824e05);
$parcel$export($c28a976f3a596127$exports, "log", () => $c28a976f3a596127$export$bef1f36f5486a6a3);
$parcel$export($c28a976f3a596127$exports, "info", () => $c28a976f3a596127$export$a80b3bd66acc52ff);
$parcel$export($c28a976f3a596127$exports, "warn", () => $c28a976f3a596127$export$c106dd0671a0fc2d);
$parcel$export($c28a976f3a596127$exports, "error", () => $c28a976f3a596127$export$a3bc9b8ed74fc);
/* c8 ignore start */ const $c28a976f3a596127$var$isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
let $c28a976f3a596127$var$Color;
(function(Color1) {
Color1[Color1["Bold"] = 1] = "Bold";
Color1[Color1["Black"] = 30] = "Black";
Color1[Color1["Red"] = 31] = "Red";
Color1[Color1["Green"] = 32] = "Green";
Color1[Color1["Yellow"] = 33] = "Yellow";
Color1[Color1["Blue"] = 34] = "Blue";
Color1[Color1["Magenta"] = 35] = "Magenta";
Color1[Color1["Cyan"] = 36] = "Cyan";
Color1[Color1["White"] = 37] = "White";
Color1[Color1["DarkGray"] = 90] = "DarkGray";
})($c28a976f3a596127$var$Color || ($c28a976f3a596127$var$Color = {}));
class $c28a976f3a596127$var$LogsMock {
logs = [];
log(line) {
this.logs.push(line);
}
clear() {
this.logs = [];
}
}
let $c28a976f3a596127$var$logsMock;
function $c28a976f3a596127$export$a3c48a6e34bb2eb9(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
async function $c28a976f3a596127$export$c7683502519ee876(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
await cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
function $c28a976f3a596127$export$394c203869fd6992() {
if (!$c28a976f3a596127$var$logsMock) $c28a976f3a596127$var$logsMock = new $c28a976f3a596127$var$LogsMock();
return $c28a976f3a596127$var$logsMock;
}
function $c28a976f3a596127$export$7f9160e76073e3f2() {
$c28a976f3a596127$var$logsMock = undefined;
}
const $c28a976f3a596127$var$colorHex = {
[$c28a976f3a596127$var$Color.Bold]: "font-weight: bold",
[$c28a976f3a596127$var$Color.Black]: "color: #000000",
[$c28a976f3a596127$var$Color.Red]: "color: #cc0000",
[$c28a976f3a596127$var$Color.Green]: "color: #4e9a06",
[$c28a976f3a596127$var$Color.Yellow]: "color: #c4a000",
[$c28a976f3a596127$var$Color.Blue]: "color: #729fcf",
[$c28a976f3a596127$var$Color.Magenta]: "color: #75507b",
[$c28a976f3a596127$var$Color.Cyan]: "color: #06989a",
[$c28a976f3a596127$var$Color.White]: "color: #d3d7cf",
[$c28a976f3a596127$var$Color.DarkGray]: "color: #555753"
"use strict";
import {
AdminContext,
FileTokenStorage,
Runloop,
TokenProvider
} from "./chunk-GYQJPRUA.js";
import {
AdminConnection,
Attributes,
Layer,
Subscriptions,
participantsSub,
transitionsSub
} from "./chunk-R47C3NOF.js";
import {
EventContext,
ListenersCollector,
Scope,
Scopes,
TajribaEvent
} from "./chunk-K4R5M4YR.js";
import {
Attribute
} from "./chunk-YMBME4LM.js";
import "./chunk-VUXXG5C5.js";
import {
TajribaConnection
} from "./chunk-ATJ54KNM.js";
import "./chunk-C67KEMIV.js";
import "./chunk-XXEIUXU2.js";
import "./chunk-EOO2SMP4.js";
export {
AdminConnection,
AdminContext,
Attribute,
Attributes,
EventContext,
FileTokenStorage,
Layer,
ListenersCollector,
Runloop,
Scope,
Scopes,
Subscriptions,
TajribaConnection,
TajribaEvent,
TokenProvider,
participantsSub,
transitionsSub
};
const $c28a976f3a596127$export$cc32c6afed33d362 = {
trace: 0,
debug: 1,
log: 2,
info: 2,
warn: 3,
error: 4
};
const $c28a976f3a596127$var$reversLevels = {};
for(const key in $c28a976f3a596127$export$cc32c6afed33d362)$c28a976f3a596127$var$reversLevels[$c28a976f3a596127$export$cc32c6afed33d362[key]] = key;
let $c28a976f3a596127$var$currentLevel = 2;
function $c28a976f3a596127$export$c622e99c0ce7b1c9(level) {
const lvl = $c28a976f3a596127$export$cc32c6afed33d362[level];
if (lvl === undefined) return;
$c28a976f3a596127$var$currentLevel = lvl;
}
function $c28a976f3a596127$var$formatConsoleDate(date, level) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
const str = (hour < 10 ? "0" + hour : hour) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "." + ("00" + milliseconds).slice(-3);
if ($c28a976f3a596127$var$isBrowser) {
const ts = $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
return [
ts[0] + " " + level[0],
ts[1],
level[1]
];
}
return $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
}
const $c28a976f3a596127$var$createLogger = (lvl, level)=>{
return (...args)=>{
if (lvl < $c28a976f3a596127$var$currentLevel) return;
if ($c28a976f3a596127$var$logsMock) {
$c28a976f3a596127$var$logsMock.log({
level: $c28a976f3a596127$var$reversLevels[lvl],
args: args
});
return;
}
console.log(...$c28a976f3a596127$var$formatConsoleDate(new Date(), level).concat(args));
};
};
function $c28a976f3a596127$var$colorize(s, ...cc) {
if ($c28a976f3a596127$var$isBrowser) {
const attr = [];
for (const c of cc)attr.push($c28a976f3a596127$var$colorHex[c]);
return [
`%c${s}`,
attr.join("; ")
];
}
let out = "";
for (const c of cc)out += `\x1b[${c}m`;
out += `${s}\x1b[0m`;
return [
out
];
}
const $c28a976f3a596127$export$357889f174732d38 = $c28a976f3a596127$var$createLogger(0, $c28a976f3a596127$var$colorize("TRC", $c28a976f3a596127$var$Color.Magenta));
const $c28a976f3a596127$export$1c9f709888824e05 = $c28a976f3a596127$var$createLogger(1, $c28a976f3a596127$var$colorize("DBG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$bef1f36f5486a6a3 = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("LOG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$a80b3bd66acc52ff = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("INF", $c28a976f3a596127$var$Color.Green));
const $c28a976f3a596127$export$c106dd0671a0fc2d = $c28a976f3a596127$var$createLogger(3, $c28a976f3a596127$var$colorize("WRN", $c28a976f3a596127$var$Color.Cyan));
const $c28a976f3a596127$export$a3bc9b8ed74fc = $c28a976f3a596127$var$createLogger(4, $c28a976f3a596127$var$colorize("ERR", $c28a976f3a596127$var$Color.Red, $c28a976f3a596127$var$Color.Bold)); // export {
// trace,
// debug,
// log,
// info,
// warn,
// error,
// };
// export function warn(...args: string[]) {}
class $7cb1a807542520c7$export$21991851b0bb231f {
constructor(attributesObs, donesObs, setAttributes){
this.setAttributes = setAttributes;
this.attrs = new Map();
this.updates = new Map();
attributesObs.subscribe({
next: ({ attribute: attribute , removed: removed })=>{
this.update(attribute, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
attribute(scopeID, key) {
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
let attr = scopeMap.get(key);
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
return attr;
}
attributePeek(scopeID, key) {
let scopeUpdateMap = this.updates.get(scopeID);
if (scopeUpdateMap) {
const updated = scopeUpdateMap.get(key);
if (updated) {
if (typeof updated === "boolean") return;
else {
if (!updated.val) return;
else {
const attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
attr._update(updated);
return attr;
}
}
}
}
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) return;
let attr = scopeMap.get(key);
if (!attr) return;
if (attr.value === undefined) return;
return attr;
}
nextAttributeValue(scopeID, key) {
const attr = this.attributePeek(scopeID, key);
if (!attr) return;
return attr.value;
}
update(attr, removed) {
let nodeID = attr.nodeID;
if (!nodeID) {
if (!attr.node?.id) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`new attribute without node ID`);
return;
}
nodeID = attr.node.id;
}
let scopeMap = this.updates.get(nodeID);
if (!scopeMap) {
scopeMap = new Map();
this.updates.set(nodeID, scopeMap);
}
if (removed) scopeMap.set(attr.key, true);
else scopeMap.set(attr.key, attr);
}
scopeWasUpdated(scopeID) {
if (!scopeID) return false;
return this.updates.has(scopeID);
}
next() {
for (const [scopeID, attrs] of this.updates){
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
for (const [key, attrOrDel] of attrs){
let attr = scopeMap.get(key);
if (typeof attrOrDel === "boolean") {
if (attr) attr._update(undefined);
} else {
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
attr._update(attrOrDel);
}
}
}
this.updates.clear();
}
}
class $7cb1a807542520c7$export$ab9c25261cd8c720 {
constructor(setAttributes, scopeID, key){
this.setAttributes = setAttributes;
this.scopeID = scopeID;
this.key = key;
this.val = new (0, $aNx9N$BehaviorSubject)(undefined);
}
get obs() {
return this.val;
}
get value() {
return this.val.getValue();
}
get nodeID() {
return this.attr?.nodeID || this.attr?.node?.id;
}
set(value, ao) {
this.val.next(value);
const attrProps = {
key: this.key,
nodeID: this.scopeID,
val: JSON.stringify(value)
};
if (ao) {
// TODO Fix this. Should check if compatible with existing attribute and
// only set fields set on ao.
attrProps.private = ao.private;
attrProps.protected = ao.protected;
attrProps.immutable = ao.immutable;
attrProps.append = ao.append;
attrProps.vector = ao.vector;
attrProps.index = ao.index;
}
this.setAttributes([
attrProps
]);
}
// internal only
_update(attr) {
if (attr && this.attr && this.attr.id === attr.id) return;
this.attr = attr;
let value = undefined;
if (this.attr?.val) value = JSON.parse(this.attr.val);
this.val.next(value);
}
}
class $b1aa8155cc096fb6$export$8546186883d6ff3e {
constructor(scopesObs, donesObs, ctx, kinds, attributes){
this.ctx = ctx;
this.kinds = kinds;
this.attributes = attributes;
this.scopes = new Map();
this.scopesByKind = new Map();
this.kindUpdated = new Set();
scopesObs.subscribe({
next: ({ scope: scope , removed: removed })=>{
this.update(scope, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
scope(id) {
return this.scopes.get(id)?.getValue();
}
scopeObs(id) {
return this.scopes.get(id);
}
byKind(kind) {
let map = this.scopesByKind.get(kind);
if (!map) {
map = new Map();
this.scopesByKind.set(kind, map);
}
return map;
}
kindWasUpdated(kind) {
return this.kindUpdated.has(kind);
}
next() {
this.kindUpdated.clear();
for (const [_, scopeSubject] of this.scopes){
const scope = scopeSubject.getValue();
if (scope._updated || this.attributes.scopeWasUpdated(scope.id)) {
scope._updated = false;
scopeSubject.next(scope);
}
}
}
update(scope, removed) {
const existing = this.scopes.get(scope.id)?.getValue();
if (removed) {
if (!existing) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: missing scope on removal");
return;
}
existing._deleted = true;
existing._updated = true;
this.scopes.delete(scope.id);
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope on removal");
return;
}
const kind = scope.kind;
// Using ! because scopes by kind must exist, since this scope was found.
this.scopesByKind.get(kind).delete(scope.id);
this.kindUpdated.add(kind);
return;
}
if (existing) {
existing._deleted = false;
return;
}
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope");
return;
}
const kind = scope.kind;
const scopeClass = this.kinds[kind];
if (!scopeClass) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)(`scopes: unknown scope kind: ${scope.kind}`);
return;
}
const obj = this.create(scopeClass, scope);
const subj = new (0, $aNx9N$BehaviorSubject)(obj);
this.scopes.set(scope.id, subj);
let skm = this.scopesByKind.get(kind);
if (!skm) {
skm = new Map();
this.scopesByKind.set(kind, skm);
}
skm.set(scope.id, obj);
obj._updated = true;
this.kindUpdated.add(kind);
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes);
}
}
class $b1aa8155cc096fb6$export$775b6bb06e53a214 {
constructor(ctx, scope, scopes, attributes){
this.ctx = ctx;
this.scope = scope;
this.scopes = scopes;
this.attributes = attributes;
this._deleted = false;
this._updated = false;
}
get id() {
return this.scope.id;
}
get kind() {
// Using ! because we don't allow scopes without kind
return this.scope.kind;
}
get(key) {
return this.attributes.attribute(this.scope.id, key).value;
}
obs(key) {
return this.attributes.attribute(this.scope.id, key).obs;
}
set(key, value, ao) {
return this.attributes.attribute(this.scope.id, key).set(value, ao);
}
scopeByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.scopes.scope(id);
}
hasUpdated() {
return this._updated || this.attributes.scopeWasUpdated(this.id);
}
}
class $61a8a9a225514e43$export$21991851b0bb231f extends (0, $7cb1a807542520c7$export$21991851b0bb231f) {
attribSubs = new Map();
subscribeAttribute(kind, key) {
if (!this.attribSubs.has(kind)) this.attribSubs.set(kind, new Map());
const keyMap = this.attribSubs.get(kind);
if (!keyMap.has(key)) keyMap.set(key, new (0, $aNx9N$Subject)());
return keyMap.get(key);
}
next() {
const byKind = new Map();
for (const [_, attrs] of this.updates)for (const [_1, attr] of attrs){
if (typeof attr === "boolean") continue;
const kind = attr.node?.kind;
if (kind) {
let kindAttrs = byKind.get(kind);
if (!kindAttrs) {
kindAttrs = [];
byKind.set(kind, kindAttrs);
}
kindAttrs.push(attr);
}
}
const updates = [];
for (const [kind, attrs1] of byKind){
const keyMap = this.attribSubs.get(kind);
if (keyMap) {
for (const attr of attrs1)if (keyMap.has(attr.key)) {
// This is very difficult to reproduce in tests since this.updates
// cannot contain an AttributeChange that would satisfy this.
/* c8 ignore next 4 */ if (!attr.nodeID && !attr.node?.id) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)(`found attribute change without node ID`);
continue;
}
updates.push([
kind,
attr.key,
attr
]);
}
}
}
super.next();
for (const [kind1, key, attrChange] of updates){
// Forcing nodeID because we already tested it above.
const nodeID = attrChange.nodeID || attrChange.node.id;
// Forcing attr because we already tested it above.
const attr = this.attrs.get(nodeID).get(key);
this.attribSubs.get(kind1).get(key).next(attr);
}
}
}
function $61606e60fefae734$export$4e222d082f82ee97(init) {
return new (0, $aNx9N$BehaviorSubject)(init);
}
function $61606e60fefae734$export$33c179bfa0ebd0fa(init) {
return new (0, $aNx9N$BehaviorSubject)(init);
}
const $03a65bfb4880dee5$export$cc2f8727f07b3cfc = new Error("not connected");
class $03a65bfb4880dee5$export$ec9163c62a32ccd0 {
constructor(url){
this.url = url;
this._connected = (0, $61606e60fefae734$export$4e222d082f82ee97)(false);
this._connecting = (0, $61606e60fefae734$export$4e222d082f82ee97)(true);
this._stopped = (0, $61606e60fefae734$export$4e222d082f82ee97)(false);
this.tajriba = (0, $aNx9N$Tajriba).connect(this.url);
this._connected.next(this.tajriba.connected);
this.tajriba.on("connected", ()=>{
this._connected.next(true);
this._connecting.next(false);
});
this.tajriba.on("disconnected", ()=>{
this._connected.next(false);
this._connecting.next(true);
});
}
get connecting() {
return this._connecting;
}
get connected() {
return this._connected;
}
get stopped() {
return this._stopped;
}
async sessionParticipant(token, pident) {
if (!this._connected.getValue()) throw $03a65bfb4880dee5$export$cc2f8727f07b3cfc;
return await this.tajriba.sessionParticipant(token, pident);
}
async sessionAdmin(token) {
if (!this._connected.getValue()) throw $03a65bfb4880dee5$export$cc2f8727f07b3cfc;
return await this.tajriba.sessionAdmin(token);
}
stop() {
if (this._stopped.getValue()) return;
if (this.tajriba) {
this.tajriba.removeAllListeners("connected");
this.tajriba.removeAllListeners("disconnected");
this.tajriba.stop();
}
this._connecting.next(false);
this._connected.next(false);
this._stopped.next(true);
}
}
class $edd0a5d2ba621682$export$f5fc02ac22259d17 {
constructor(taj, tokens, resetToken){
this.resetToken = resetToken;
this._tajriba = (0, $61606e60fefae734$export$33c179bfa0ebd0fa)();
this._connected = (0, $61606e60fefae734$export$4e222d082f82ee97)(false);
this._connecting = (0, $61606e60fefae734$export$4e222d082f82ee97)(false);
this._stopped = (0, $61606e60fefae734$export$4e222d082f82ee97)(false);
let token;
let connected = false;
this.sub = (0, $aNx9N$merge)(taj.connected, tokens).subscribe({
next: async (tokenOrConnected)=>{
if (typeof tokenOrConnected === "boolean") connected = tokenOrConnected;
else token = tokenOrConnected;
if (!token || !connected) return;
if (this._connected.getValue()) return;
this._connecting.next(true);
try {
const tajAdmin = await taj.sessionAdmin(token);
this._tajriba.next(tajAdmin);
this._connected.next(true);
tajAdmin.on("connected", this._connected.next.bind(this._connected, true));
tajAdmin.on("disconnected", this._connected.next.bind(this._connected, false));
} catch (error) {
if (error !== (0, $03a65bfb4880dee5$export$cc2f8727f07b3cfc)) this.resetToken();
}
this._connecting.next(false);
}
});
}
stop() {
if (this._stopped.getValue()) return;
const taj = this._tajriba.getValue();
if (taj) {
taj.removeAllListeners("connected");
taj.removeAllListeners("disconnected");
taj.stop();
this._tajriba.next(undefined);
}
this.sub.unsubscribe();
this._connecting.next(false);
this._connected.next(false);
this._stopped.next(true);
}
get connecting() {
return this._connecting;
}
get connected() {
return this._connected;
}
get stopped() {
return this._stopped;
}
get admin() {
return this._tajriba;
}
}
let $79913bb2f688ffaa$export$d4a5061344b4c7da;
(function(TajribaEvent1) {
TajribaEvent1["TransitionAdd"] = "TRANSITION_ADD";
TajribaEvent1["ParticipantConnect"] = "PARTICIPANT_CONNECT";
TajribaEvent1["ParticipantDisconnect"] = "PARTICIPANT_DISCONNECT";
})($79913bb2f688ffaa$export$d4a5061344b4c7da || ($79913bb2f688ffaa$export$d4a5061344b4c7da = {}));
class $79913bb2f688ffaa$export$482326d055f63011 {
starts = [];
tajEvents = [];
kindEvents = [];
attributeEvents = [];
on(kindOrEvent, keyOrNodeIDOrEventOrCallback, callback) {
if (kindOrEvent === "start") {
if (callback) throw new Error("start event only accepts 2 arguments");
if (typeof keyOrNodeIDOrEventOrCallback !== "function") throw new Error("second argument expected to be a callback");
this.starts.push(keyOrNodeIDOrEventOrCallback);
return;
}
if (Object.values($79913bb2f688ffaa$export$d4a5061344b4c7da).includes(kindOrEvent)) {
if (typeof keyOrNodeIDOrEventOrCallback !== "function") throw new Error("second argument expected to be a callback");
this.tajEvents.push({
event: kindOrEvent,
callback: keyOrNodeIDOrEventOrCallback
});
return;
}
if (typeof keyOrNodeIDOrEventOrCallback === "function") this.kindEvents.push({
kind: kindOrEvent,
callback: keyOrNodeIDOrEventOrCallback
});
else {
if (typeof keyOrNodeIDOrEventOrCallback !== "string") throw new Error("second argument expected to be an attribute key");
if (typeof callback !== "function") throw new Error("third argument expected to be a callback");
this.attributeEvents.push({
kind: kindOrEvent,
key: keyOrNodeIDOrEventOrCallback,
callback: callback
});
}
}
}
class $79913bb2f688ffaa$export$4994f107c6e9cbba {
constructor(subs){
this.subs = subs;
}
scopeSub(...inputs) {
for (const input of inputs)this.subs.scopeSub(input);
}
participantsSub() {
this.subs.participantsSub();
}
transitionsSub(stepID) {
this.subs.transitionsSub(stepID);
}
}
class $63e6f642f6004e39$export$936d0764594b6eb3 {
constructor(evtctx, scope, scopesByKind, attribute, kindSubscription, attributeSubscription, participants, connections, transitions){
this.evtctx = evtctx;
this.scope = scope;
this.scopesByKind = scopesByKind;
this.attribute = attribute;
this.kindSubscription = kindSubscription;
this.attributeSubscription = attributeSubscription;
this.participants = participants;
this.connections = connections;
this.transitions = transitions;
this.listeners = new (0, $79913bb2f688ffaa$export$482326d055f63011)();
}
async start() {
for (const kindEvent of this.listeners.kindEvents)this.kindSubscription(kindEvent.kind).subscribe({
next: async (scope)=>{
kindEvent.callback(this.evtctx, {
[kindEvent.kind]: scope
});
if (this.postCallback) await this.postCallback();
}
});
for (const attributeEvent of this.listeners.attributeEvents)this.attributeSubscription(attributeEvent.kind, attributeEvent.key).subscribe({
next: async (attribute)=>{
const props = {
[attributeEvent.key]: attribute.value,
attribute: attribute
};
if (attribute.nodeID) {
const scope = this.scope(attribute.nodeID);
if (scope) props[attributeEvent.kind] = scope;
}
attributeEvent.callback(this.evtctx, props);
if (this.postCallback) await this.postCallback();
}
});
for (const tajEvent of this.listeners.tajEvents)switch(tajEvent.event){
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).TransitionAdd:
this.transitions.subscribe({
next: async (transition)=>{
tajEvent.callback(this.evtctx, {
transition: transition,
step: transition.step
});
if (this.postCallback) await this.postCallback();
}
});
break;
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).ParticipantConnect:
this.connections.subscribe({
next: async (connection)=>{
if (!connection.connected) return;
tajEvent.callback(this.evtctx, {
participant: connection.participant
});
if (this.postCallback) await this.postCallback();
}
});
break;
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).ParticipantDisconnect:
this.connections.subscribe({
next: async (connection)=>{
if (connection.connected) return;
tajEvent.callback(this.evtctx, {
participant: connection.participant
});
if (this.postCallback) await this.postCallback();
}
});
break;
// This is difficult to simulate
/* c8 ignore next 3 */ default:
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`unsupported tajriba event listener: ${tajEvent.event}`);
}
for (const start of this.listeners.starts)await start(this.evtctx);
for (const kindEvent1 of this.listeners.kindEvents)for (const [_, scope2] of this.scopesByKind(kindEvent1.kind)){
kindEvent1.callback(this.evtctx, {
[kindEvent1.kind]: scope2
});
if (this.postCallback) await this.postCallback();
}
for (const attributeEvent1 of this.listeners.attributeEvents)for (const [scopeID, scope1] of this.scopesByKind(attributeEvent1.kind)){
const attrib = this.attribute(scopeID, attributeEvent1.key);
if (!attrib) continue;
attributeEvent1.callback(this.evtctx, {
[attributeEvent1.key]: attrib.value,
attribute: attrib,
[attributeEvent1.kind]: scope1
});
if (this.postCallback) await this.postCallback();
}
for (const tajEvent1 of this.listeners.tajEvents)switch(tajEvent1.event){
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).TransitionAdd:
break;
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).ParticipantConnect:
for (const [_1, participant] of this.participants){
tajEvent1.callback(this.evtctx, {
participant: participant
});
if (this.postCallback) await this.postCallback();
}
break;
case (0, $79913bb2f688ffaa$export$d4a5061344b4c7da).ParticipantDisconnect:
break;
// This is difficult to simulate
/* c8 ignore next 3 */ default:
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`unsupported tajriba event listener: ${tajEvent1.event}`);
}
}
}
function $8fddce1377f789d4$export$7ed3a551696e57e3(taj, connections, participants) {
taj.onEvent({
eventTypes: [
(0, $aNx9N$EventType).ParticipantConnected
]
}).subscribe({
next ({ node: node }) {
if (node.__typename !== "Participant") {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`received non-participant`);
return;
}
const part = {
id: node.id,
identifier: node.identifier
};
participants.set(node.id, part);
connections.next({
participant: part,
connected: true
});
}
});
taj.onEvent({
eventTypes: [
(0, $aNx9N$EventType).ParticipantDisconnect
]
}).subscribe({
next ({ node: node }) {
if (node.__typename !== "Participant") {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`received non-participant`);
return;
}
participants.delete(node.id);
connections.next({
participant: {
id: node.id,
identifier: node.identifier
},
connected: false
});
}
});
}
class $a6e0765b60aaf0b9$export$8546186883d6ff3e extends (0, $b1aa8155cc096fb6$export$8546186883d6ff3e) {
kindSubs = new Map();
subscribeKind(kind) {
if (!this.kindSubs.has(kind)) this.kindSubs.set(kind, new (0, $aNx9N$Subject)());
return this.kindSubs.get(kind);
}
next() {
for (const [_, scopeSubject] of this.scopes){
const scope = scopeSubject.getValue();
if (scope._updated) {
const kindSub = this.kindSubs.get(scope.kind);
if (kindSub) kindSub.next(scope);
}
}
super.next();
}
}
class $5842cafed2ff8301$export$d73dcc2e0bdfb5bd {
scopeKinds = new Set();
scopeIDs = new Set();
participantSub = false;
transitionsSubs = new Set();
dirty = false;
last = {
participants: false,
scopes: {
ids: [],
kinds: []
},
transitions: []
};
get subs() {
return {
participants: this.participantSub,
scopes: {
kinds: Array.from(this.scopeKinds.values()),
ids: Array.from(this.scopeIDs.values())
},
transitions: Array.from(this.transitionsSubs.values())
};
}
// newSubs will return only new subs since the last call.
newSubs() {
if (!this.dirty) return;
const current = this.subs;
const { scopes: { ids: ids , kinds: kinds } , participants: participants , transitions: transitions , } = this.last;
const next = {
participants: this.participantSub && !participants,
scopes: {
ids: current.scopes.ids.filter((id)=>!ids.includes(id)),
kinds: current.scopes.kinds.filter((kind)=>!kinds.includes(kind))
},
transitions: current.transitions.filter((id)=>!transitions.includes(id))
};
this.last = current;
this.dirty = false;
return next;
}
scopeSub(input) {
if (input.ids) {
for (const id of input.ids)if (!this.scopeIDs.has(id)) {
this.scopeIDs.add(id);
this.dirty = true;
}
}
if (input.kinds) {
for (const id of input.kinds)if (!this.scopeKinds.has(id)) {
this.scopeKinds.add(id);
this.dirty = true;
}
}
}
participantsSub() {
if (!this.participantSub) {
this.dirty = true;
this.participantSub = true;
}
}
transitionsSub(nodeID) {
if (!this.transitionsSubs.has(nodeID)) {
this.transitionsSubs.add(nodeID);
this.dirty = true;
}
}
}
function $3de51cc809460bf8$export$9346a7e566637398(taj, transitions, nodeID) {
taj.onEvent({
eventTypes: [
(0, $aNx9N$EventType).TransitionAdd
],
nodeID: nodeID
}).subscribe({
next ({ node: node }) {
if (node.__typename !== "Transition") {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`received non-transition`);
return;
}
if (node.node.__typename !== "Step") {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`received non-step transition`);
return;
}
transitions.next({
id: node.id,
to: node.to,
from: node.from,
step: {
id: node.node.id,
duration: node.node.duration,
state: node.node.state
}
});
}
});
}
class $2b4a6e8f0be5bbdf$export$c7dd9e7942e9af20 {
constructor(conn, ctx, kinds, subs, stop){
this.conn = conn;
this.ctx = ctx;
this.kinds = kinds;
this.layers = [];
this.subs = new (0, $5842cafed2ff8301$export$d73dcc2e0bdfb5bd)();
this.participants = new Map();
this.connections = new (0, $aNx9N$Subject)();
this.transitions = new (0, $aNx9N$Subject)();
this.scopesSub = new (0, $aNx9N$Subject)();
this.attributesSub = new (0, $aNx9N$Subject)();
this.donesSub = new (0, $aNx9N$Subject)();
this.attributes = new (0, $61a8a9a225514e43$export$21991851b0bb231f)(this.attributesSub, this.donesSub, this.taj.setAttributes.bind(this.taj));
this.scopes = new (0, $a6e0765b60aaf0b9$export$8546186883d6ff3e)(this.scopesSub, this.donesSub, this.ctx, this.kinds, this.attributes);
this.evtctx = new (0, $79913bb2f688ffaa$export$4994f107c6e9cbba)(this.subs);
const subsSub = subs.subscribe({
next: async (subscriber)=>{
const layer = new (0, $63e6f642f6004e39$export$936d0764594b6eb3)(this.evtctx, this.scopes.scope.bind(this.scopes), this.scopes.byKind.bind(this.scopes), this.attributes.attributePeek.bind(this.scopes), this.scopes.subscribeKind.bind(this.scopes), this.attributes.subscribeAttribute.bind(this.attributes), this.participants, this.connections, this.transitions);
this.layers.push(layer);
subscriber(layer.listeners);
await this.initLayer(layer);
}
});
let stopSub;
stopSub = stop.subscribe({
next: ()=>{
subsSub.unsubscribe();
stopSub.unsubscribe();
}
});
}
async initLayer(layer) {
await layer.start();
// Keep loading until no more subs
while(true){
const subs = this.subs.newSubs();
if (!subs) break;
await this.processNewSub(subs);
}
layer.postCallback = async ()=>{
const subs = this.subs.newSubs();
if (subs) await this.processNewSub(subs);
};
}
async processNewScopesSub(filters) {
if (filters.length === 0) return;
let resolve;
const prom = new Promise((r)=>resolve = r);
this.taj.scopedAttributes(filters).subscribe({
next: ({ attribute: attribute , done: done })=>{
if (attribute) {
if (attribute.node.__typename !== "Scope") {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`scoped attribute with non-scope node`);
return;
}
this.attributesSub.next({
attribute: attribute,
removed: false
});
this.scopesSub.next({
scope: attribute.node,
removed: false
});
}
if (done) {
resolve(null);
this.donesSub.next();
}
}
});
await prom;
}
async processNewSub(subs) {
const filters = [];
if (subs.scopes.ids.length > 0) filters.push({
ids: subs.scopes.ids
});
if (subs.scopes.kinds.length > 0) filters.push({
kinds: subs.scopes.kinds
});
if (subs.participants) (0, $8fddce1377f789d4$export$7ed3a551696e57e3)(this.taj, this.connections, this.participants);
if (subs.transitions.length > 0) for (const id of subs.transitions)(0, $3de51cc809460bf8$export$9346a7e566637398)(this.taj, this.transitions, id);
await this.processNewScopesSub(filters);
}
get taj() {
return this.conn.admin.getValue();
}
}
class $d5a780a75ff453cb$export$e5cf4eff53e7947d {
tokens = (0, $61606e60fefae734$export$33c179bfa0ebd0fa)(undefined);
constructor(taj, storage, serviceName, serviceRegistrationToken){
let connected = false;
let token;
this.sub = (0, $aNx9N$merge)(taj.connected, storage.tokens).subscribe({
next: async (tokenOrConnected)=>{
if (typeof tokenOrConnected === "boolean") connected = tokenOrConnected;
else token = tokenOrConnected;
if (token) {
this.tokens.next(token);
return;
}
if (!connected) return;
if (token === undefined) return;
try {
const t = await taj.tajriba.registerService(serviceName, serviceRegistrationToken);
if (t) {
storage.updateToken(t);
this.tokens.next(t);
}
} catch (err) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`token: register service ${err.message}`);
return;
}
}
});
}
get token() {
return this.tokens.getValue();
}
// When stopped, cannot be restarted
stop() {
this.sub?.unsubscribe();
this.sub = undefined;
}
}
class $d5a780a75ff453cb$export$ac29d910d313ce08 {
constructor(serviceTokenFile, resetToken){
this.serviceTokenFile = serviceTokenFile;
this._tokens = (0, $61606e60fefae734$export$33c179bfa0ebd0fa)(null);
resetToken.subscribe({
next: ()=>{
this.clearToken();
}
});
}
static async init(serviceTokenFile, resetToken) {
const p = new this(serviceTokenFile, resetToken);
const token = await p.readToken();
if (token) p._tokens.next(token);
return p;
}
async readToken() {
try {
const data = await (0, $aNx9N$fspromises).readFile(this.serviceTokenFile, {
encoding: "utf8"
});
if (data.length > 0) return data;
} catch (err) {
const e = err;
if (e.code !== "ENOENT") (0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`token: read token file ${e.message}`);
}
return;
}
async writeToken(token) {
try {
await (0, $aNx9N$fspromises).writeFile(this.serviceTokenFile, token);
} catch (err) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`token: write token file ${err.message}`);
}
}
async deleteTokenFile() {
try {
await (0, $aNx9N$fspromises).unlink(this.serviceTokenFile);
} catch (err) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`token: delete token file ${err.message}`);
}
}
get tokens() {
return this._tokens;
}
get token() {
return this._tokens.getValue();
}
async updateToken(token) {
if (token === this._tokens.getValue()) return;
this._tokens.next(token);
await this.writeToken(token);
}
async clearToken() {
await this.deleteTokenFile();
if (this.token) this._tokens.next(undefined);
}
}
class $8d195e53fc634fd4$export$b4fb6f5c344ec334 {
constructor(url, ctx, kinds){
this.ctx = ctx;
this.kinds = kinds;
this.adminSubs = new (0, $aNx9N$Subject)();
this.adminStop = new (0, $aNx9N$Subject)();
this.subs = [];
this.tajriba = new (0, $03a65bfb4880dee5$export$ec9163c62a32ccd0)(url);
}
static async init(url, tokenFile, serviceName, serviceRegistrationToken, ctx, kinds) {
const adminContext = new this(url, ctx, kinds);
const reset = new (0, $aNx9N$Subject)();
const strg = await (0, $d5a780a75ff453cb$export$ac29d910d313ce08).init(tokenFile, reset);
const tp = new (0, $d5a780a75ff453cb$export$e5cf4eff53e7947d)(adminContext.tajriba, strg, serviceName, serviceRegistrationToken);
adminContext.adminConn = new (0, $edd0a5d2ba621682$export$f5fc02ac22259d17)(adminContext.tajriba, tp.tokens, reset.next.bind(reset));
adminContext.tajriba.connected.subscribe({
next: ()=>{
adminContext.initOrStop();
}
});
adminContext.adminConn.connected.subscribe({
next: ()=>{
adminContext.initOrStop();
}
});
return adminContext;
}
register(subscriber) {
this.subs.push(subscriber);
if (this.runloop) this.adminSubs.next(subscriber);
}
initOrStop() {
// Forcing this.adminConn since adminConn is always created by init().
if (this.tajriba.connected.getValue() && this.adminConn.connected.getValue()) this.initSubs();
else this.stopSubs();
}
initSubs() {
if (this.runloop) return;
/* c8 ignore next 5 */ if (!this.adminConn) {
// This condition is nearly impossible to create
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("context: admin not connected");
return;
}
this.runloop = new (0, $2b4a6e8f0be5bbdf$export$c7dd9e7942e9af20)(this.adminConn, this.ctx, this.kinds, this.adminSubs, this.adminStop);
for (const sub of this.subs)this.adminSubs.next(sub);
}
stopSubs() {
this.adminStop.next();
this.runloop = undefined;
}
}
export {$7cb1a807542520c7$export$ab9c25261cd8c720 as Attribute, $b1aa8155cc096fb6$export$775b6bb06e53a214 as Scope, $61a8a9a225514e43$export$21991851b0bb231f as Attributes, $edd0a5d2ba621682$export$f5fc02ac22259d17 as AdminConnection, $8d195e53fc634fd4$export$b4fb6f5c344ec334 as AdminContext, $79913bb2f688ffaa$export$4994f107c6e9cbba as EventContext, $79913bb2f688ffaa$export$482326d055f63011 as ListenersCollector, $79913bb2f688ffaa$export$d4a5061344b4c7da as TajribaEvent, $63e6f642f6004e39$export$936d0764594b6eb3 as Layer, $8fddce1377f789d4$export$7ed3a551696e57e3 as participantsSub, $2b4a6e8f0be5bbdf$export$c7dd9e7942e9af20 as Runloop, $a6e0765b60aaf0b9$export$8546186883d6ff3e as Scopes, $5842cafed2ff8301$export$d73dcc2e0bdfb5bd as Subscriptions, $d5a780a75ff453cb$export$ac29d910d313ce08 as FileTokenStorage, $d5a780a75ff453cb$export$e5cf4eff53e7947d as TokenProvider, $3de51cc809460bf8$export$9346a7e566637398 as transitionsSub};
//# sourceMappingURL=admin.js.map
//# sourceMappingURL=admin.js.map

@@ -1,136 +0,30 @@

/* c8 ignore start */ const $c28a976f3a596127$var$isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
let $c28a976f3a596127$var$Color;
(function(Color1) {
Color1[Color1["Bold"] = 1] = "Bold";
Color1[Color1["Black"] = 30] = "Black";
Color1[Color1["Red"] = 31] = "Red";
Color1[Color1["Green"] = 32] = "Green";
Color1[Color1["Yellow"] = 33] = "Yellow";
Color1[Color1["Blue"] = 34] = "Blue";
Color1[Color1["Magenta"] = 35] = "Magenta";
Color1[Color1["Cyan"] = 36] = "Cyan";
Color1[Color1["White"] = 37] = "White";
Color1[Color1["DarkGray"] = 90] = "DarkGray";
})($c28a976f3a596127$var$Color || ($c28a976f3a596127$var$Color = {}));
class $c28a976f3a596127$var$LogsMock {
logs = [];
log(line) {
this.logs.push(line);
}
clear() {
this.logs = [];
}
}
let $c28a976f3a596127$var$logsMock;
function $c28a976f3a596127$export$a3c48a6e34bb2eb9(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
async function $c28a976f3a596127$export$c7683502519ee876(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
await cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
function $c28a976f3a596127$export$394c203869fd6992() {
if (!$c28a976f3a596127$var$logsMock) $c28a976f3a596127$var$logsMock = new $c28a976f3a596127$var$LogsMock();
return $c28a976f3a596127$var$logsMock;
}
function $c28a976f3a596127$export$7f9160e76073e3f2() {
$c28a976f3a596127$var$logsMock = undefined;
}
const $c28a976f3a596127$var$colorHex = {
[$c28a976f3a596127$var$Color.Bold]: "font-weight: bold",
[$c28a976f3a596127$var$Color.Black]: "color: #000000",
[$c28a976f3a596127$var$Color.Red]: "color: #cc0000",
[$c28a976f3a596127$var$Color.Green]: "color: #4e9a06",
[$c28a976f3a596127$var$Color.Yellow]: "color: #c4a000",
[$c28a976f3a596127$var$Color.Blue]: "color: #729fcf",
[$c28a976f3a596127$var$Color.Magenta]: "color: #75507b",
[$c28a976f3a596127$var$Color.Cyan]: "color: #06989a",
[$c28a976f3a596127$var$Color.White]: "color: #d3d7cf",
[$c28a976f3a596127$var$Color.DarkGray]: "color: #555753"
"use strict";
import {
captureLogs,
captureLogsAsync,
debug,
error,
info,
levels,
log,
mockLogging,
setLogLevel,
stopMockLogging,
trace,
warn
} from "./chunk-EOO2SMP4.js";
export {
captureLogs,
captureLogsAsync,
debug,
error,
info,
levels,
log,
mockLogging,
setLogLevel,
stopMockLogging,
trace,
warn
};
const $c28a976f3a596127$export$cc32c6afed33d362 = {
trace: 0,
debug: 1,
log: 2,
info: 2,
warn: 3,
error: 4
};
const $c28a976f3a596127$var$reversLevels = {};
for(const key in $c28a976f3a596127$export$cc32c6afed33d362)$c28a976f3a596127$var$reversLevels[$c28a976f3a596127$export$cc32c6afed33d362[key]] = key;
let $c28a976f3a596127$var$currentLevel = 2;
function $c28a976f3a596127$export$c622e99c0ce7b1c9(level) {
const lvl = $c28a976f3a596127$export$cc32c6afed33d362[level];
if (lvl === undefined) return;
$c28a976f3a596127$var$currentLevel = lvl;
}
function $c28a976f3a596127$var$formatConsoleDate(date, level) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
const str = (hour < 10 ? "0" + hour : hour) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "." + ("00" + milliseconds).slice(-3);
if ($c28a976f3a596127$var$isBrowser) {
const ts = $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
return [
ts[0] + " " + level[0],
ts[1],
level[1]
];
}
return $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
}
const $c28a976f3a596127$var$createLogger = (lvl, level)=>{
return (...args)=>{
if (lvl < $c28a976f3a596127$var$currentLevel) return;
if ($c28a976f3a596127$var$logsMock) {
$c28a976f3a596127$var$logsMock.log({
level: $c28a976f3a596127$var$reversLevels[lvl],
args: args
});
return;
}
console.log(...$c28a976f3a596127$var$formatConsoleDate(new Date(), level).concat(args));
};
};
function $c28a976f3a596127$var$colorize(s, ...cc) {
if ($c28a976f3a596127$var$isBrowser) {
const attr = [];
for (const c of cc)attr.push($c28a976f3a596127$var$colorHex[c]);
return [
`%c${s}`,
attr.join("; ")
];
}
let out = "";
for (const c of cc)out += `\x1b[${c}m`;
out += `${s}\x1b[0m`;
return [
out
];
}
const $c28a976f3a596127$export$357889f174732d38 = $c28a976f3a596127$var$createLogger(0, $c28a976f3a596127$var$colorize("TRC", $c28a976f3a596127$var$Color.Magenta));
const $c28a976f3a596127$export$1c9f709888824e05 = $c28a976f3a596127$var$createLogger(1, $c28a976f3a596127$var$colorize("DBG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$bef1f36f5486a6a3 = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("LOG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$a80b3bd66acc52ff = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("INF", $c28a976f3a596127$var$Color.Green));
const $c28a976f3a596127$export$c106dd0671a0fc2d = $c28a976f3a596127$var$createLogger(3, $c28a976f3a596127$var$colorize("WRN", $c28a976f3a596127$var$Color.Cyan));
const $c28a976f3a596127$export$a3bc9b8ed74fc = $c28a976f3a596127$var$createLogger(4, $c28a976f3a596127$var$colorize("ERR", $c28a976f3a596127$var$Color.Red, $c28a976f3a596127$var$Color.Bold)); // export {
// trace,
// debug,
// log,
// info,
// warn,
// error,
// };
// export function warn(...args: string[]) {}
export {$c28a976f3a596127$export$a3c48a6e34bb2eb9 as captureLogs, $c28a976f3a596127$export$394c203869fd6992 as mockLogging, $c28a976f3a596127$export$7f9160e76073e3f2 as stopMockLogging, $c28a976f3a596127$export$c7683502519ee876 as captureLogsAsync, $c28a976f3a596127$export$cc32c6afed33d362 as levels, $c28a976f3a596127$export$c622e99c0ce7b1c9 as setLogLevel, $c28a976f3a596127$export$357889f174732d38 as trace, $c28a976f3a596127$export$1c9f709888824e05 as debug, $c28a976f3a596127$export$bef1f36f5486a6a3 as log, $c28a976f3a596127$export$a80b3bd66acc52ff as info, $c28a976f3a596127$export$c106dd0671a0fc2d as warn, $c28a976f3a596127$export$a3bc9b8ed74fc as error};
//# sourceMappingURL=console.js.map
//# sourceMappingURL=console.js.map

@@ -1,833 +0,27 @@

import {Subject as $kSxqQ$Subject, BehaviorSubject as $kSxqQ$BehaviorSubject, map as $kSxqQ$map} from "rxjs";
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $parcel$global =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {};
var $c28a976f3a596127$exports = {};
$parcel$export($c28a976f3a596127$exports, "captureLogs", () => $c28a976f3a596127$export$a3c48a6e34bb2eb9);
$parcel$export($c28a976f3a596127$exports, "mockLogging", () => $c28a976f3a596127$export$394c203869fd6992);
$parcel$export($c28a976f3a596127$exports, "stopMockLogging", () => $c28a976f3a596127$export$7f9160e76073e3f2);
$parcel$export($c28a976f3a596127$exports, "captureLogsAsync", () => $c28a976f3a596127$export$c7683502519ee876);
$parcel$export($c28a976f3a596127$exports, "levels", () => $c28a976f3a596127$export$cc32c6afed33d362);
$parcel$export($c28a976f3a596127$exports, "setLogLevel", () => $c28a976f3a596127$export$c622e99c0ce7b1c9);
$parcel$export($c28a976f3a596127$exports, "trace", () => $c28a976f3a596127$export$357889f174732d38);
$parcel$export($c28a976f3a596127$exports, "debug", () => $c28a976f3a596127$export$1c9f709888824e05);
$parcel$export($c28a976f3a596127$exports, "log", () => $c28a976f3a596127$export$bef1f36f5486a6a3);
$parcel$export($c28a976f3a596127$exports, "info", () => $c28a976f3a596127$export$a80b3bd66acc52ff);
$parcel$export($c28a976f3a596127$exports, "warn", () => $c28a976f3a596127$export$c106dd0671a0fc2d);
$parcel$export($c28a976f3a596127$exports, "error", () => $c28a976f3a596127$export$a3bc9b8ed74fc);
/* c8 ignore start */ const $c28a976f3a596127$var$isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
let $c28a976f3a596127$var$Color;
(function(Color1) {
Color1[Color1["Bold"] = 1] = "Bold";
Color1[Color1["Black"] = 30] = "Black";
Color1[Color1["Red"] = 31] = "Red";
Color1[Color1["Green"] = 32] = "Green";
Color1[Color1["Yellow"] = 33] = "Yellow";
Color1[Color1["Blue"] = 34] = "Blue";
Color1[Color1["Magenta"] = 35] = "Magenta";
Color1[Color1["Cyan"] = 36] = "Cyan";
Color1[Color1["White"] = 37] = "White";
Color1[Color1["DarkGray"] = 90] = "DarkGray";
})($c28a976f3a596127$var$Color || ($c28a976f3a596127$var$Color = {}));
class $c28a976f3a596127$var$LogsMock {
logs = [];
log(line) {
this.logs.push(line);
}
clear() {
this.logs = [];
}
}
let $c28a976f3a596127$var$logsMock;
function $c28a976f3a596127$export$a3c48a6e34bb2eb9(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
async function $c28a976f3a596127$export$c7683502519ee876(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
await cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
function $c28a976f3a596127$export$394c203869fd6992() {
if (!$c28a976f3a596127$var$logsMock) $c28a976f3a596127$var$logsMock = new $c28a976f3a596127$var$LogsMock();
return $c28a976f3a596127$var$logsMock;
}
function $c28a976f3a596127$export$7f9160e76073e3f2() {
$c28a976f3a596127$var$logsMock = undefined;
}
const $c28a976f3a596127$var$colorHex = {
[$c28a976f3a596127$var$Color.Bold]: "font-weight: bold",
[$c28a976f3a596127$var$Color.Black]: "color: #000000",
[$c28a976f3a596127$var$Color.Red]: "color: #cc0000",
[$c28a976f3a596127$var$Color.Green]: "color: #4e9a06",
[$c28a976f3a596127$var$Color.Yellow]: "color: #c4a000",
[$c28a976f3a596127$var$Color.Blue]: "color: #729fcf",
[$c28a976f3a596127$var$Color.Magenta]: "color: #75507b",
[$c28a976f3a596127$var$Color.Cyan]: "color: #06989a",
[$c28a976f3a596127$var$Color.White]: "color: #d3d7cf",
[$c28a976f3a596127$var$Color.DarkGray]: "color: #555753"
"use strict";
import {
EmpiricaClassic,
Game,
Player,
PlayerGame,
PlayerRound,
PlayerStage,
Round,
Stage
} from "./chunk-DVDN4LPG.js";
import "./chunk-RMTAE234.js";
import "./chunk-YMBME4LM.js";
import "./chunk-VUXXG5C5.js";
import "./chunk-XXEIUXU2.js";
import "./chunk-EOO2SMP4.js";
export {
EmpiricaClassic,
Game,
Player,
PlayerGame,
PlayerRound,
PlayerStage,
Round,
Stage
};
const $c28a976f3a596127$export$cc32c6afed33d362 = {
trace: 0,
debug: 1,
log: 2,
info: 2,
warn: 3,
error: 4
};
const $c28a976f3a596127$var$reversLevels = {};
for(const key in $c28a976f3a596127$export$cc32c6afed33d362)$c28a976f3a596127$var$reversLevels[$c28a976f3a596127$export$cc32c6afed33d362[key]] = key;
let $c28a976f3a596127$var$currentLevel = 2;
function $c28a976f3a596127$export$c622e99c0ce7b1c9(level) {
const lvl = $c28a976f3a596127$export$cc32c6afed33d362[level];
if (lvl === undefined) return;
$c28a976f3a596127$var$currentLevel = lvl;
}
function $c28a976f3a596127$var$formatConsoleDate(date, level) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
const str = (hour < 10 ? "0" + hour : hour) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "." + ("00" + milliseconds).slice(-3);
if ($c28a976f3a596127$var$isBrowser) {
const ts = $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
return [
ts[0] + " " + level[0],
ts[1],
level[1]
];
}
return $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
}
const $c28a976f3a596127$var$createLogger = (lvl, level)=>{
return (...args)=>{
if (lvl < $c28a976f3a596127$var$currentLevel) return;
if ($c28a976f3a596127$var$logsMock) {
$c28a976f3a596127$var$logsMock.log({
level: $c28a976f3a596127$var$reversLevels[lvl],
args: args
});
return;
}
console.log(...$c28a976f3a596127$var$formatConsoleDate(new Date(), level).concat(args));
};
};
function $c28a976f3a596127$var$colorize(s, ...cc) {
if ($c28a976f3a596127$var$isBrowser) {
const attr = [];
for (const c of cc)attr.push($c28a976f3a596127$var$colorHex[c]);
return [
`%c${s}`,
attr.join("; ")
];
}
let out = "";
for (const c of cc)out += `\x1b[${c}m`;
out += `${s}\x1b[0m`;
return [
out
];
}
const $c28a976f3a596127$export$357889f174732d38 = $c28a976f3a596127$var$createLogger(0, $c28a976f3a596127$var$colorize("TRC", $c28a976f3a596127$var$Color.Magenta));
const $c28a976f3a596127$export$1c9f709888824e05 = $c28a976f3a596127$var$createLogger(1, $c28a976f3a596127$var$colorize("DBG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$bef1f36f5486a6a3 = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("LOG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$a80b3bd66acc52ff = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("INF", $c28a976f3a596127$var$Color.Green));
const $c28a976f3a596127$export$c106dd0671a0fc2d = $c28a976f3a596127$var$createLogger(3, $c28a976f3a596127$var$colorize("WRN", $c28a976f3a596127$var$Color.Cyan));
const $c28a976f3a596127$export$a3bc9b8ed74fc = $c28a976f3a596127$var$createLogger(4, $c28a976f3a596127$var$colorize("ERR", $c28a976f3a596127$var$Color.Red, $c28a976f3a596127$var$Color.Bold)); // export {
// trace,
// debug,
// log,
// info,
// warn,
// error,
// };
// export function warn(...args: string[]) {}
class $7cb1a807542520c7$export$21991851b0bb231f {
constructor(attributesObs, donesObs, setAttributes){
this.setAttributes = setAttributes;
this.attrs = new Map();
this.updates = new Map();
attributesObs.subscribe({
next: ({ attribute: attribute , removed: removed })=>{
this.update(attribute, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
attribute(scopeID, key) {
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
let attr = scopeMap.get(key);
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
return attr;
}
attributePeek(scopeID, key) {
let scopeUpdateMap = this.updates.get(scopeID);
if (scopeUpdateMap) {
const updated = scopeUpdateMap.get(key);
if (updated) {
if (typeof updated === "boolean") return;
else {
if (!updated.val) return;
else {
const attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
attr._update(updated);
return attr;
}
}
}
}
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) return;
let attr = scopeMap.get(key);
if (!attr) return;
if (attr.value === undefined) return;
return attr;
}
nextAttributeValue(scopeID, key) {
const attr = this.attributePeek(scopeID, key);
if (!attr) return;
return attr.value;
}
update(attr, removed) {
let nodeID = attr.nodeID;
if (!nodeID) {
if (!attr.node?.id) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`new attribute without node ID`);
return;
}
nodeID = attr.node.id;
}
let scopeMap = this.updates.get(nodeID);
if (!scopeMap) {
scopeMap = new Map();
this.updates.set(nodeID, scopeMap);
}
if (removed) scopeMap.set(attr.key, true);
else scopeMap.set(attr.key, attr);
}
scopeWasUpdated(scopeID) {
if (!scopeID) return false;
return this.updates.has(scopeID);
}
next() {
for (const [scopeID, attrs] of this.updates){
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
for (const [key, attrOrDel] of attrs){
let attr = scopeMap.get(key);
if (typeof attrOrDel === "boolean") {
if (attr) attr._update(undefined);
} else {
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
attr._update(attrOrDel);
}
}
}
this.updates.clear();
}
}
class $7cb1a807542520c7$export$ab9c25261cd8c720 {
constructor(setAttributes, scopeID, key){
this.setAttributes = setAttributes;
this.scopeID = scopeID;
this.key = key;
this.val = new (0, $kSxqQ$BehaviorSubject)(undefined);
}
get obs() {
return this.val;
}
get value() {
return this.val.getValue();
}
get nodeID() {
return this.attr?.nodeID || this.attr?.node?.id;
}
set(value, ao) {
this.val.next(value);
const attrProps = {
key: this.key,
nodeID: this.scopeID,
val: JSON.stringify(value)
};
if (ao) {
// TODO Fix this. Should check if compatible with existing attribute and
// only set fields set on ao.
attrProps.private = ao.private;
attrProps.protected = ao.protected;
attrProps.immutable = ao.immutable;
attrProps.append = ao.append;
attrProps.vector = ao.vector;
attrProps.index = ao.index;
}
this.setAttributes([
attrProps
]);
}
// internal only
_update(attr) {
if (attr && this.attr && this.attr.id === attr.id) return;
this.attr = attr;
let value = undefined;
if (this.attr?.val) value = JSON.parse(this.attr.val);
this.val.next(value);
}
}
class $b1aa8155cc096fb6$export$8546186883d6ff3e {
constructor(scopesObs, donesObs, ctx, kinds, attributes){
this.ctx = ctx;
this.kinds = kinds;
this.attributes = attributes;
this.scopes = new Map();
this.scopesByKind = new Map();
this.kindUpdated = new Set();
scopesObs.subscribe({
next: ({ scope: scope , removed: removed })=>{
this.update(scope, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
scope(id) {
return this.scopes.get(id)?.getValue();
}
scopeObs(id) {
return this.scopes.get(id);
}
byKind(kind) {
let map = this.scopesByKind.get(kind);
if (!map) {
map = new Map();
this.scopesByKind.set(kind, map);
}
return map;
}
kindWasUpdated(kind) {
return this.kindUpdated.has(kind);
}
next() {
this.kindUpdated.clear();
for (const [_, scopeSubject] of this.scopes){
const scope = scopeSubject.getValue();
if (scope._updated || this.attributes.scopeWasUpdated(scope.id)) {
scope._updated = false;
scopeSubject.next(scope);
}
}
}
update(scope, removed) {
const existing = this.scopes.get(scope.id)?.getValue();
if (removed) {
if (!existing) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: missing scope on removal");
return;
}
existing._deleted = true;
existing._updated = true;
this.scopes.delete(scope.id);
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope on removal");
return;
}
const kind = scope.kind;
// Using ! because scopes by kind must exist, since this scope was found.
this.scopesByKind.get(kind).delete(scope.id);
this.kindUpdated.add(kind);
return;
}
if (existing) {
existing._deleted = false;
return;
}
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope");
return;
}
const kind = scope.kind;
const scopeClass = this.kinds[kind];
if (!scopeClass) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)(`scopes: unknown scope kind: ${scope.kind}`);
return;
}
const obj = this.create(scopeClass, scope);
const subj = new (0, $kSxqQ$BehaviorSubject)(obj);
this.scopes.set(scope.id, subj);
let skm = this.scopesByKind.get(kind);
if (!skm) {
skm = new Map();
this.scopesByKind.set(kind, skm);
}
skm.set(scope.id, obj);
obj._updated = true;
this.kindUpdated.add(kind);
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes);
}
}
class $b1aa8155cc096fb6$export$775b6bb06e53a214 {
constructor(ctx, scope, scopes, attributes){
this.ctx = ctx;
this.scope = scope;
this.scopes = scopes;
this.attributes = attributes;
this._deleted = false;
this._updated = false;
}
get id() {
return this.scope.id;
}
get kind() {
// Using ! because we don't allow scopes without kind
return this.scope.kind;
}
get(key) {
return this.attributes.attribute(this.scope.id, key).value;
}
obs(key) {
return this.attributes.attribute(this.scope.id, key).obs;
}
set(key, value, ao) {
return this.attributes.attribute(this.scope.id, key).set(value, ao);
}
scopeByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.scopes.scope(id);
}
hasUpdated() {
return this._updated || this.attributes.scopeWasUpdated(this.id);
}
}
class $0e423146924dff20$export$8546186883d6ff3e extends (0, $b1aa8155cc096fb6$export$8546186883d6ff3e) {
constructor(scopesObs, donesObs, ctx, kinds, attributes, steps){
super(scopesObs, donesObs, ctx, kinds, attributes);
this.steps = steps;
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes, this.steps);
}
}
class $0e423146924dff20$export$775b6bb06e53a214 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
constructor(ctx, scope, scopes, attributes, steps){
super(ctx, scope, scopes, attributes);
this.steps = steps;
this._deleted = false;
this._updated = false;
}
ticker(id) {
return this.steps.step(id);
}
tickerByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.ticker(id);
}
}
class $dab56e532931ce2a$export$cceeabf822b64fc0 {
attrs = new Map();
updates = new Map();
constructor(globals){
this.self = new (0, $kSxqQ$BehaviorSubject)(this);
globals.subscribe({
next: ({ attribute: attribute , done: done })=>{
if (attribute) {
let val = undefined;
if (attribute.val) val = JSON.parse(attribute.val);
this.updates.set(attribute.key, val);
}
if (done) {
for (const [key, val] of this.updates)this.obs(key).next(val);
this.updates.clear();
if (this.self) this.self.next(this);
}
}
});
}
get(key) {
const o = this.attrs.get(key);
if (o) return o.getValue();
return undefined;
}
obs(key) {
let o = this.attrs.get(key);
if (!o) {
o = new (0, $kSxqQ$BehaviorSubject)(undefined);
this.attrs.set(key, o);
}
return o;
}
}
let $3f5770985ebbd9e5$var$scheduled = [];
let $3f5770985ebbd9e5$export$a5e55367be404707 = null;
function $3f5770985ebbd9e5$export$6b09b4ca4892be7e(now) {
if ($3f5770985ebbd9e5$export$a5e55367be404707 && $3f5770985ebbd9e5$export$a5e55367be404707 > now) {
if (now === 0) // This is a reset scheduled should be empty
$3f5770985ebbd9e5$var$scheduled = [];
else throw "time must move forward";
}
$3f5770985ebbd9e5$export$a5e55367be404707 = now;
const rescheduled = [];
for (const s of $3f5770985ebbd9e5$var$scheduled)if ($3f5770985ebbd9e5$export$a5e55367be404707 >= s.from + s.dur) s.cb();
else rescheduled.push(s);
$3f5770985ebbd9e5$var$scheduled = rescheduled;
}
function $3f5770985ebbd9e5$var$pnow() {
if ($3f5770985ebbd9e5$export$a5e55367be404707 !== null) return $3f5770985ebbd9e5$export$a5e55367be404707;
else return performance.now();
}
function $3f5770985ebbd9e5$var$timeout(callback, ms) {
if ($3f5770985ebbd9e5$export$a5e55367be404707 !== null) {
const schd = {
cb: callback,
from: $3f5770985ebbd9e5$export$a5e55367be404707,
dur: ms
};
$3f5770985ebbd9e5$var$scheduled.push(schd);
} else setTimeout(callback, ms);
}
class $3f5770985ebbd9e5$export$fd55ce593607084a {
running = false;
ticker = new (0, $kSxqQ$BehaviorSubject)(undefined);
startAt = 0;
endAt = 0;
constructor(step, ticker){
ticker.pipe((0, $kSxqQ$map)(this.recalc.bind(this))).subscribe({
next: (val)=>{
this.ticker.next(val);
}
});
this._update(step);
}
recalc(t) {
if (!this.running) return undefined;
return {
started: t >= this.startAt,
ended: t >= this.endAt,
ellapsed: Math.round(t - this.startAt),
remaining: Math.round(this.endAt - t),
duration: this.endAt - this.startAt
};
}
obs() {
return this.ticker;
}
get current() {
return this.recalc($3f5770985ebbd9e5$var$pnow());
}
// internal only
_update(step) {
if (!step.running) {
this.running = false;
this.ticker.next(undefined);
return;
}
if (step.ellapsed === null || step.remaining === null || step.ellapsed === undefined || step.remaining === undefined) {
this.running = false;
return;
}
const now = $3f5770985ebbd9e5$var$pnow();
this.startAt = now - step.ellapsed * 1000;
this.endAt = now + step.remaining * 1000;
this.running = step.ellapsed >= 0 && step.remaining >= 0;
this.ticker.next(this.recalc(now));
}
// internal only
_stop() {
this.running = false;
this.ticker.next(undefined);
}
}
class $3f5770985ebbd9e5$export$fb587a27d5a722e7 {
steps = new Map();
updates = new Map();
constructor(stepsObs, donesObs){
stepsObs.subscribe({
next: ({ step: step , removed: removed })=>{
this.update(step, removed);
}
});
donesObs.subscribe({
next: ()=>{
this.next();
}
});
this.ticker = new (0, $kSxqQ$BehaviorSubject)(Math.floor($3f5770985ebbd9e5$var$pnow()));
const controller = new AbortController();
$3f5770985ebbd9e5$var$timerInterval(1000, controller.signal, (t)=>{
this.ticker.next(t);
});
}
step(stepID) {
return this.steps.get(stepID);
}
update(step, removed) {
if (removed) this.updates.set(step.id, true);
else this.updates.set(step.id, step);
}
next() {
for (const [id, stepOrDel] of this.updates){
let step = this.steps.get(id);
if (typeof stepOrDel === "boolean") {
if (step) {
step._stop();
this.steps.delete(id);
}
} else {
if (!step) {
step = new $3f5770985ebbd9e5$export$fd55ce593607084a(stepOrDel, this.ticker);
this.steps.set(id, step);
}
step._update(stepOrDel);
}
}
this.updates.clear();
}
}
const $3f5770985ebbd9e5$export$e8e78c978b129247 = typeof self === "object" && self.self == self ? self : typeof $parcel$global === "object" && $parcel$global.global == $parcel$global ? $parcel$global : {};
// nodejs support
if (!$3f5770985ebbd9e5$export$e8e78c978b129247["requestAnimationFrame"]) $3f5770985ebbd9e5$export$e8e78c978b129247["requestAnimationFrame"] = (cb)=>cb($3f5770985ebbd9e5$var$pnow());
// Inspiration:
// https://www.youtube.com/watch?v=MCi6AZMkxcU
// https://gist.github.com/jakearchibald/cb03f15670817001b1157e62a076fe95
function $3f5770985ebbd9e5$var$timerInterval(ms = 1000, signal, callback) {
// Performance should be available in Nodejs 10+.
// Get the last rounded second, which will go negative, but that's fine, since
// it will immediately send out its first tick, then be on the second.
const start = Math.floor($3f5770985ebbd9e5$var$pnow() / 1000) * 1000;
function frame(time) {
/* c8 ignore next */ if (signal.aborted) return;
callback(time);
scheduleFrame(time);
}
function scheduleFrame(time) {
const elapsed = time - start;
const roundedElapsed = Math.round(elapsed / ms) * ms;
const targetNext = start + roundedElapsed + ms;
const delay = targetNext - $3f5770985ebbd9e5$var$pnow();
$3f5770985ebbd9e5$var$timeout(()=>requestAnimationFrame(frame), delay);
}
scheduleFrame(start);
} // export function useAnimationInterval(
// ms: number,
// callback: (time: number) => void
// ) {
// const callbackRef = React.useRef(callback);
// React.useEffect(() => {
// callbackRef.current = callback;
// }, [callback]);
// React.useEffect(() => {
// const controller = new AbortController();
// animationInterval(ms, controller.signal, callbackRef.current);
// return () => controller.abort();
// }, [ms]);
// }
class $a548fd8dd88740ee$export$985739bfa5723e08 extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
get stage() {
return this.scopeByKey("stageID");
}
get round() {
return this.stage?.round;
}
}
class $a548fd8dd88740ee$export$2616165974278734 extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
get game() {
const { game: game } = this.ctx;
if (!game) return;
const key = `playerGameID-${game.id}`;
return this.scopeByKey(key);
}
get round() {
const { stage: stage } = this.ctx;
if (!stage) return;
const { round: round } = stage;
if (!round) return;
const key = `playerRoundID-${round.id}`;
return this.scopeByKey(key);
}
get stage() {
const { stage: stage } = this.ctx;
if (!stage) return;
const key = `playerStageID-${stage.id}`;
return this.scopeByKey(key);
}
hasUpdated() {
if (super.hasUpdated()) return true;
return Boolean(this.round?.hasUpdated() || this.stage?.hasUpdated() || this.game?.hasUpdated());
}
}
class $a548fd8dd88740ee$export$82841d2a59838c0a extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
}
class $a548fd8dd88740ee$export$a108a2b722838976 extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
}
class $a548fd8dd88740ee$export$a613b4df4b6a4e3a extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
}
class $a548fd8dd88740ee$export$c5ed3eef16c0612f extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
}
class $a548fd8dd88740ee$export$208cd1682bd0e4b6 extends (0, $0e423146924dff20$export$775b6bb06e53a214) {
get round() {
return this.scopeByKey("roundID");
}
get timer() {
return this.tickerByKey("timerID");
}
}
// TODO update context
class $a548fd8dd88740ee$var$Context {
}
const $a548fd8dd88740ee$export$9ef7793a01f1f377 = {
game: $a548fd8dd88740ee$export$985739bfa5723e08,
player: $a548fd8dd88740ee$export$2616165974278734,
playerGame: $a548fd8dd88740ee$export$82841d2a59838c0a,
playerRound: $a548fd8dd88740ee$export$a108a2b722838976,
playerStage: $a548fd8dd88740ee$export$a613b4df4b6a4e3a,
round: $a548fd8dd88740ee$export$c5ed3eef16c0612f,
stage: $a548fd8dd88740ee$export$208cd1682bd0e4b6
};
function $a548fd8dd88740ee$export$ebf8ffde38aee09(participantID, provider) {
const attributesDones = new (0, $kSxqQ$Subject)();
const scopesDones = new (0, $kSxqQ$Subject)();
const ctx = new $a548fd8dd88740ee$var$Context();
const attributes = new (0, $7cb1a807542520c7$export$21991851b0bb231f)(provider.attributes, attributesDones, provider.setAttributes);
const steps = new (0, $3f5770985ebbd9e5$export$fb587a27d5a722e7)(provider.steps, provider.dones);
const scopes = new (0, $0e423146924dff20$export$8546186883d6ff3e)(provider.scopes, scopesDones, ctx, $a548fd8dd88740ee$export$9ef7793a01f1f377, attributes, steps);
const participantIDs = new Set();
const glob = new (0, $dab56e532931ce2a$export$cceeabf822b64fc0)(provider.globals);
const ret = {
game: new (0, $kSxqQ$BehaviorSubject)(undefined),
player: new (0, $kSxqQ$BehaviorSubject)(undefined),
players: new (0, $kSxqQ$BehaviorSubject)([]),
round: new (0, $kSxqQ$BehaviorSubject)(undefined),
stage: new (0, $kSxqQ$BehaviorSubject)(undefined),
globals: glob.self
};
provider.participants.subscribe({
next: ({ participant: participant , removed: removed })=>{
if (removed) {
if (participantIDs.has(participant.id)) participantIDs.delete(participant.id);
} else if (!participantIDs.has(participant.id)) participantIDs.add(participant.id);
}
});
provider.dones.subscribe({
next: ()=>{
const current = $a548fd8dd88740ee$var$getCurrent(ret);
const updated = $a548fd8dd88740ee$var$getMainObjects(participantID, scopes, attributes);
ctx.game = updated.game;
ctx.stage = updated.stage;
if ($a548fd8dd88740ee$var$scopeChanged(current.game, updated.game)) ret.game.next(updated.game);
if ($a548fd8dd88740ee$var$scopeChanged(current.player, updated.player)) ret.player.next(updated.player);
if ($a548fd8dd88740ee$var$scopeChanged(current.round, updated.round)) ret.round.next(updated.round);
if ($a548fd8dd88740ee$var$scopeChanged(current.stage, updated.stage)) ret.stage.next(updated.stage);
let playersChanged = false;
const players = [];
for(let i = 0; i < updated.players.length; i++){
let p = updated.players[i];
if (p) {
const partID = attributes.nextAttributeValue(p.id, "participantID");
if (!participantIDs.has(partID)) p = undefined;
}
if (!playersChanged && $a548fd8dd88740ee$var$scopeChanged(p, current.players[i])) playersChanged = true;
if (p) players.push(p);
}
if (playersChanged) ret.players.next(players);
scopesDones.next();
attributesDones.next();
}
});
return ret;
}
function $a548fd8dd88740ee$var$scopeChanged(current, updated) {
if (!current && !updated) return false;
if (!current || !updated) return true;
return current.id !== updated.id || updated.hasUpdated();
}
function $a548fd8dd88740ee$var$getCurrent(ctx) {
return {
game: ctx.game.getValue(),
player: ctx.player.getValue(),
round: ctx.round.getValue(),
stage: ctx.stage.getValue(),
players: ctx.players.getValue()
};
}
function $a548fd8dd88740ee$var$getMainObjects(participantID, scopes, attributes) {
const players = scopes.byKind("player");
const res = {
players: Array.from(players.values())
};
if (players.size === 0) return res;
res.player = Array.from(players.values()).find((p)=>{
const pID = attributes.nextAttributeValue(p.id, "participantID");
return pID === participantID;
});
if (!res.player) return res;
res.game = $a548fd8dd88740ee$var$nextScopeByKey(scopes, attributes, res.player, "gameID");
if (!res.game) return res;
res.stage = $a548fd8dd88740ee$var$nextScopeByKey(scopes, attributes, res.game, "stageID");
if (!res.stage) return res;
res.round = $a548fd8dd88740ee$var$nextScopeByKey(scopes, attributes, res.stage, "roundID");
if (!res.round) return res;
return res;
}
function $a548fd8dd88740ee$var$nextScopeByKey(scopes, attributes, scope, key) {
const id = attributes.nextAttributeValue(scope.id, key);
if (!id || typeof id !== "string") return;
return scopes.scope(id);
}
export {$a548fd8dd88740ee$export$ebf8ffde38aee09 as EmpiricaClassic, $a548fd8dd88740ee$export$985739bfa5723e08 as Game, $a548fd8dd88740ee$export$2616165974278734 as Player, $a548fd8dd88740ee$export$82841d2a59838c0a as PlayerGame, $a548fd8dd88740ee$export$a108a2b722838976 as PlayerRound, $a548fd8dd88740ee$export$a613b4df4b6a4e3a as PlayerStage, $a548fd8dd88740ee$export$c5ed3eef16c0612f as Round, $a548fd8dd88740ee$export$208cd1682bd0e4b6 as Stage};
//# sourceMappingURL=player-classic.js.map
//# sourceMappingURL=player-classic.js.map

@@ -1,742 +0,30 @@

import {BehaviorSubject as $jOzOc$BehaviorSubject, Subject as $jOzOc$Subject, groupBy as $jOzOc$groupBy, map as $jOzOc$map} from "rxjs";
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
var $parcel$global =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {};
var $c28a976f3a596127$exports = {};
$parcel$export($c28a976f3a596127$exports, "captureLogs", () => $c28a976f3a596127$export$a3c48a6e34bb2eb9);
$parcel$export($c28a976f3a596127$exports, "mockLogging", () => $c28a976f3a596127$export$394c203869fd6992);
$parcel$export($c28a976f3a596127$exports, "stopMockLogging", () => $c28a976f3a596127$export$7f9160e76073e3f2);
$parcel$export($c28a976f3a596127$exports, "captureLogsAsync", () => $c28a976f3a596127$export$c7683502519ee876);
$parcel$export($c28a976f3a596127$exports, "levels", () => $c28a976f3a596127$export$cc32c6afed33d362);
$parcel$export($c28a976f3a596127$exports, "setLogLevel", () => $c28a976f3a596127$export$c622e99c0ce7b1c9);
$parcel$export($c28a976f3a596127$exports, "trace", () => $c28a976f3a596127$export$357889f174732d38);
$parcel$export($c28a976f3a596127$exports, "debug", () => $c28a976f3a596127$export$1c9f709888824e05);
$parcel$export($c28a976f3a596127$exports, "log", () => $c28a976f3a596127$export$bef1f36f5486a6a3);
$parcel$export($c28a976f3a596127$exports, "info", () => $c28a976f3a596127$export$a80b3bd66acc52ff);
$parcel$export($c28a976f3a596127$exports, "warn", () => $c28a976f3a596127$export$c106dd0671a0fc2d);
$parcel$export($c28a976f3a596127$exports, "error", () => $c28a976f3a596127$export$a3bc9b8ed74fc);
/* c8 ignore start */ const $c28a976f3a596127$var$isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
let $c28a976f3a596127$var$Color;
(function(Color1) {
Color1[Color1["Bold"] = 1] = "Bold";
Color1[Color1["Black"] = 30] = "Black";
Color1[Color1["Red"] = 31] = "Red";
Color1[Color1["Green"] = 32] = "Green";
Color1[Color1["Yellow"] = 33] = "Yellow";
Color1[Color1["Blue"] = 34] = "Blue";
Color1[Color1["Magenta"] = 35] = "Magenta";
Color1[Color1["Cyan"] = 36] = "Cyan";
Color1[Color1["White"] = 37] = "White";
Color1[Color1["DarkGray"] = 90] = "DarkGray";
})($c28a976f3a596127$var$Color || ($c28a976f3a596127$var$Color = {}));
class $c28a976f3a596127$var$LogsMock {
logs = [];
log(line) {
this.logs.push(line);
}
clear() {
this.logs = [];
}
}
let $c28a976f3a596127$var$logsMock;
function $c28a976f3a596127$export$a3c48a6e34bb2eb9(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
async function $c28a976f3a596127$export$c7683502519ee876(cb) {
const lm = $c28a976f3a596127$export$394c203869fd6992();
await cb();
const ret = lm.logs;
$c28a976f3a596127$export$7f9160e76073e3f2();
return ret;
}
function $c28a976f3a596127$export$394c203869fd6992() {
if (!$c28a976f3a596127$var$logsMock) $c28a976f3a596127$var$logsMock = new $c28a976f3a596127$var$LogsMock();
return $c28a976f3a596127$var$logsMock;
}
function $c28a976f3a596127$export$7f9160e76073e3f2() {
$c28a976f3a596127$var$logsMock = undefined;
}
const $c28a976f3a596127$var$colorHex = {
[$c28a976f3a596127$var$Color.Bold]: "font-weight: bold",
[$c28a976f3a596127$var$Color.Black]: "color: #000000",
[$c28a976f3a596127$var$Color.Red]: "color: #cc0000",
[$c28a976f3a596127$var$Color.Green]: "color: #4e9a06",
[$c28a976f3a596127$var$Color.Yellow]: "color: #c4a000",
[$c28a976f3a596127$var$Color.Blue]: "color: #729fcf",
[$c28a976f3a596127$var$Color.Magenta]: "color: #75507b",
[$c28a976f3a596127$var$Color.Cyan]: "color: #06989a",
[$c28a976f3a596127$var$Color.White]: "color: #d3d7cf",
[$c28a976f3a596127$var$Color.DarkGray]: "color: #555753"
"use strict";
import {
Scope,
Scopes,
Step,
Steps
} from "./chunk-RMTAE234.js";
import {
Attribute,
Attributes
} from "./chunk-YMBME4LM.js";
import "./chunk-VUXXG5C5.js";
import {
TajribaProvider
} from "./chunk-T653CF3C.js";
import {
Globals
} from "./chunk-XXEIUXU2.js";
import "./chunk-EOO2SMP4.js";
export {
Attribute,
Attributes,
Globals,
Scope,
Scopes,
Step,
Steps,
TajribaProvider
};
const $c28a976f3a596127$export$cc32c6afed33d362 = {
trace: 0,
debug: 1,
log: 2,
info: 2,
warn: 3,
error: 4
};
const $c28a976f3a596127$var$reversLevels = {};
for(const key in $c28a976f3a596127$export$cc32c6afed33d362)$c28a976f3a596127$var$reversLevels[$c28a976f3a596127$export$cc32c6afed33d362[key]] = key;
let $c28a976f3a596127$var$currentLevel = 2;
function $c28a976f3a596127$export$c622e99c0ce7b1c9(level) {
const lvl = $c28a976f3a596127$export$cc32c6afed33d362[level];
if (lvl === undefined) return;
$c28a976f3a596127$var$currentLevel = lvl;
}
function $c28a976f3a596127$var$formatConsoleDate(date, level) {
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var milliseconds = date.getMilliseconds();
const str = (hour < 10 ? "0" + hour : hour) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "." + ("00" + milliseconds).slice(-3);
if ($c28a976f3a596127$var$isBrowser) {
const ts = $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
return [
ts[0] + " " + level[0],
ts[1],
level[1]
];
}
return $c28a976f3a596127$var$colorize(str, $c28a976f3a596127$var$Color.DarkGray).concat(level);
}
const $c28a976f3a596127$var$createLogger = (lvl, level)=>{
return (...args)=>{
if (lvl < $c28a976f3a596127$var$currentLevel) return;
if ($c28a976f3a596127$var$logsMock) {
$c28a976f3a596127$var$logsMock.log({
level: $c28a976f3a596127$var$reversLevels[lvl],
args: args
});
return;
}
console.log(...$c28a976f3a596127$var$formatConsoleDate(new Date(), level).concat(args));
};
};
function $c28a976f3a596127$var$colorize(s, ...cc) {
if ($c28a976f3a596127$var$isBrowser) {
const attr = [];
for (const c of cc)attr.push($c28a976f3a596127$var$colorHex[c]);
return [
`%c${s}`,
attr.join("; ")
];
}
let out = "";
for (const c of cc)out += `\x1b[${c}m`;
out += `${s}\x1b[0m`;
return [
out
];
}
const $c28a976f3a596127$export$357889f174732d38 = $c28a976f3a596127$var$createLogger(0, $c28a976f3a596127$var$colorize("TRC", $c28a976f3a596127$var$Color.Magenta));
const $c28a976f3a596127$export$1c9f709888824e05 = $c28a976f3a596127$var$createLogger(1, $c28a976f3a596127$var$colorize("DBG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$bef1f36f5486a6a3 = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("LOG", $c28a976f3a596127$var$Color.Yellow));
const $c28a976f3a596127$export$a80b3bd66acc52ff = $c28a976f3a596127$var$createLogger(2, $c28a976f3a596127$var$colorize("INF", $c28a976f3a596127$var$Color.Green));
const $c28a976f3a596127$export$c106dd0671a0fc2d = $c28a976f3a596127$var$createLogger(3, $c28a976f3a596127$var$colorize("WRN", $c28a976f3a596127$var$Color.Cyan));
const $c28a976f3a596127$export$a3bc9b8ed74fc = $c28a976f3a596127$var$createLogger(4, $c28a976f3a596127$var$colorize("ERR", $c28a976f3a596127$var$Color.Red, $c28a976f3a596127$var$Color.Bold)); // export {
// trace,
// debug,
// log,
// info,
// warn,
// error,
// };
// export function warn(...args: string[]) {}
class $7cb1a807542520c7$export$21991851b0bb231f {
constructor(attributesObs, donesObs, setAttributes){
this.setAttributes = setAttributes;
this.attrs = new Map();
this.updates = new Map();
attributesObs.subscribe({
next: ({ attribute: attribute , removed: removed })=>{
this.update(attribute, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
attribute(scopeID, key) {
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
let attr = scopeMap.get(key);
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
return attr;
}
attributePeek(scopeID, key) {
let scopeUpdateMap = this.updates.get(scopeID);
if (scopeUpdateMap) {
const updated = scopeUpdateMap.get(key);
if (updated) {
if (typeof updated === "boolean") return;
else {
if (!updated.val) return;
else {
const attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
attr._update(updated);
return attr;
}
}
}
}
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) return;
let attr = scopeMap.get(key);
if (!attr) return;
if (attr.value === undefined) return;
return attr;
}
nextAttributeValue(scopeID, key) {
const attr = this.attributePeek(scopeID, key);
if (!attr) return;
return attr.value;
}
update(attr, removed) {
let nodeID = attr.nodeID;
if (!nodeID) {
if (!attr.node?.id) {
(0, $c28a976f3a596127$export$a3bc9b8ed74fc)(`new attribute without node ID`);
return;
}
nodeID = attr.node.id;
}
let scopeMap = this.updates.get(nodeID);
if (!scopeMap) {
scopeMap = new Map();
this.updates.set(nodeID, scopeMap);
}
if (removed) scopeMap.set(attr.key, true);
else scopeMap.set(attr.key, attr);
}
scopeWasUpdated(scopeID) {
if (!scopeID) return false;
return this.updates.has(scopeID);
}
next() {
for (const [scopeID, attrs] of this.updates){
let scopeMap = this.attrs.get(scopeID);
if (!scopeMap) {
scopeMap = new Map();
this.attrs.set(scopeID, scopeMap);
}
for (const [key, attrOrDel] of attrs){
let attr = scopeMap.get(key);
if (typeof attrOrDel === "boolean") {
if (attr) attr._update(undefined);
} else {
if (!attr) {
attr = new $7cb1a807542520c7$export$ab9c25261cd8c720(this.setAttributes, scopeID, key);
scopeMap.set(key, attr);
}
attr._update(attrOrDel);
}
}
}
this.updates.clear();
}
}
class $7cb1a807542520c7$export$ab9c25261cd8c720 {
constructor(setAttributes, scopeID, key){
this.setAttributes = setAttributes;
this.scopeID = scopeID;
this.key = key;
this.val = new (0, $jOzOc$BehaviorSubject)(undefined);
}
get obs() {
return this.val;
}
get value() {
return this.val.getValue();
}
get nodeID() {
return this.attr?.nodeID || this.attr?.node?.id;
}
set(value, ao) {
this.val.next(value);
const attrProps = {
key: this.key,
nodeID: this.scopeID,
val: JSON.stringify(value)
};
if (ao) {
// TODO Fix this. Should check if compatible with existing attribute and
// only set fields set on ao.
attrProps.private = ao.private;
attrProps.protected = ao.protected;
attrProps.immutable = ao.immutable;
attrProps.append = ao.append;
attrProps.vector = ao.vector;
attrProps.index = ao.index;
}
this.setAttributes([
attrProps
]);
}
// internal only
_update(attr) {
if (attr && this.attr && this.attr.id === attr.id) return;
this.attr = attr;
let value = undefined;
if (this.attr?.val) value = JSON.parse(this.attr.val);
this.val.next(value);
}
}
class $dab56e532931ce2a$export$cceeabf822b64fc0 {
attrs = new Map();
updates = new Map();
constructor(globals){
this.self = new (0, $jOzOc$BehaviorSubject)(this);
globals.subscribe({
next: ({ attribute: attribute , done: done })=>{
if (attribute) {
let val = undefined;
if (attribute.val) val = JSON.parse(attribute.val);
this.updates.set(attribute.key, val);
}
if (done) {
for (const [key, val] of this.updates)this.obs(key).next(val);
this.updates.clear();
if (this.self) this.self.next(this);
}
}
});
}
get(key) {
const o = this.attrs.get(key);
if (o) return o.getValue();
return undefined;
}
obs(key) {
let o = this.attrs.get(key);
if (!o) {
o = new (0, $jOzOc$BehaviorSubject)(undefined);
this.attrs.set(key, o);
}
return o;
}
}
class $9c1ce6385a03e42f$export$d31e58fbd756e9f7 {
constructor(changes, globals, setAttributes){
this.globals = globals;
this.setAttributes = setAttributes;
this.scopes = new (0, $jOzOc$Subject)();
this.attributes = new (0, $jOzOc$Subject)();
this.participants = new (0, $jOzOc$Subject)();
this.steps = new (0, $jOzOc$Subject)();
this.dones = new (0, $jOzOc$Subject)();
changes.pipe((0, $jOzOc$groupBy)((chg)=>chg.change.__typename)).subscribe({
next: (group)=>{
switch(group.key){
case "ScopeChange":
group.subscribe({
next: (scope)=>{
this.scopes.next({
scope: scope.change,
removed: scope.removed
});
if (scope.done) this.dones.next();
}
});
break;
case "AttributeChange":
group.subscribe({
next: (scope)=>{
this.attributes.next({
attribute: scope.change,
removed: scope.removed
});
if (scope.done) this.dones.next();
}
});
break;
case "ParticipantChange":
group.subscribe({
next: (scope)=>{
this.participants.next({
participant: scope.change,
removed: scope.removed
});
if (scope.done) this.dones.next();
}
});
break;
case "StepChange":
group.subscribe({
next: (scope)=>{
this.steps.next({
step: scope.change,
removed: scope.removed
});
if (scope.done) this.dones.next();
}
});
break;
}
}
});
}
}
class $b1aa8155cc096fb6$export$8546186883d6ff3e {
constructor(scopesObs, donesObs, ctx, kinds, attributes){
this.ctx = ctx;
this.kinds = kinds;
this.attributes = attributes;
this.scopes = new Map();
this.scopesByKind = new Map();
this.kindUpdated = new Set();
scopesObs.subscribe({
next: ({ scope: scope , removed: removed })=>{
this.update(scope, removed);
}
});
donesObs.subscribe({
next: this.next.bind(this)
});
}
scope(id) {
return this.scopes.get(id)?.getValue();
}
scopeObs(id) {
return this.scopes.get(id);
}
byKind(kind) {
let map = this.scopesByKind.get(kind);
if (!map) {
map = new Map();
this.scopesByKind.set(kind, map);
}
return map;
}
kindWasUpdated(kind) {
return this.kindUpdated.has(kind);
}
next() {
this.kindUpdated.clear();
for (const [_, scopeSubject] of this.scopes){
const scope = scopeSubject.getValue();
if (scope._updated || this.attributes.scopeWasUpdated(scope.id)) {
scope._updated = false;
scopeSubject.next(scope);
}
}
}
update(scope, removed) {
const existing = this.scopes.get(scope.id)?.getValue();
if (removed) {
if (!existing) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: missing scope on removal");
return;
}
existing._deleted = true;
existing._updated = true;
this.scopes.delete(scope.id);
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope on removal");
return;
}
const kind = scope.kind;
// Using ! because scopes by kind must exist, since this scope was found.
this.scopesByKind.get(kind).delete(scope.id);
this.kindUpdated.add(kind);
return;
}
if (existing) {
existing._deleted = false;
return;
}
if (!scope.kind) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)("scopes: scope missing kind on scope");
return;
}
const kind = scope.kind;
const scopeClass = this.kinds[kind];
if (!scopeClass) {
(0, $c28a976f3a596127$export$c106dd0671a0fc2d)(`scopes: unknown scope kind: ${scope.kind}`);
return;
}
const obj = this.create(scopeClass, scope);
const subj = new (0, $jOzOc$BehaviorSubject)(obj);
this.scopes.set(scope.id, subj);
let skm = this.scopesByKind.get(kind);
if (!skm) {
skm = new Map();
this.scopesByKind.set(kind, skm);
}
skm.set(scope.id, obj);
obj._updated = true;
this.kindUpdated.add(kind);
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes);
}
}
class $b1aa8155cc096fb6$export$775b6bb06e53a214 {
constructor(ctx, scope, scopes, attributes){
this.ctx = ctx;
this.scope = scope;
this.scopes = scopes;
this.attributes = attributes;
this._deleted = false;
this._updated = false;
}
get id() {
return this.scope.id;
}
get kind() {
// Using ! because we don't allow scopes without kind
return this.scope.kind;
}
get(key) {
return this.attributes.attribute(this.scope.id, key).value;
}
obs(key) {
return this.attributes.attribute(this.scope.id, key).obs;
}
set(key, value, ao) {
return this.attributes.attribute(this.scope.id, key).set(value, ao);
}
scopeByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.scopes.scope(id);
}
hasUpdated() {
return this._updated || this.attributes.scopeWasUpdated(this.id);
}
}
class $0e423146924dff20$export$8546186883d6ff3e extends (0, $b1aa8155cc096fb6$export$8546186883d6ff3e) {
constructor(scopesObs, donesObs, ctx, kinds, attributes, steps){
super(scopesObs, donesObs, ctx, kinds, attributes);
this.steps = steps;
}
create(scopeClass, scope) {
return new scopeClass(this.ctx, scope, this, this.attributes, this.steps);
}
}
class $0e423146924dff20$export$775b6bb06e53a214 extends (0, $b1aa8155cc096fb6$export$775b6bb06e53a214) {
constructor(ctx, scope, scopes, attributes, steps){
super(ctx, scope, scopes, attributes);
this.steps = steps;
this._deleted = false;
this._updated = false;
}
ticker(id) {
return this.steps.step(id);
}
tickerByKey(key) {
const id = this.get(key);
if (!id || typeof id !== "string") return;
return this.ticker(id);
}
}
let $3f5770985ebbd9e5$var$scheduled = [];
let $3f5770985ebbd9e5$export$a5e55367be404707 = null;
function $3f5770985ebbd9e5$export$6b09b4ca4892be7e(now) {
if ($3f5770985ebbd9e5$export$a5e55367be404707 && $3f5770985ebbd9e5$export$a5e55367be404707 > now) {
if (now === 0) // This is a reset scheduled should be empty
$3f5770985ebbd9e5$var$scheduled = [];
else throw "time must move forward";
}
$3f5770985ebbd9e5$export$a5e55367be404707 = now;
const rescheduled = [];
for (const s of $3f5770985ebbd9e5$var$scheduled)if ($3f5770985ebbd9e5$export$a5e55367be404707 >= s.from + s.dur) s.cb();
else rescheduled.push(s);
$3f5770985ebbd9e5$var$scheduled = rescheduled;
}
function $3f5770985ebbd9e5$var$pnow() {
if ($3f5770985ebbd9e5$export$a5e55367be404707 !== null) return $3f5770985ebbd9e5$export$a5e55367be404707;
else return performance.now();
}
function $3f5770985ebbd9e5$var$timeout(callback, ms) {
if ($3f5770985ebbd9e5$export$a5e55367be404707 !== null) {
const schd = {
cb: callback,
from: $3f5770985ebbd9e5$export$a5e55367be404707,
dur: ms
};
$3f5770985ebbd9e5$var$scheduled.push(schd);
} else setTimeout(callback, ms);
}
class $3f5770985ebbd9e5$export$fd55ce593607084a {
running = false;
ticker = new (0, $jOzOc$BehaviorSubject)(undefined);
startAt = 0;
endAt = 0;
constructor(step, ticker){
ticker.pipe((0, $jOzOc$map)(this.recalc.bind(this))).subscribe({
next: (val)=>{
this.ticker.next(val);
}
});
this._update(step);
}
recalc(t) {
if (!this.running) return undefined;
return {
started: t >= this.startAt,
ended: t >= this.endAt,
ellapsed: Math.round(t - this.startAt),
remaining: Math.round(this.endAt - t),
duration: this.endAt - this.startAt
};
}
obs() {
return this.ticker;
}
get current() {
return this.recalc($3f5770985ebbd9e5$var$pnow());
}
// internal only
_update(step) {
if (!step.running) {
this.running = false;
this.ticker.next(undefined);
return;
}
if (step.ellapsed === null || step.remaining === null || step.ellapsed === undefined || step.remaining === undefined) {
this.running = false;
return;
}
const now = $3f5770985ebbd9e5$var$pnow();
this.startAt = now - step.ellapsed * 1000;
this.endAt = now + step.remaining * 1000;
this.running = step.ellapsed >= 0 && step.remaining >= 0;
this.ticker.next(this.recalc(now));
}
// internal only
_stop() {
this.running = false;
this.ticker.next(undefined);
}
}
class $3f5770985ebbd9e5$export$fb587a27d5a722e7 {
steps = new Map();
updates = new Map();
constructor(stepsObs, donesObs){
stepsObs.subscribe({
next: ({ step: step , removed: removed })=>{
this.update(step, removed);
}
});
donesObs.subscribe({
next: ()=>{
this.next();
}
});
this.ticker = new (0, $jOzOc$BehaviorSubject)(Math.floor($3f5770985ebbd9e5$var$pnow()));
const controller = new AbortController();
$3f5770985ebbd9e5$var$timerInterval(1000, controller.signal, (t)=>{
this.ticker.next(t);
});
}
step(stepID) {
return this.steps.get(stepID);
}
update(step, removed) {
if (removed) this.updates.set(step.id, true);
else this.updates.set(step.id, step);
}
next() {
for (const [id, stepOrDel] of this.updates){
let step = this.steps.get(id);
if (typeof stepOrDel === "boolean") {
if (step) {
step._stop();
this.steps.delete(id);
}
} else {
if (!step) {
step = new $3f5770985ebbd9e5$export$fd55ce593607084a(stepOrDel, this.ticker);
this.steps.set(id, step);
}
step._update(stepOrDel);
}
}
this.updates.clear();
}
}
const $3f5770985ebbd9e5$export$e8e78c978b129247 = typeof self === "object" && self.self == self ? self : typeof $parcel$global === "object" && $parcel$global.global == $parcel$global ? $parcel$global : {};
// nodejs support
if (!$3f5770985ebbd9e5$export$e8e78c978b129247["requestAnimationFrame"]) $3f5770985ebbd9e5$export$e8e78c978b129247["requestAnimationFrame"] = (cb)=>cb($3f5770985ebbd9e5$var$pnow());
// Inspiration:
// https://www.youtube.com/watch?v=MCi6AZMkxcU
// https://gist.github.com/jakearchibald/cb03f15670817001b1157e62a076fe95
function $3f5770985ebbd9e5$var$timerInterval(ms = 1000, signal, callback) {
// Performance should be available in Nodejs 10+.
// Get the last rounded second, which will go negative, but that's fine, since
// it will immediately send out its first tick, then be on the second.
const start = Math.floor($3f5770985ebbd9e5$var$pnow() / 1000) * 1000;
function frame(time) {
/* c8 ignore next */ if (signal.aborted) return;
callback(time);
scheduleFrame(time);
}
function scheduleFrame(time) {
const elapsed = time - start;
const roundedElapsed = Math.round(elapsed / ms) * ms;
const targetNext = start + roundedElapsed + ms;
const delay = targetNext - $3f5770985ebbd9e5$var$pnow();
$3f5770985ebbd9e5$var$timeout(()=>requestAnimationFrame(frame), delay);
}
scheduleFrame(start);
} // export function useAnimationInterval(
// ms: number,
// callback: (time: number) => void
// ) {
// const callbackRef = React.useRef(callback);
// React.useEffect(() => {
// callbackRef.current = callback;
// }, [callback]);
// React.useEffect(() => {
// const controller = new AbortController();
// animationInterval(ms, controller.signal, callbackRef.current);
// return () => controller.abort();
// }, [ms]);
// }
export {$7cb1a807542520c7$export$ab9c25261cd8c720 as Attribute, $7cb1a807542520c7$export$21991851b0bb231f as Attributes, $dab56e532931ce2a$export$cceeabf822b64fc0 as Globals, $9c1ce6385a03e42f$export$d31e58fbd756e9f7 as TajribaProvider, $0e423146924dff20$export$775b6bb06e53a214 as Scope, $0e423146924dff20$export$8546186883d6ff3e as Scopes, $3f5770985ebbd9e5$export$fd55ce593607084a as Step, $3f5770985ebbd9e5$export$fb587a27d5a722e7 as Steps};
//# sourceMappingURL=player.js.map
//# sourceMappingURL=player.js.map
{
"name": "@empirica/core",
"version": "1.0.0-beta.1",
"version": "1.0.0-rc.1",
"description": "Empirica Core",

@@ -27,21 +27,53 @@ "author": "Nicolas Paton <nicolas.paton@gmail.com>",

"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./console": {
"import": "./dist/console.js"
"types": "./dist/console.d.ts",
"import": "./dist/console.js",
"require": "./dist/console.cjs"
},
"./player": {
"import": "./dist/player.js"
"types": "./dist/player.d.ts",
"import": "./dist/player.js",
"require": "./dist/player.cjs"
},
"./player/react": {
"types": "./dist/player-react.d.ts",
"import": "./dist/player-react.js",
"require": "./dist/player-react.cjs"
},
"./player/classic": {
"import": "./dist/player-classic.js"
"types": "./dist/player-classic.d.ts",
"import": "./dist/player-classic.js",
"require": "./dist/player-classic.cjs"
},
"./player/classic/react": {
"types": "./dist/player-classic-react.d.ts",
"import": "./dist/player-classic-react.js",
"require": "./dist/player-classic-react.cjs"
},
"./user": {
"types": "./dist/user.d.ts",
"import": "./dist/user.js",
"require": "./dist/user.cjs"
},
"./admin": {
"import": "./dist/admin.js"
"types": "./dist/admin.d.ts",
"import": "./dist/admin.js",
"require": "./dist/admin.cjs"
},
"./admin/classic": {
"import": "./dist/admin-classic.js"
"types": "./dist/admin-classic.d.ts",
"import": "./dist/admin-classic.js",
"require": "./dist/admin-classic.cjs"
}
},
"types": "dist/types.d.ts",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"player": "dist/player.js",
"player-react": "dist/player-react.js",
"player-classic": "dist/player-classic.js",
"player-classic-react": "dist/player-classic-react.js",
"admin": "dist/admin.js",

@@ -51,2 +83,8 @@ "admin-classic": "dist/admin-classic.js",

"targets": {
"main": {
"source": "src/index.ts",
"isLibrary": true,
"outputFormat": "esmodule",
"sourceMap": true
},
"player": {

@@ -58,2 +96,8 @@ "source": "src/player/index.ts",

},
"player-react": {
"source": "src/player/react/index.ts",
"isLibrary": true,
"outputFormat": "esmodule",
"sourceMap": true
},
"player-classic": {

@@ -65,2 +109,8 @@ "source": "src/player/classic/index.ts",

},
"player-classic-react": {
"source": "src/player/classic/react/index.ts",
"isLibrary": true,
"outputFormat": "esmodule",
"sourceMap": true
},
"admin": {

@@ -86,4 +136,4 @@ "source": "src/admin/index.ts",

"volta": {
"node": "16.15.0",
"npm": "8.10.0"
"node": "16.15.1",
"npm": "8.11.0"
},

@@ -115,5 +165,8 @@ "engines": {

"scripts": {
"build": "parcel build",
"pkg": "parcel build",
"build:parcel": "rm -rf dist && npm run pkg",
"build": "tsup --entry.index src/index.ts --entry.user src/admin/user.ts --entry.admin src/admin/index.ts --entry.admin-classic src/admin/classic/index.ts --entry.player src/player/index.ts --entry.player-react src/player/react/index.ts --entry.player-classic src/player/classic/index.ts --entry.player-classic-react src/player/classic/react/index.ts --entry.console src/utils/console.ts --dts --format esm,cjs --clean --sourcemap true",
"check": "tsc --noEmit",
"test": "NODE_NO_WARNINGS=1 TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true c8 -r lcov -r html ava -v",
"test:real": "NODE_NO_WARNINGS=1 TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true c8 -r lcov -r html ava -v",
"test": "echo 'tests temporarily disabled'",
"test:watch": "NODE_NO_WARNINGS=1 TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true ava --watch -v",

@@ -125,4 +178,4 @@ "prerelease": "npm run build",

"devDependencies": {
"@parcel/packager-ts": "^2.6.1",
"@parcel/transformer-typescript-types": "^2.6.1",
"@parcel/packager-ts": "2.6.2",
"@parcel/transformer-typescript-types": "2.6.2",
"@testing-library/react": "13.3.0",

@@ -136,12 +189,12 @@ "@types/node": "18.0.0",

"jsdom": "20.0.0",
"np": "7.6.1",
"parcel": "2.6.1",
"np": "7.6.2",
"parcel": "2.6.2",
"prettier": "2.7.1",
"sinon": "14.0.0",
"ts-node": "10.8.1",
"tsup": "6.1.2",
"typescript": "4.7.4"
},
"dependencies": {
"@empirica/tajriba": "^1.0.0-alpha.4",
"@react-hook/mouse-position": "4.1.3",
"@empirica/tajriba": "^1.0.0-rc.1",
"@swc/helpers": "0.4.2",

@@ -148,0 +201,0 @@ "rxjs": "7.5.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc