@media-quest/engine 0.0.30 → 0.0.31

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.
@@ -184,7 +184,7 @@ declare namespace DCss {
184
184
  readonly _unit: "percent";
185
185
  readonly value: number;
186
186
  }
187
- type LengthUnit = Px | Percent;
187
+ type LengthUnit = Px | Percent | number;
188
188
  /**
189
189
  * Will scale to 3% of baseScale
190
190
  * @param unit
@@ -200,16 +200,32 @@ interface DStyle {
200
200
  backgroundColor: string;
201
201
  visibility: "visible" | "hidden";
202
202
  cursor: "pointer" | "help" | "copy" | "wait" | "not-allowed" | "context-menu" | "move" | "grabbing" | "grab" | "zoom-in" | "zoom-out" | "none" | "auto" | "default";
203
+ zIndex: number;
203
204
  h: number;
204
205
  w: number;
205
206
  x: number;
206
207
  y: number;
208
+ height: DCss.LengthUnit;
209
+ maxHeight: DCss.LengthUnit;
210
+ minHeight: DCss.LengthUnit;
211
+ width: DCss.LengthUnit;
212
+ maxWidth: DCss.LengthUnit;
213
+ minWidth: DCss.LengthUnit;
214
+ bottom: DCss.LengthUnit;
215
+ top: DCss.LengthUnit;
216
+ left: DCss.LengthUnit;
217
+ right: DCss.LengthUnit;
218
+ boxShadow: string;
207
219
  borderStyle: "solid" | "none" | "dotted" | "dashed";
208
220
  borderRadius: DCss.Px | DCss.Percent;
209
221
  borderWidth: DCss.Px;
210
222
  borderColor: string;
211
223
  margin: DCss.Px | DCss.Percent;
212
224
  padding: DCss.Px | DCss.Percent;
225
+ paddingLeft: DCss.Px | DCss.Percent;
226
+ paddingRight: DCss.Px | DCss.Percent;
227
+ paddingTop: DCss.Px | DCss.Percent;
228
+ paddingBottom: DCss.Px | DCss.Percent;
213
229
  transform: string;
214
230
  translate: string;
215
231
  fontSize: DCss.Px;
@@ -217,6 +233,14 @@ interface DStyle {
217
233
  fontWeight: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
218
234
  textAlign: "right" | "left" | "center";
219
235
  letterSpacing: DCss.Px;
236
+ position: "absolute" | "relative";
237
+ display: "flex" | "block";
238
+ flexDirection: "row" | "colum";
239
+ flexWrap: "nowrap" | "wrap";
240
+ justifyContent: "flex-start" | "flex-end" | "center" | "space-around" | "space-evenly" | "space-between";
241
+ alignItems: "stretch" | "baseline" | "center" | "flex-start" | "flex-end";
242
+ gap: DCss.Px;
243
+ alignContent: "stretch" | "center" | "flex-start" | "flex-end" | "space-around" | "space-evenly" | "space-between";
220
244
  }
221
245
  declare namespace DStyle {
222
246
  const normalize: <T extends HTMLElement>(el: T) => T;
@@ -253,7 +277,7 @@ type TaskStateDiff = Partial<TaskState> & {
253
277
  type TaskState = {
254
278
  audioIsPlaying: boolean;
255
279
  isGifMode: boolean;
256
- videoIsPlaying: boolean;
280
+ videoPlayState: "playing" | "paused" | "ended" | "playing-and-muted" | "paused-and-muted" | "ended-and-muted";
257
281
  blockFormInput: boolean;
258
282
  blockResponseButton: boolean;
259
283
  blockAudio: boolean;
@@ -267,20 +291,33 @@ declare const TaskState: {
267
291
  type ButtonClickAction = {
268
292
  kind: "play-audio";
269
293
  task: PlayAudioTask;
294
+ vibrateMs?: number;
270
295
  } | {
271
296
  kind: "pause-audio";
297
+ vibrateMs?: number;
272
298
  } | {
273
299
  kind: "play-video";
274
300
  task: PlayVideoTask;
301
+ vibrateMs?: number;
302
+ } | {
303
+ kind: "mute-video";
304
+ vibrateMs?: number;
305
+ } | {
306
+ kind: "un-mute-video";
307
+ vibrateMs?: number;
275
308
  } | {
276
309
  kind: "pause-video";
310
+ vibrateMs?: number;
277
311
  } | {
278
312
  kind: "submit-fact";
279
313
  fact: Fact;
314
+ vibrateMs?: number;
280
315
  } | {
281
316
  kind: "next-page";
317
+ vibrateMs?: number;
282
318
  } | {
283
319
  kind: "submit-form";
320
+ vibrateMs?: number;
284
321
  };
285
322
  declare const ButtonClickAction: {
286
323
  describe: (a: ButtonClickAction) => string;
@@ -293,24 +330,46 @@ interface DElementBaseDto {
293
330
  readonly onMouseDown?: PStyle;
294
331
  readonly onMouseUp?: PStyle;
295
332
  readonly innerText?: string;
333
+ readonly onClick?: ButtonClickAction;
334
+ readonly whenVideoPaused?: PStyle;
335
+ readonly whenVideoPausedAndMuted?: PStyle;
336
+ readonly whenVideoEnded?: PStyle;
337
+ readonly whenVideoEndedAndMuted?: PStyle;
338
+ readonly whenVideoPlaying?: PStyle;
339
+ readonly whenVideoPlayingAndMuted?: PStyle;
340
+ readonly whenAudioPlaying?: PStyle;
341
+ readonly whenAudioPaused?: PStyle;
342
+ readonly whenAudioBlocked?: PStyle;
343
+ readonly whenVideoBlocked?: PStyle;
344
+ readonly whenAudioUnblocked?: PStyle;
345
+ readonly whenVideoUnblocked?: PStyle;
346
+ readonly whenResponseBlocked?: PStyle;
347
+ readonly whenResponseUnblocked?: PStyle;
348
+ readonly whenFormInputBlocked?: PStyle;
349
+ readonly whenFormInputUnblocked?: PStyle;
296
350
  }
297
351
  declare abstract class DElement<T extends HTMLElement> {
298
352
  protected readonly el: T;
299
353
  protected readonly dto: DElementBaseDto;
300
354
  protected readonly scale: ScaleService;
355
+ private prevState;
301
356
  protected currStyle: Partial<DStyle>;
302
357
  protected constructor(el: T, dto: DElementBaseDto, scale: ScaleService);
303
358
  /**
304
359
  * This method is called when the element is clicked.
305
360
  * This method shall be overridden by the pageClass.
306
- * @param actions
361
+ * @param style
307
362
  */
