pixospritz-core 0.10.1 → 1.0.1
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 +36 -286
- package/dist/bundle.js +13 -3
- package/dist/bundle.js.map +1 -1
- package/dist/style.css +1 -0
- package/package.json +43 -44
- package/src/components/WebGLView.jsx +318 -0
- package/src/css/pixos.css +372 -0
- package/src/engine/actions/animate.js +41 -0
- package/src/engine/actions/changezone.js +135 -0
- package/src/engine/actions/chat.js +109 -0
- package/src/engine/actions/dialogue.js +90 -0
- package/src/engine/actions/face.js +22 -0
- package/src/engine/actions/greeting.js +28 -0
- package/src/engine/actions/interact.js +86 -0
- package/src/engine/actions/move.js +67 -0
- package/src/engine/actions/patrol.js +109 -0
- package/src/engine/actions/prompt.js +185 -0
- package/src/engine/actions/script.js +42 -0
- package/src/engine/core/audio/AudioSystem.js +543 -0
- package/src/engine/core/cutscene/PxcPlayer.js +956 -0
- package/src/engine/core/cutscene/manager.js +243 -0
- package/src/engine/core/database/index.js +75 -0
- package/src/engine/core/debug/index.js +371 -0
- package/src/engine/core/hud/index.js +765 -0
- package/src/engine/core/index.js +540 -0
- package/src/engine/core/input/gamepad/Controller.js +71 -0
- package/src/engine/core/input/gamepad/ControllerButtons.js +231 -0
- package/src/engine/core/input/gamepad/ControllerStick.js +173 -0
- package/src/engine/core/input/gamepad/index.js +592 -0
- package/src/engine/core/input/keyboard.js +196 -0
- package/src/engine/core/input/manager.js +485 -0
- package/src/engine/core/input/mouse.js +203 -0
- package/src/engine/core/input/touch.js +175 -0
- package/src/engine/core/mode/manager.js +199 -0
- package/src/engine/core/net/manager.js +535 -0
- package/src/engine/core/queue/action.js +83 -0
- package/src/engine/core/queue/event.js +82 -0
- package/src/engine/core/queue/index.js +44 -0
- package/src/engine/core/queue/loadable.js +33 -0
- package/src/engine/core/render/CameraEffects.js +494 -0
- package/src/engine/core/render/FrustumCuller.js +417 -0
- package/src/engine/core/render/LODManager.js +285 -0
- package/src/engine/core/render/ParticleManager.js +529 -0
- package/src/engine/core/render/TextureAtlas.js +465 -0
- package/src/engine/core/render/camera.js +338 -0
- package/src/engine/core/render/light.js +197 -0
- package/src/engine/core/render/manager.js +1079 -0
- package/src/engine/core/render/shaders.js +110 -0
- package/src/engine/core/render/skybox.js +342 -0
- package/src/engine/core/resource/manager.js +133 -0
- package/src/engine/core/resource/object.js +611 -0
- package/src/engine/core/resource/texture.js +103 -0
- package/src/engine/core/resource/tileset.js +177 -0
- package/src/engine/core/scene/avatar.js +215 -0
- package/src/engine/core/scene/speech.js +138 -0
- package/src/engine/core/scene/sprite.js +702 -0
- package/src/engine/core/scene/spritz.js +189 -0
- package/src/engine/core/scene/world.js +681 -0
- package/src/engine/core/scene/zone.js +1167 -0
- package/src/engine/core/store/index.js +110 -0
- package/src/engine/dynamic/animatedSprite.js +64 -0
- package/src/engine/dynamic/animatedTile.js +98 -0
- package/src/engine/dynamic/avatar.js +110 -0
- package/src/engine/dynamic/map.js +174 -0
- package/src/engine/dynamic/sprite.js +255 -0
- package/src/engine/dynamic/spritz.js +119 -0
- package/src/engine/events/EventSystem.js +609 -0
- package/src/engine/events/camera.js +142 -0
- package/src/engine/events/chat.js +75 -0
- package/src/engine/events/menu.js +186 -0
- package/src/engine/scripting/CallbackManager.js +514 -0
- package/src/engine/scripting/PixoScriptInterpreter.js +81 -0
- package/src/engine/scripting/PixoScriptLibrary.js +704 -0
- package/src/engine/shaders/effects/index.js +450 -0
- package/src/engine/shaders/fs.js +222 -0
- package/src/engine/shaders/particles/fs.js +41 -0
- package/src/engine/shaders/particles/vs.js +61 -0
- package/src/engine/shaders/picker/fs.js +34 -0
- package/src/engine/shaders/picker/init.js +62 -0
- package/src/engine/shaders/picker/vs.js +42 -0
- package/src/engine/shaders/pxsl/README.md +250 -0
- package/src/engine/shaders/pxsl/index.js +25 -0
- package/src/engine/shaders/pxsl/library.js +608 -0
- package/src/engine/shaders/pxsl/manager.js +338 -0
- package/src/engine/shaders/pxsl/specification.js +363 -0
- package/src/engine/shaders/pxsl/transpiler.js +753 -0
- package/src/engine/shaders/skybox/cosmic/fs.js +147 -0
- package/src/engine/shaders/skybox/cosmic/vs.js +23 -0
- package/src/engine/shaders/skybox/matrix/fs.js +127 -0
- package/src/engine/shaders/skybox/matrix/vs.js +23 -0
- package/src/engine/shaders/skybox/morning/fs.js +109 -0
- package/src/engine/shaders/skybox/morning/vs.js +23 -0
- package/src/engine/shaders/skybox/neon/fs.js +119 -0
- package/src/engine/shaders/skybox/neon/vs.js +23 -0
- package/src/engine/shaders/skybox/sky/fs.js +114 -0
- package/src/engine/shaders/skybox/sky/vs.js +23 -0
- package/src/engine/shaders/skybox/sunset/fs.js +101 -0
- package/src/engine/shaders/skybox/sunset/vs.js +23 -0
- package/src/engine/shaders/transition/blur/fs.js +42 -0
- package/src/engine/shaders/transition/blur/vs.js +26 -0
- package/src/engine/shaders/transition/cross/fs.js +36 -0
- package/src/engine/shaders/transition/cross/vs.js +26 -0
- package/src/engine/shaders/transition/crossBlur/fs.js +41 -0
- package/src/engine/shaders/transition/crossBlur/vs.js +25 -0
- package/src/engine/shaders/transition/dissolve/fs.js +78 -0
- package/src/engine/shaders/transition/dissolve/vs.js +24 -0
- package/src/engine/shaders/transition/fade/fs.js +31 -0
- package/src/engine/shaders/transition/fade/vs.js +27 -0
- package/src/engine/shaders/transition/iris/fs.js +52 -0
- package/src/engine/shaders/transition/iris/vs.js +24 -0
- package/src/engine/shaders/transition/pixelate/fs.js +44 -0
- package/src/engine/shaders/transition/pixelate/vs.js +24 -0
- package/src/engine/shaders/transition/slide/fs.js +53 -0
- package/src/engine/shaders/transition/slide/vs.js +24 -0
- package/src/engine/shaders/transition/swirl/fs.js +39 -0
- package/src/engine/shaders/transition/swirl/vs.js +26 -0
- package/src/engine/shaders/transition/wipe/fs.js +50 -0
- package/src/engine/shaders/transition/wipe/vs.js +24 -0
- package/src/engine/shaders/vs.js +60 -0
- package/src/engine/utils/CameraController.js +506 -0
- package/src/engine/utils/ObjHelper.js +551 -0
- package/src/engine/utils/debug-logger.js +110 -0
- package/src/engine/utils/enums.js +305 -0
- package/src/engine/utils/generator.js +156 -0
- package/src/engine/utils/index.js +21 -0
- package/src/engine/utils/loaders/ActionLoader.js +77 -0
- package/src/engine/utils/loaders/AudioLoader.js +157 -0
- package/src/engine/utils/loaders/EventLoader.js +66 -0
- package/src/engine/utils/loaders/ObjectLoader.js +67 -0
- package/src/engine/utils/loaders/SpriteLoader.js +77 -0
- package/src/engine/utils/loaders/TilesetLoader.js +103 -0
- package/src/engine/utils/loaders/index.js +21 -0
- package/src/engine/utils/math/matrix4.js +367 -0
- package/src/engine/utils/math/vector.js +458 -0
- package/src/engine/utils/obj/_old_js/index.js +46 -0
- package/src/engine/utils/obj/_old_js/layout.js +308 -0
- package/src/engine/utils/obj/_old_js/material.js +711 -0
- package/src/engine/utils/obj/_old_js/mesh.js +761 -0
- package/src/engine/utils/obj/_old_js/utils.js +647 -0
- package/src/engine/utils/obj/index.js +24 -0
- package/src/engine/utils/obj/js/index.js +277 -0
- package/src/engine/utils/obj/js/loader.js +232 -0
- package/src/engine/utils/obj/layout.js +246 -0
- package/src/engine/utils/obj/material.js +665 -0
- package/src/engine/utils/obj/mesh.js +657 -0
- package/src/engine/utils/obj/ts/index.ts +72 -0
- package/src/engine/utils/obj/ts/layout.ts +265 -0
- package/src/engine/utils/obj/ts/material.ts +760 -0
- package/src/engine/utils/obj/ts/mesh.ts +785 -0
- package/src/engine/utils/obj/ts/utils.ts +501 -0
- package/src/engine/utils/obj/utils.js +428 -0
- package/src/engine/utils/resources.js +18 -0
- package/src/index.jsx +55 -0
- package/src/spritz/player.js +18 -0
- package/src/spritz/readme.md +18 -0
- package/LICENSE +0 -437
- package/dist/bundle.js.LICENSE.txt +0 -31
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/* *\
|
|
2
|
+
** ----------------------------------------------- **
|
|
3
|
+
** Calliope - Pixos Game Engine **
|
|
4
|
+
** ----------------------------------------------- **
|
|
5
|
+
** Copyright (c) 2020-2025 - Kyle Derby MacInnis **
|
|
6
|
+
** **
|
|
7
|
+
** Any unauthorized distribution or transfer **
|
|
8
|
+
** of this work is strictly prohibited. **
|
|
9
|
+
** **
|
|
10
|
+
** All Rights Reserved. **
|
|
11
|
+
** ----------------------------------------------- **
|
|
12
|
+
\* */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @fileoverview Pixos Cutscene Manager
|
|
16
|
+
*
|
|
17
|
+
* This minimal manager supports registering named cutscenes composed of
|
|
18
|
+
* sequential steps (wait, transition, load zone). A cutscene can be
|
|
19
|
+
* started via the engine API or Lua and will run asynchronously,
|
|
20
|
+
* blocking player input until complete. Additional step types can be
|
|
21
|
+
* added as needed.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} CutsceneStep
|
|
26
|
+
* @property {string} type - The type of step ('wait', 'transition', 'load_zone', 'action', 'set_backdrop', 'show_cutout').
|
|
27
|
+
* @property {number} [ms] - Milliseconds to wait (for 'wait' type).
|
|
28
|
+
* @property {string} [effect] - Transition effect (for 'transition' and 'load_zone' types).
|
|
29
|
+
* @property {string} [direction] - Transition direction ('in' or 'out', for 'transition' type).
|
|
30
|
+
* @property {number} [duration] - Transition duration in ms (for 'transition' and 'load_zone' types).
|
|
31
|
+
* @property {string} [zone] - Zone name to load (for 'load_zone' type).
|
|
32
|
+
* @property {boolean} [remotely] - Whether to load remotely (for 'load_zone' type).
|
|
33
|
+
* @property {string} [zip] - Zip archive for zone loading (for 'load_zone' type).
|
|
34
|
+
* @property {function(): Promise<void>} [action] - Action function to run (for 'action' type).
|
|
35
|
+
* @property {string} [backdrop] - Backdrop label to set (for 'set_backdrop' type).
|
|
36
|
+
* @property {string} [sprite] - Sprite ID for cutout (for 'show_cutout' type).
|
|
37
|
+
* @property {string} [cutout] - Cutout label (for 'show_cutout' type).
|
|
38
|
+
* @property {string} [position] - Position ('left' or 'right') for cutout (for 'show_cutout' type).
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* CutsceneManager - Manages cutscenes in the Pixos game engine.
|
|
43
|
+
* Supports registering and playing sequential cutscene steps asynchronously.
|
|
44
|
+
*/
|
|
45
|
+
export default class CutsceneManager {
|
|
46
|
+
/**
|
|
47
|
+
* Creates an instance of CutsceneManager.
|
|
48
|
+
* @param {import('../index.js').default} engine - The main game engine instance.
|
|
49
|
+
*/
|
|
50
|
+
constructor(engine) {
|
|
51
|
+
/** @type {import('../index.js').default} */
|
|
52
|
+
this.engine = engine;
|
|
53
|
+
/** @type {Object.<string, CutsceneStep[]>} */
|
|
54
|
+
this.scenes = {}; // Registered cutscenes: name -> array of steps
|
|
55
|
+
/** @type {CutsceneStep[]} */
|
|
56
|
+
this.queue = []; // Queue of steps for the currently active cutscene
|
|
57
|
+
/** @type {boolean} */
|
|
58
|
+
this.active = false;
|
|
59
|
+
/** @type {Promise<void>|null} */
|
|
60
|
+
this._currentPromise = null;
|
|
61
|
+
/** @type {string|null} */
|
|
62
|
+
this.currentBackdrop = null; // Current backdrop label
|
|
63
|
+
/** @type {Array} */
|
|
64
|
+
this.currentCutouts = []; // Array of {sprite, cutout, position} objects
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Registers a cutscene definition.
|
|
69
|
+
* @param {string} name - The name of the cutscene.
|
|
70
|
+
* @param {CutsceneStep[]} steps - The array of cutscene steps.
|
|
71
|
+
*/
|
|
72
|
+
register = (name, steps) => {
|
|
73
|
+
this.scenes[name] = Array.isArray(steps) ? steps.slice() : [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Checks if a cutscene is registered.
|
|
78
|
+
* @param {string} name - The name of the cutscene.
|
|
79
|
+
* @returns {boolean} True if the cutscene is registered.
|
|
80
|
+
*/
|
|
81
|
+
isRegistered = (name) => {
|
|
82
|
+
return name in this.scenes;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Starts playing a cutscene by name.
|
|
87
|
+
* @param {string} name - The name of the cutscene to start.
|
|
88
|
+
*/
|
|
89
|
+
start = (name) => {
|
|
90
|
+
const def = this.scenes[name];
|
|
91
|
+
if (!def) {
|
|
92
|
+
console.warn('Cutscene not found:', name);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.queue = def.slice();
|
|
96
|
+
this.active = true;
|
|
97
|
+
this._currentPromise = null;
|
|
98
|
+
this.currentBackdrop = null; // Reset backdrop
|
|
99
|
+
this.currentCutouts = []; // Reset cutouts
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Skips the active cutscene.
|
|
104
|
+
*/
|
|
105
|
+
skip = () => {
|
|
106
|
+
this.queue = [];
|
|
107
|
+
this.active = false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a cutscene is running.
|
|
112
|
+
* @returns {boolean} True if a cutscene is active.
|
|
113
|
+
*/
|
|
114
|
+
isRunning = () => {
|
|
115
|
+
return this.active;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Updates the cutscene manager each frame.
|
|
120
|
+
*/
|
|
121
|
+
update = () => {
|
|
122
|
+
if (!this.active) return;
|
|
123
|
+
// if a step is currently processing, wait
|
|
124
|
+
if (this._currentPromise) return;
|
|
125
|
+
const step = this.queue.shift();
|
|
126
|
+
if (!step) {
|
|
127
|
+
this.active = false;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// execute step and on completion call update again to process next
|
|
131
|
+
let promise;
|
|
132
|
+
switch (step.type) {
|
|
133
|
+
// todo -- add addiitonal step support:
|
|
134
|
+
// -- Thinking along the lines of run script, dialogue, picker, music, sprite and object actions, etc.
|
|
135
|
+
// -- in theory should be able to script a scene, set flags too, and have it proceed to the next scene if
|
|
136
|
+
// -- if another one follows. -- I should be able to script a basic 'movie' using this
|
|
137
|
+
case 'action':
|
|
138
|
+
promise = this.runAction(step);
|
|
139
|
+
break;
|
|
140
|
+
case 'wait':
|
|
141
|
+
promise = this.wait(step.ms || 0);
|
|
142
|
+
break;
|
|
143
|
+
case 'transition':
|
|
144
|
+
promise = this.transition(step);
|
|
145
|
+
break;
|
|
146
|
+
case 'load_zone':
|
|
147
|
+
promise = this.loadZone(step);
|
|
148
|
+
break;
|
|
149
|
+
case 'set_backdrop':
|
|
150
|
+
promise = this.setBackdrop(step);
|
|
151
|
+
break;
|
|
152
|
+
case 'show_cutout':
|
|
153
|
+
promise = this.showCutout(step);
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
console.warn('Unknown cutscene step:', step.type);
|
|
157
|
+
promise = Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
this._currentPromise = promise;
|
|
160
|
+
promise.then(() => {
|
|
161
|
+
this._currentPromise = null;
|
|
162
|
+
this.update();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Waits for a specified number of milliseconds.
|
|
168
|
+
* @param {number} ms - The milliseconds to wait.
|
|
169
|
+
* @returns {Promise<void>} A promise that resolves after the wait.
|
|
170
|
+
*/
|
|
171
|
+
wait = (ms) => {
|
|
172
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Handles a transition step.
|
|
177
|
+
* @param {CutsceneStep} step - The transition step.
|
|
178
|
+
* @returns {Promise<void>} A promise that resolves when the transition completes.
|
|
179
|
+
*/
|
|
180
|
+
transition = (step) => {
|
|
181
|
+
const rm = this.engine.renderManager;
|
|
182
|
+
if (!rm) return Promise.resolve();
|
|
183
|
+
const effect = step.effect || 'fade';
|
|
184
|
+
const direction = step.direction || 'out';
|
|
185
|
+
const duration = step.duration || 500;
|
|
186
|
+
return rm.startTransition({ effect, direction, duration });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Runs an action step.
|
|
191
|
+
* @param {CutsceneStep} step - The action step.
|
|
192
|
+
* @returns {Promise<void>} A promise that resolves when the action completes.
|
|
193
|
+
*/
|
|
194
|
+
runAction = (step) => {
|
|
195
|
+
const action = step.action;
|
|
196
|
+
if (!action) return Promise.resolve();
|
|
197
|
+
return action();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Loads a zone as part of a cutscene.
|
|
202
|
+
* @param {CutsceneStep} step - The load_zone step.
|
|
203
|
+
* @returns {Promise<void>} A promise that resolves when the zone is loaded.
|
|
204
|
+
*/
|
|
205
|
+
loadZone = (step) => {
|
|
206
|
+
const { zone, remotely = false, zip } = step;
|
|
207
|
+
if (!zone || !this.engine.spritz || !this.engine.spritz.world) {
|
|
208
|
+
return Promise.resolve();
|
|
209
|
+
}
|
|
210
|
+
const effect = step.effect || 'fade';
|
|
211
|
+
const duration = step.duration || 500;
|
|
212
|
+
if (zip) {
|
|
213
|
+
return this.engine.spritz.world.loadZoneFromZip(zone, zip, false, null);
|
|
214
|
+
}
|
|
215
|
+
return this.engine.spritz.world.loadZone(zone, remotely, false, null);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Sets the backdrop for the cutscene.
|
|
220
|
+
* @param {CutsceneStep} step - The set_backdrop step.
|
|
221
|
+
* @returns {Promise<void>} A promise that resolves when the backdrop is set.
|
|
222
|
+
*/
|
|
223
|
+
setBackdrop = (step) => {
|
|
224
|
+
this.currentBackdrop = step.backdrop || null;
|
|
225
|
+
return Promise.resolve();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Shows a cutout in the cutscene.
|
|
230
|
+
* @param {CutsceneStep} step - The show_cutout step.
|
|
231
|
+
* @returns {Promise<void>} A promise that resolves when the cutout is shown.
|
|
232
|
+
*/
|
|
233
|
+
showCutout = (step) => {
|
|
234
|
+
const { sprite, cutout, position = 'left' } = step;
|
|
235
|
+
if (sprite && cutout) {
|
|
236
|
+
// Remove existing cutout for this sprite if any
|
|
237
|
+
this.currentCutouts = this.currentCutouts.filter(c => c.sprite !== sprite);
|
|
238
|
+
// Add new cutout
|
|
239
|
+
this.currentCutouts.push({ sprite, cutout, position });
|
|
240
|
+
}
|
|
241
|
+
return Promise.resolve();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* *\
|
|
2
|
+
** ----------------------------------------------- **
|
|
3
|
+
** Calliope - Pixos Game Engine **
|
|
4
|
+
** ----------------------------------------------- **
|
|
5
|
+
** Copyright (c) 2020-2025 - Kyle Derby MacInnis **
|
|
6
|
+
** **
|
|
7
|
+
** Any unauthorized distribution or transfer **
|
|
8
|
+
** of this work is strictly prohibited. **
|
|
9
|
+
** **
|
|
10
|
+
** All Rights Reserved. **
|
|
11
|
+
** ----------------------------------------------- **
|
|
12
|
+
\* */
|
|
13
|
+
|
|
14
|
+
import Dexie from 'dexie';
|
|
15
|
+
|
|
16
|
+
export default class Database {
|
|
17
|
+
/**
|
|
18
|
+
* Database
|
|
19
|
+
*/
|
|
20
|
+
constructor() {
|
|
21
|
+
this.db = new Dexie('hyperspace');
|
|
22
|
+
this.db.version(1).stores({
|
|
23
|
+
tileset: '++id, name, creator, type, checksum, signature, timestamp', // Primary key and indexed props
|
|
24
|
+
inventory: '++id, name, creator, type, checksum, signature, timestamp', // Primary key and indexed props
|
|
25
|
+
spirits: '++id, name, creator, type, checksum, signature, timestamp', // Primary key and indexed props
|
|
26
|
+
abilities: '++id, name, creator, type checksum, signature, timestamp', // Primary key and indexed props
|
|
27
|
+
models: '++id, name, creator, type, checksum, signature, timestamp', // Primary key and indexed props
|
|
28
|
+
accounts: '++id, name, type, checksum, signature, timestamp', // Primary key and indexed props
|
|
29
|
+
dht: '++id, name, type, ip, checksum, signature, timestamp', // Primary key and indexed props
|
|
30
|
+
msg: '++id, name, type, ip, checksum, signature, timestamp', // Primary key and indexed props
|
|
31
|
+
tmp: '++id, key, value, timestamp', // key-store
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* fetch value
|
|
37
|
+
* @param {*} store
|
|
38
|
+
* @param {*} key
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
dbGet = async (store, key) => {
|
|
42
|
+
return await this.db[store].get(key);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* add key to db store and returns id
|
|
47
|
+
* @param {*} store
|
|
48
|
+
* @param {*} value
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
dbAdd = async (store, value) => {
|
|
52
|
+
return await this.db[store].add({ ...value });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* update key to db store returns number of rows
|
|
57
|
+
* @param {*} store
|
|
58
|
+
* @param {*} id
|
|
59
|
+
* @param {*} changes
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
dbUpdate = async (store, id, changes) => {
|
|
63
|
+
return await this.db[store].update(id, { ...changes });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* update key to db store returns number of rows
|
|
68
|
+
* @param {*} store
|
|
69
|
+
* @param {*} id
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
dbRemove = async (store, id) => {
|
|
73
|
+
return await this.db[store].delete(id);
|
|
74
|
+
}
|
|
75
|
+
}
|