@quizpot/quizcore 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -7
- package/dist/index.cjs +582 -0
- package/dist/index.d.cts +472 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +472 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +522 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/events/client/host/kick-player.d.ts +0 -8
- package/dist/events/client/host/kick-player.d.ts.map +0 -1
- package/dist/events/client/host/kick-player.js +0 -4
- package/dist/events/client/host/next-step.d.ts +0 -5
- package/dist/events/client/host/next-step.d.ts.map +0 -1
- package/dist/events/client/host/next-step.js +0 -3
- package/dist/events/client/host/start-lobby.d.ts +0 -6
- package/dist/events/client/host/start-lobby.d.ts.map +0 -1
- package/dist/events/client/host/start-lobby.js +0 -4
- package/dist/events/client/player/submit-answer.d.ts +0 -9
- package/dist/events/client/player/submit-answer.d.ts.map +0 -1
- package/dist/events/client/player/submit-answer.js +0 -4
- package/dist/events/server/lobby-deleted.d.ts +0 -8
- package/dist/events/server/lobby-deleted.d.ts.map +0 -1
- package/dist/events/server/lobby-deleted.js +0 -4
- package/dist/events/server/lobby-joined.d.ts +0 -14
- package/dist/events/server/lobby-joined.d.ts.map +0 -1
- package/dist/events/server/lobby-joined.js +0 -18
- package/dist/events/server/lobby-status-update.d.ts +0 -32
- package/dist/events/server/lobby-status-update.d.ts.map +0 -1
- package/dist/events/server/lobby-status-update.js +0 -4
- package/dist/events/server/player-answer-result.d.ts +0 -11
- package/dist/events/server/player-answer-result.d.ts.map +0 -1
- package/dist/events/server/player-answer-result.js +0 -4
- package/dist/events/server/player-joined.d.ts +0 -9
- package/dist/events/server/player-joined.d.ts.map +0 -1
- package/dist/events/server/player-joined.js +0 -4
- package/dist/events/server/player-kicked.d.ts +0 -6
- package/dist/events/server/player-kicked.d.ts.map +0 -1
- package/dist/events/server/player-kicked.js +0 -4
- package/dist/events/server/player-left.d.ts +0 -9
- package/dist/events/server/player-left.d.ts.map +0 -1
- package/dist/events/server/player-left.js +0 -4
- package/dist/events/server/player-update.d.ts +0 -9
- package/dist/events/server/player-update.d.ts.map +0 -1
- package/dist/events/server/player-update.js +0 -4
- package/dist/events/server/update-lobby-answers.d.ts +0 -8
- package/dist/events/server/update-lobby-answers.d.ts.map +0 -1
- package/dist/events/server/update-lobby-answers.js +0 -4
- package/dist/index.d.ts +0 -26
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -25
- package/dist/managers/lobby-manager.d.ts +0 -12
- package/dist/managers/lobby-manager.d.ts.map +0 -1
- package/dist/managers/lobby-manager.js +0 -112
- package/dist/questions/multiple-choice.d.ts +0 -22
- package/dist/questions/multiple-choice.d.ts.map +0 -1
- package/dist/questions/multiple-choice.js +0 -1
- package/dist/questions/short-answer.d.ts +0 -12
- package/dist/questions/short-answer.d.ts.map +0 -1
- package/dist/questions/short-answer.js +0 -1
- package/dist/questions/true-false.d.ts +0 -12
- package/dist/questions/true-false.d.ts.map +0 -1
- package/dist/questions/true-false.js +0 -1
- package/dist/schemas/quizfile.d.ts +0 -87
- package/dist/schemas/quizfile.d.ts.map +0 -1
- package/dist/schemas/quizfile.js +0 -55
- package/dist/slides/comparison.d.ts +0 -9
- package/dist/slides/comparison.d.ts.map +0 -1
- package/dist/slides/comparison.js +0 -7
- package/dist/slides/titleImageTextSlide.d.ts +0 -9
- package/dist/slides/titleImageTextSlide.d.ts.map +0 -1
- package/dist/slides/titleImageTextSlide.js +0 -7
- package/dist/slides/titleSlide.d.ts +0 -8
- package/dist/slides/titleSlide.d.ts.map +0 -1
- package/dist/slides/titleSlide.js +0 -6
- package/dist/types/events.d.ts +0 -16
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -1
- package/dist/types/lobby.d.ts +0 -42
- package/dist/types/lobby.d.ts.map +0 -1
- package/dist/types/lobby.js +0 -10
- package/dist/types/question.d.ts +0 -106
- package/dist/types/question.d.ts.map +0 -1
- package/dist/types/question.js +0 -22
- package/dist/types/questions/multiple-choice.d.ts +0 -51
- package/dist/types/questions/multiple-choice.d.ts.map +0 -1
- package/dist/types/questions/multiple-choice.js +0 -21
- package/dist/types/questions/short-answer.d.ts +0 -34
- package/dist/types/questions/short-answer.d.ts.map +0 -1
- package/dist/types/questions/short-answer.js +0 -11
- package/dist/types/questions/true-false.d.ts +0 -36
- package/dist/types/questions/true-false.d.ts.map +0 -1
- package/dist/types/questions/true-false.js +0 -12
- package/dist/types/quizfile.d.ts +0 -79
- package/dist/types/quizfile.d.ts.map +0 -1
- package/dist/types/quizfile.js +0 -23
- package/dist/types/quizstep.d.ts +0 -73
- package/dist/types/quizstep.d.ts.map +0 -1
- package/dist/types/quizstep.js +0 -7
- package/dist/types/quiztheme.d.ts +0 -7
- package/dist/types/quiztheme.d.ts.map +0 -1
- package/dist/types/quiztheme.js +0 -5
- package/dist/types/slide.d.ts +0 -18
- package/dist/types/slide.d.ts.map +0 -1
- package/dist/types/slide.js +0 -9
- package/dist/types/slides/comparison.d.ts +0 -9
- package/dist/types/slides/comparison.d.ts.map +0 -1
- package/dist/types/slides/comparison.js +0 -7
- package/dist/types/slides/titleImageTextSlide.d.ts +0 -9
- package/dist/types/slides/titleImageTextSlide.d.ts.map +0 -1
- package/dist/types/slides/titleImageTextSlide.js +0 -7
- package/dist/types/slides/titleSlide.d.ts +0 -8
- package/dist/types/slides/titleSlide.d.ts.map +0 -1
- package/dist/types/slides/titleSlide.js +0 -6
- package/dist/util/guards.d.ts +0 -18
- package/dist/util/guards.d.ts.map +0 -1
- package/dist/util/guards.js +0 -15
- package/dist/util/names/additives.json +0 -23
- package/dist/util/names/animals.json +0 -23
- package/dist/util/names/colors.json +0 -14
- package/dist/util/names/names.d.ts +0 -4
- package/dist/util/names/names.d.ts.map +0 -1
- package/dist/util/names/names.js +0 -31
- package/dist/util/sanitizer.d.ts +0 -3
- package/dist/util/sanitizer.d.ts.map +0 -1
- package/dist/util/sanitizer.js +0 -18
- package/dist/util/score.d.ts +0 -11
- package/dist/util/score.d.ts.map +0 -1
- package/dist/util/score.js +0 -33
- package/dist/util/validator.d.ts +0 -14
- package/dist/util/validator.d.ts.map +0 -1
- package/dist/util/validator.js +0 -27
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SubmittedAnswer } from "../../../util/validator";
|
|
2
|
-
export type SubmitAnswer = {
|
|
3
|
-
type: "SUBMIT_ANSWER";
|
|
4
|
-
payload: {
|
|
5
|
-
submission: SubmittedAnswer;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const createSubmitAnswerEvent: (submission: SubmittedAnswer) => SubmitAnswer;
|
|
9
|
-
//# sourceMappingURL=submit-answer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"submit-answer.d.ts","sourceRoot":"","sources":["../../../../src/events/client/player/submit-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE;QAAE,UAAU,EAAE,eAAe,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,YAAY,eAAe,KAAG,YAGpE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lobby-deleted.d.ts","sourceRoot":"","sources":["../../../src/events/server/lobby-deleted.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,YAGvD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Lobby, Player } from "../../types/lobby";
|
|
2
|
-
import { Answer } from "../../util/validator";
|
|
3
|
-
export type LobbyJoined = {
|
|
4
|
-
type: "LOBBY_JOINED";
|
|
5
|
-
payload: {
|
|
6
|
-
lobby: Omit<Lobby, "host" | "quiz" | "players" | "currentAnswers" | "answers">;
|
|
7
|
-
me?: Player;
|
|
8
|
-
players?: Player[];
|
|
9
|
-
currentAnswers?: Answer[];
|
|
10
|
-
answers?: Answer[];
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare const createLobbyJoinedEvent: (lobby: Lobby, me: Player, isHost: boolean) => LobbyJoined;
|
|
14
|
-
//# sourceMappingURL=lobby-joined.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lobby-joined.d.ts","sourceRoot":"","sources":["../../../src/events/server/lobby-joined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE;QACP,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAAC,CAAC;QAC/E,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,OAAO,KAAK,EACZ,IAAI,MAAM,EACV,QAAQ,OAAO,KACd,WAiBD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const createLobbyJoinedEvent = (lobby, me, isHost) => ({
|
|
2
|
-
type: "LOBBY_JOINED",
|
|
3
|
-
payload: {
|
|
4
|
-
lobby: {
|
|
5
|
-
code: lobby.code,
|
|
6
|
-
quizInfo: lobby.quizInfo,
|
|
7
|
-
status: lobby.status,
|
|
8
|
-
timeoutStartedAt: lobby.timeoutStartedAt,
|
|
9
|
-
duration: lobby.duration,
|
|
10
|
-
currentStep: lobby.currentStep,
|
|
11
|
-
settings: lobby.settings,
|
|
12
|
-
},
|
|
13
|
-
me,
|
|
14
|
-
players: isHost ? lobby.players : undefined,
|
|
15
|
-
currentAnswers: isHost ? lobby.currentAnswers : undefined,
|
|
16
|
-
answers: isHost ? lobby.answers : undefined,
|
|
17
|
-
}
|
|
18
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { LobbyStatus, Player } from "../../types/lobby";
|
|
2
|
-
import { SafeQuestion } from "../../types/question";
|
|
3
|
-
import { Slide } from "../../types/slide";
|
|
4
|
-
import { Answer } from "../../util/validator";
|
|
5
|
-
export type LobbyStatusUpdate = {
|
|
6
|
-
type: "LOBBY_STATUS_UPDATE";
|
|
7
|
-
payload: {
|
|
8
|
-
status: LobbyStatus.waiting;
|
|
9
|
-
} | {
|
|
10
|
-
status: LobbyStatus.slide;
|
|
11
|
-
slide: Slide;
|
|
12
|
-
} | {
|
|
13
|
-
status: LobbyStatus.question;
|
|
14
|
-
question: SafeQuestion;
|
|
15
|
-
timeoutStartedAt: number;
|
|
16
|
-
duration: number;
|
|
17
|
-
} | {
|
|
18
|
-
status: LobbyStatus.answer;
|
|
19
|
-
timeoutStartedAt: number;
|
|
20
|
-
duration: number;
|
|
21
|
-
} | {
|
|
22
|
-
status: LobbyStatus.answers;
|
|
23
|
-
answers: Answer[];
|
|
24
|
-
} | {
|
|
25
|
-
status: LobbyStatus.score;
|
|
26
|
-
leaderboard: Player[];
|
|
27
|
-
} | {
|
|
28
|
-
status: LobbyStatus.end;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export declare const createLobbyStatusUpdateEvent: (payload: LobbyStatusUpdate["payload"]) => LobbyStatusUpdate;
|
|
32
|
-
//# sourceMappingURL=lobby-status-update.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lobby-status-update.d.ts","sourceRoot":"","sources":["../../../src/events/server/lobby-status-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EACH;QAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAA;KAAE,GAC/B;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,GAC3C;QAAE,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACpG;QAAE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAC1E;QAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAClD;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,GACpD;QAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAA;KAAE,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,SAAS,iBAAiB,CAAC,SAAS,CAAC,KACpC,iBAGD,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type PlayerAnswerResult = {
|
|
2
|
-
type: "PLAYER_ANSWER_RESULT";
|
|
3
|
-
payload: {
|
|
4
|
-
isCorrect: boolean;
|
|
5
|
-
pointsAwarded: number;
|
|
6
|
-
score: number;
|
|
7
|
-
streak: number;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare const createPlayerAnswerResultEvent: (isCorrect: boolean, pointsAwarded: number, score: number, streak: number) => PlayerAnswerResult;
|
|
11
|
-
//# sourceMappingURL=player-answer-result.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-answer-result.d.ts","sourceRoot":"","sources":["../../../src/events/server/player-answer-result.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE;QACP,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,WAAW,OAAO,EAClB,eAAe,MAAM,EACrB,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,kBAGD,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Player } from "../../types/lobby";
|
|
2
|
-
export type PlayerJoined = {
|
|
3
|
-
type: "PLAYER_JOINED";
|
|
4
|
-
payload: {
|
|
5
|
-
player: Player;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const createPlayerJoinedEvent: (player: Player) => PlayerJoined;
|
|
9
|
-
//# sourceMappingURL=player-joined.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-joined.d.ts","sourceRoot":"","sources":["../../../src/events/server/player-joined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,YAGvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-kicked.d.ts","sourceRoot":"","sources":["../../../src/events/server/player-kicked.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAO,YAGzC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-left.d.ts","sourceRoot":"","sources":["../../../src/events/server/player-left.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,UAGrD,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Player } from "../../types/lobby";
|
|
2
|
-
export type PlayerUpdate = {
|
|
3
|
-
type: "PLAYER_UPDATE";
|
|
4
|
-
payload: {
|
|
5
|
-
player: Player;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const createPlayerUpdateEvent: (player: Player) => PlayerUpdate;
|
|
9
|
-
//# sourceMappingURL=player-update.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"player-update.d.ts","sourceRoot":"","sources":["../../../src/events/server/player-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,YAGvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-lobby-answers.d.ts","sourceRoot":"","sources":["../../../src/events/server/update-lobby-answers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,KAAG,kBAG5D,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export * from './events/client/host/kick-player';
|
|
2
|
-
export * from './events/client/host/next-step';
|
|
3
|
-
export * from './events/client/host/start-lobby';
|
|
4
|
-
export * from './events/client/player/submit-answer';
|
|
5
|
-
export * from './events/server/lobby-deleted';
|
|
6
|
-
export * from './events/server/lobby-joined';
|
|
7
|
-
export * from './events/server/lobby-status-update';
|
|
8
|
-
export * from './events/server/player-answer-result';
|
|
9
|
-
export * from './events/server/player-joined';
|
|
10
|
-
export * from './events/server/player-kicked';
|
|
11
|
-
export * from './events/server/player-left';
|
|
12
|
-
export * from './events/server/player-update';
|
|
13
|
-
export * from './events/server/update-lobby-answers';
|
|
14
|
-
export * from './managers/lobby-manager';
|
|
15
|
-
export * from './types/questions/multiple-choice';
|
|
16
|
-
export * from './types/questions/short-answer';
|
|
17
|
-
export * from './types/questions/true-false';
|
|
18
|
-
export * from './types/events';
|
|
19
|
-
export * from './types/lobby';
|
|
20
|
-
export * from './types/quizfile';
|
|
21
|
-
export * from './util/guards';
|
|
22
|
-
export * from './util/names/names';
|
|
23
|
-
export * from './util/sanitizer';
|
|
24
|
-
export * from './util/score';
|
|
25
|
-
export * from './util/validator';
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export * from './events/client/host/kick-player';
|
|
2
|
-
export * from './events/client/host/next-step';
|
|
3
|
-
export * from './events/client/host/start-lobby';
|
|
4
|
-
export * from './events/client/player/submit-answer';
|
|
5
|
-
export * from './events/server/lobby-deleted';
|
|
6
|
-
export * from './events/server/lobby-joined';
|
|
7
|
-
export * from './events/server/lobby-status-update';
|
|
8
|
-
export * from './events/server/player-answer-result';
|
|
9
|
-
export * from './events/server/player-joined';
|
|
10
|
-
export * from './events/server/player-kicked';
|
|
11
|
-
export * from './events/server/player-left';
|
|
12
|
-
export * from './events/server/player-update';
|
|
13
|
-
export * from './events/server/update-lobby-answers';
|
|
14
|
-
export * from './managers/lobby-manager';
|
|
15
|
-
export * from './types/questions/multiple-choice';
|
|
16
|
-
export * from './types/questions/short-answer';
|
|
17
|
-
export * from './types/questions/true-false';
|
|
18
|
-
export * from './types/events';
|
|
19
|
-
export * from './types/lobby';
|
|
20
|
-
export * from './types/quizfile';
|
|
21
|
-
export * from './util/guards';
|
|
22
|
-
export * from './util/names/names';
|
|
23
|
-
export * from './util/sanitizer';
|
|
24
|
-
export * from './util/score';
|
|
25
|
-
export * from './util/validator';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PlayerAnswerResult } from "../events/server/player-answer-result";
|
|
2
|
-
import { Lobby } from "../types/lobby";
|
|
3
|
-
import { QuizFile } from "../types/quizfile";
|
|
4
|
-
import { SubmittedAnswer } from "../util/validator";
|
|
5
|
-
export declare const createLobby: (code: string, hostId: string, quiz: QuizFile) => Lobby;
|
|
6
|
-
export declare const advanceLobby: (lobby: Lobby) => Lobby;
|
|
7
|
-
export type SubmissionResult = {
|
|
8
|
-
nextLobby: Lobby;
|
|
9
|
-
result: PlayerAnswerResult;
|
|
10
|
-
};
|
|
11
|
-
export declare const handleSubmission: (lobby: Lobby, playerId: string, submission: SubmittedAnswer) => SubmissionResult | null;
|
|
12
|
-
//# sourceMappingURL=lobby-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lobby-manager.d.ts","sourceRoot":"","sources":["../../src/managers/lobby-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAe,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAqB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEvE,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,MAAM,QAAQ,KACb,KAiBD,CAAC;AAEH,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,KAmC3C,CAAC;AA0BF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,KAAK,EACZ,UAAU,MAAM,EAChB,YAAY,eAAe,KAC1B,gBAAgB,GAAG,IA0CrB,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { LobbyStatus } from "../types/lobby";
|
|
2
|
-
import { isQuestion } from "../util/guards";
|
|
3
|
-
import { calculateScore } from "../util/score";
|
|
4
|
-
import { isCorrect } from "../util/validator";
|
|
5
|
-
export const createLobby = (code, hostId, quiz) => ({
|
|
6
|
-
code,
|
|
7
|
-
host: hostId,
|
|
8
|
-
quiz,
|
|
9
|
-
quizInfo: {
|
|
10
|
-
title: quiz.title,
|
|
11
|
-
stepCount: quiz.steps.length,
|
|
12
|
-
theme: quiz.theme
|
|
13
|
-
},
|
|
14
|
-
players: [],
|
|
15
|
-
status: LobbyStatus.waiting,
|
|
16
|
-
currentStep: 0,
|
|
17
|
-
timeoutStartedAt: null,
|
|
18
|
-
duration: null,
|
|
19
|
-
currentAnswers: [],
|
|
20
|
-
answers: [],
|
|
21
|
-
settings: { customNames: true, displayOnDevice: true }
|
|
22
|
-
});
|
|
23
|
-
export const advanceLobby = (lobby) => {
|
|
24
|
-
const isLastStep = lobby.currentStep >= lobby.quiz.steps.length - 1;
|
|
25
|
-
switch (lobby.status) {
|
|
26
|
-
case LobbyStatus.waiting:
|
|
27
|
-
return prepareStep(lobby, 0);
|
|
28
|
-
case LobbyStatus.slide:
|
|
29
|
-
case LobbyStatus.score:
|
|
30
|
-
return isLastStep
|
|
31
|
-
? { ...lobby, status: LobbyStatus.end }
|
|
32
|
-
: prepareStep(lobby, lobby.currentStep + 1);
|
|
33
|
-
case LobbyStatus.question: {
|
|
34
|
-
const step = lobby.quiz.steps[lobby.currentStep];
|
|
35
|
-
if (step.type !== 'question')
|
|
36
|
-
return lobby;
|
|
37
|
-
return {
|
|
38
|
-
...lobby,
|
|
39
|
-
status: LobbyStatus.answer,
|
|
40
|
-
timeoutStartedAt: Date.now(),
|
|
41
|
-
duration: step.data.timeLimit * 1000,
|
|
42
|
-
currentAnswers: []
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
case LobbyStatus.answer:
|
|
46
|
-
return { ...lobby, status: LobbyStatus.answers };
|
|
47
|
-
case LobbyStatus.answers:
|
|
48
|
-
return { ...lobby, status: LobbyStatus.score };
|
|
49
|
-
default:
|
|
50
|
-
return lobby;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// Prepares the lobby for the next step
|
|
54
|
-
const prepareStep = (lobby, index) => {
|
|
55
|
-
const step = lobby.quiz.steps[index];
|
|
56
|
-
if (!step)
|
|
57
|
-
return lobby;
|
|
58
|
-
if (step.type === "slide") {
|
|
59
|
-
return {
|
|
60
|
-
...lobby,
|
|
61
|
-
status: LobbyStatus.slide,
|
|
62
|
-
currentStep: index
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
...lobby,
|
|
67
|
-
status: LobbyStatus.question,
|
|
68
|
-
currentStep: index,
|
|
69
|
-
timeoutStartedAt: null,
|
|
70
|
-
duration: null,
|
|
71
|
-
currentAnswers: []
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export const handleSubmission = (lobby, playerId, submission) => {
|
|
75
|
-
if (lobby.status !== LobbyStatus.answer)
|
|
76
|
-
return null;
|
|
77
|
-
const step = lobby.quiz.steps[lobby.currentStep];
|
|
78
|
-
if (!isQuestion(step))
|
|
79
|
-
return null;
|
|
80
|
-
const player = lobby.players.find(p => p.id === playerId);
|
|
81
|
-
if (!player)
|
|
82
|
-
return null;
|
|
83
|
-
if (lobby.currentAnswers.some(a => a.playerId === playerId))
|
|
84
|
-
return null;
|
|
85
|
-
const correct = isCorrect(step.data, submission);
|
|
86
|
-
const timeTaken = Date.now() - (lobby.timeoutStartedAt ?? 0);
|
|
87
|
-
const answerObj = {
|
|
88
|
-
playerId,
|
|
89
|
-
submission,
|
|
90
|
-
timeTaken,
|
|
91
|
-
isCorrect: correct,
|
|
92
|
-
pointsAwarded: 0
|
|
93
|
-
};
|
|
94
|
-
const { newScore, pointsAwarded } = calculateScore(player, step.data, answerObj, lobby.quiz);
|
|
95
|
-
answerObj.pointsAwarded = pointsAwarded;
|
|
96
|
-
const nextLobby = {
|
|
97
|
-
...lobby,
|
|
98
|
-
players: lobby.players.map(p => p.id === playerId ? {
|
|
99
|
-
...p,
|
|
100
|
-
score: newScore,
|
|
101
|
-
streak: correct ? p.streak + 1 : 0
|
|
102
|
-
} : p),
|
|
103
|
-
currentAnswers: [...lobby.currentAnswers, answerObj]
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
nextLobby,
|
|
107
|
-
result: {
|
|
108
|
-
type: "PLAYER_ANSWER_RESULT",
|
|
109
|
-
payload: { isCorrect: correct, pointsAwarded, score: newScore, streak: correct ? player.streak + 1 : 0 }
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseQuestion } from "../types/quizfile";
|
|
2
|
-
export interface MultipleChoiceQuestion extends BaseQuestion {
|
|
3
|
-
questionType: "multipleChoice";
|
|
4
|
-
choices: Choice[];
|
|
5
|
-
matchAll: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface Choice {
|
|
8
|
-
text: string;
|
|
9
|
-
correct: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface SafeMultipleChoiceQuestion extends Omit<MultipleChoiceQuestion, "choices"> {
|
|
12
|
-
choices: SafeChoice[];
|
|
13
|
-
matchAll: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface SafeChoice {
|
|
16
|
-
text: string;
|
|
17
|
-
}
|
|
18
|
-
export interface MultipleChoiceQuestionAnswer {
|
|
19
|
-
type: "multipleChoice";
|
|
20
|
-
choices: number[];
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=multiple-choice.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiple-choice.d.ts","sourceRoot":"","sources":["../../src/questions/multiple-choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D,YAAY,EAAE,gBAAgB,CAAC;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,SAAS,CAAC;IACzF,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseQuestion } from "../types/quizfile";
|
|
2
|
-
export interface ShortAnswerQuestion extends BaseQuestion {
|
|
3
|
-
questionType: "shortAnswer";
|
|
4
|
-
answers: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface SafeShortAnswerQuestion extends Omit<ShortAnswerQuestion, "answers"> {
|
|
7
|
-
}
|
|
8
|
-
export interface ShortAnswerQuestionAnswer {
|
|
9
|
-
type: "shortAnswer";
|
|
10
|
-
answer: string;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=short-answer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"short-answer.d.ts","sourceRoot":"","sources":["../../src/questions/short-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,YAAY,EAAE,aAAa,CAAC;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC;CAAG;AAExF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseQuestion } from "../types/quizfile";
|
|
2
|
-
export interface TrueFalseQuestion extends BaseQuestion {
|
|
3
|
-
questionType: "trueFalse";
|
|
4
|
-
answer: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface SafeTrueFalseQuestion extends Omit<TrueFalseQuestion, "answer"> {
|
|
7
|
-
}
|
|
8
|
-
export interface TrueFalseQuestionAnswer {
|
|
9
|
-
type: "trueFalse";
|
|
10
|
-
answer: boolean;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=true-false.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"true-false.d.ts","sourceRoot":"","sources":["../../src/questions/true-false.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,YAAY,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;CAAG;AAEnF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const QuizFileSchema: z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
version: z.ZodLiteral<2>;
|
|
5
|
-
title: z.ZodString;
|
|
6
|
-
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
theme: z.ZodObject<{
|
|
8
|
-
color: z.ZodString;
|
|
9
|
-
background: z.ZodOptional<z.ZodString>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
language: z.ZodString;
|
|
12
|
-
steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
|
-
type: z.ZodLiteral<"question">;
|
|
14
|
-
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
15
|
-
question: z.ZodString;
|
|
16
|
-
imageHash: z.ZodOptional<z.ZodString>;
|
|
17
|
-
displayTime: z.ZodNumber;
|
|
18
|
-
timeLimit: z.ZodNumber;
|
|
19
|
-
points: z.ZodEnum<{
|
|
20
|
-
normalPoints: "normalPoints";
|
|
21
|
-
doublePoints: "doublePoints";
|
|
22
|
-
noPoints: "noPoints";
|
|
23
|
-
}>;
|
|
24
|
-
type: z.ZodLiteral<"multiple-choice">;
|
|
25
|
-
options: z.ZodArray<z.ZodObject<{
|
|
26
|
-
id: z.ZodString;
|
|
27
|
-
text: z.ZodString;
|
|
28
|
-
isCorrect: z.ZodBoolean;
|
|
29
|
-
}, z.core.$strip>>;
|
|
30
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
-
question: z.ZodString;
|
|
32
|
-
imageHash: z.ZodOptional<z.ZodString>;
|
|
33
|
-
displayTime: z.ZodNumber;
|
|
34
|
-
timeLimit: z.ZodNumber;
|
|
35
|
-
points: z.ZodEnum<{
|
|
36
|
-
normalPoints: "normalPoints";
|
|
37
|
-
doublePoints: "doublePoints";
|
|
38
|
-
noPoints: "noPoints";
|
|
39
|
-
}>;
|
|
40
|
-
type: z.ZodLiteral<"true-false">;
|
|
41
|
-
answer: z.ZodBoolean;
|
|
42
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
-
question: z.ZodString;
|
|
44
|
-
imageHash: z.ZodOptional<z.ZodString>;
|
|
45
|
-
displayTime: z.ZodNumber;
|
|
46
|
-
timeLimit: z.ZodNumber;
|
|
47
|
-
points: z.ZodEnum<{
|
|
48
|
-
normalPoints: "normalPoints";
|
|
49
|
-
doublePoints: "doublePoints";
|
|
50
|
-
noPoints: "noPoints";
|
|
51
|
-
}>;
|
|
52
|
-
type: z.ZodLiteral<"short-answer">;
|
|
53
|
-
acceptedAnswers: z.ZodArray<z.ZodString>;
|
|
54
|
-
}, z.core.$strip>], "type">;
|
|
55
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
-
type: z.ZodLiteral<"slide">;
|
|
57
|
-
data: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
-
slideType: z.ZodLiteral<"title">;
|
|
59
|
-
title: z.ZodString;
|
|
60
|
-
subtitle: z.ZodOptional<z.ZodString>;
|
|
61
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
-
slideType: z.ZodLiteral<"titleAndText">;
|
|
63
|
-
title: z.ZodString;
|
|
64
|
-
text: z.ZodString;
|
|
65
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
-
slideType: z.ZodLiteral<"titleAndTextWithImage">;
|
|
67
|
-
title: z.ZodString;
|
|
68
|
-
text: z.ZodString;
|
|
69
|
-
imageHash: z.ZodOptional<z.ZodString>;
|
|
70
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
-
slideType: z.ZodLiteral<"comparison">;
|
|
72
|
-
title: z.ZodString;
|
|
73
|
-
left: z.ZodString;
|
|
74
|
-
right: z.ZodString;
|
|
75
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
76
|
-
slideType: z.ZodLiteral<"titleImageText">;
|
|
77
|
-
title: z.ZodString;
|
|
78
|
-
imageHash: z.ZodOptional<z.ZodString>;
|
|
79
|
-
text: z.ZodString;
|
|
80
|
-
}, z.core.$strip>], "slideType">;
|
|
81
|
-
}, z.core.$strip>], "type">>;
|
|
82
|
-
images: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
83
|
-
updatedAt: z.ZodString;
|
|
84
|
-
createdAt: z.ZodString;
|
|
85
|
-
}, z.core.$strip>;
|
|
86
|
-
export type QuizFile = z.infer<typeof QuizFileSchema>;
|
|
87
|
-
//# sourceMappingURL=quizfile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quizfile.d.ts","sourceRoot":"","sources":["../../src/schemas/quizfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqDxB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWzB,CAAC;AAGH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|