308
- onclick(): void;
309
363
  setStyle(style: PStyle): void;
364
+ getElementByDangerousReference(): T;
310
365
  appendYourself(parent: {
311
366
  append: (el: HTMLElement) => void;
312
367
  }): void;
368
+ updateState(state: TaskStateDiff): void;
369
+ setState(state: TaskState): void;
370
+ private handleStateChanges;
313
371
  private normalize;
372
+ abstract registerClickHandler(clickHandler: (action: ButtonClickAction) => void): void;
314
373
  protected updateStyles(style: Partial<DStyle>): void;
315
374
  }
316
375
 
@@ -326,6 +385,7 @@ declare class DImg extends DElement<HTMLImageElement> {
326
385
  readonly TAG: string;
327
386
  readonly TIMING_TAG: string;
328
387
  private readonly loadStart;
388
+ registerClickHandler(clickHandler: (action: ButtonClickAction) => void): void;
329
389
  constructor(dto: DImgDto, scaleService: ScaleService);
330
390
  log(): void;
331
391
  }
@@ -336,11 +396,25 @@ interface DTextDto extends DElementBaseDto {
336
396
  }
337
397
  declare class DText extends DElement<HTMLParagraphElement> {
338
398
  constructor(dto: DTextDto, scale: ScaleService);
399
+ registerClickHandler(clickHandler: (action: ButtonClickAction) => void): void;
400
+ }
401
+
402
+ interface DButtonDto extends DElementBaseDto {
403
+ readonly _tag: "button";
404
+ }
405
+ declare class DButton extends DElement<HTMLButtonElement> {
406
+ private readonly TAG;
407
+ protected readonly defaultStyle: {
408
+ x: number;
409
+ y: number;
410
+ };
411
+ constructor(dto: DButtonDto, scale: ScaleService);
412
+ registerClickHandler(clickHandler: (action: ButtonClickAction) => void): void;
339
413
  }
340
414
 
341
415
  interface DDivDto extends DElementBaseDto {
342
416
  readonly _tag: "div";
343
- readonly children: Array<DTextDto | DImgDto>;
417
+ readonly children: Array<DTextDto | DImgDto | DButtonDto>;
344
418
  }
345
419
  declare class DDiv extends DElement<HTMLDivElement> {
346
420
  private readonly TAG;
@@ -349,42 +423,12 @@ declare class DDiv extends DElement<HTMLDivElement> {
349
423
  y: number;
350
424
  };
351
425
  private children;
352
- constructor(dto: DDivDto, scale: ScaleService, children: Array<DText | DImg>);
426
+ registerClickHandler(clickHandler: (action: ButtonClickAction) => void): void;
427
+ constructor(dto: DDivDto, scale: ScaleService, children: Array<DText | DImg | DButton>);
428
+ protected whenConstructed(): void;
353
429
  }
354
430
 
355
- type DElementDto = DTextDto | DImgDto | DDivDto;
356
-
357
- interface PageComponentDto {
358
- readonly onClick?: ButtonClickAction;
359
- readonly el: DElementDto;
360
- readonly whenVideoPlay?: PStyle;
361
- readonly whenVideoPaused?: PStyle;
362
- readonly whenAudioPlaying?: PStyle;
363
- readonly whenAudioPaused?: PStyle;
364
- readonly whenAudioBlocked?: PStyle;
365
- readonly whenVideoBlocked?: PStyle;
366
- readonly whenAudioUnblocked?: PStyle;
367
- readonly whenVideoUnblocked?: PStyle;
368
- readonly whenResponseBlocked?: PStyle;
369
- readonly whenResponseUnblocked?: PStyle;
370
- readonly whenFormInputBlocked?: PStyle;
371
- readonly whenFormInputUnblocked?: PStyle;
372
- }
373
- declare class PageComponent {
374
- readonly dto: PageComponentDto;
375
- readonly scale: ScaleService;
376
- private readonly TAG;
377
- private el;
378
- private prevState;
379
- constructor(dto: PageComponentDto, scale: ScaleService);
380
- onClick(action: ButtonClickAction): void;
381
- updateState(state: TaskStateDiff): void;
382
- setState(state: TaskState): void;
383
- private handleStateChanges;
384
- appendToParent(parent: {
385
- append: (el: HTMLElement) => void;
386
- }): void;
387
- }
431
+ type DElementDto = DTextDto | DImgDto | DDivDto | DButtonDto;
388
432
 
389
433
  interface VideoPlayerDto {
390
434
  playUrl: string;
@@ -394,9 +438,8 @@ interface PageDto {
394
438
  readonly id: string;
395
439
  readonly prefix: string;
396
440
  readonly tags: string[];
397
- staticElements: Array<DElementDto>;
398
441
  background: string;
399
- components: Array<PageComponentDto>;
442
+ elements: Array<DElementDto>;
400
443
  videoPlayer?: VideoPlayerDto;
401
444
  initialTasks: Array<Task>;
402
445
  }
@@ -507,4 +550,4 @@ declare namespace DUtil {
507
550
  const minFn: (lowerLimit: number) => (value: number) => number;
508
551
  }
509
552
 
510
- export { ButtonClickAction, Condition, DCss, DDiv, type DDivDto, DElement, type DElementBaseDto, type DElementDto, DImg, type DImgDto, DStyle, DText, type DTextDto, DUtil, type DelayTask, type EngineLogger, Fact, type ISchemaEngine, type Match, MqEvent, type MqEventEngineStart, type MqEventPageEnter, type MqEventPageLeave, type MqEventUserClicked, type PStyle, PageComponent, type PageComponentDto, PageDto, type PageQueRules, type PageSequenceDto, type PlayAudioTask, type PlayVideoTask, Rule, type RuleActionPageQue, RuleEngine, type RuleEngineError, type SchemaDto, SchemaEngine, type SchemaResult, type SolveResult, Task };
553
+ export { ButtonClickAction, Condition, DButton, type DButtonDto, DCss, DDiv, type DDivDto, DElement, type DElementBaseDto, type DElementDto, DImg, type DImgDto, DStyle, DText, type DTextDto, DUtil, type DelayTask, type EngineLogger, Fact, type ISchemaEngine, type Match, MqEvent, type MqEventEngineStart, type MqEventPageEnter, type MqEventPageLeave, type MqEventUserClicked, type PStyle, PageDto, type PageQueRules, type PageSequenceDto, type PlayAudioTask, type PlayVideoTask, Rule, type RuleActionPageQue, RuleEngine, type RuleEngineError, type SchemaDto, SchemaEngine, type SchemaResult, type SolveResult, Task };