@media-quest/engine 0.0.30 → 0.0.32

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,15 @@ 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
+ lineHeight: number;
237
+ position: "absolute" | "relative";
238
+ display: "flex" | "block";
239
+ flexDirection: "row" | "colum";
240
+ flexWrap: "nowrap" | "wrap";
241
+ justifyContent: "flex-start" | "flex-end" | "center" | "space-around" | "space-evenly" | "space-between";
242
+ alignItems: "stretch" | "baseline" | "center" | "flex-start" | "flex-end";
243
+ gap: DCss.Px;
244
+ alignContent: "stretch" | "center" | "flex-start" | "flex-end" | "space-around" | "space-evenly" | "space-between";
220
245
  }
221
246
  declare namespace DStyle {
222
247
  const normalize: <T extends HTMLElement>(el: T) => T;
@@ -253,7 +278,7 @@ type TaskStateDiff = Partial<TaskState> & {
253
278
  type TaskState = {
254
279
  audioIsPlaying: boolean;
255
280
  isGifMode: boolean;
256
- videoIsPlaying: boolean;
281
+ videoPlayState: "playing" | "paused" | "ended" | "playing-and-muted" | "paused-and-muted" | "ended-and-muted";
257
282
  blockFormInput: boolean;
258
283
  blockResponseButton: boolean;
259
284
  blockAudio: boolean;
@@ -267,20 +292,33 @@ declare const TaskState: {
267
292
  type ButtonClickAction = {
268
293
  kind: "play-audio";
269
294
  task: PlayAudioTask;
295
+ vibrateMs?: number;
270
296
  } | {
271
297
  kind: "pause-audio";
298
+ vibrateMs?: number;
272
299
  } | {
273
300
  kind: "play-video";
274
301
  task: PlayVideoTask;
302
+ vibrateMs?: number;
303
+ } | {
304
+ kind: "mute-video";
305
+ vibrateMs?: number;
306
+ } | {
307
+ kind: "un-mute-video";
308
+ vibrateMs?: number;
275
309
  } | {
276
310
  kind: "pause-video";
311
+ vibrateMs?: number;
277
312
  } | {
278
313
  kind: "submit-fact";
279
314
  fact: Fact;
315
+ vibrateMs?: number;
280
316
  } | {
281
317
  kind: "next-page";
318
+ vibrateMs?: number;
282
319
  } | {
283
320
  kind: "submit-form";
321
+ vibrateMs?: number;
284
322
  };
285
323
  declare const ButtonClickAction: {
286
324
  describe: (a: ButtonClickAction) => string;
@@ -293,24 +331,45 @@ interface DElementBaseDto {
293
331
  readonly onMouseDown?: PStyle;
294
332
  readonly onMouseUp?: PStyle;
295
333
  readonly innerText?: string;
334
+ readonly onClick?: ButtonClickAction;
335
+ readonly whenVideoPaused?: PStyle;
336
+ readonly whenVideoPausedAndMuted?: PStyle;
337
+ readonly whenVideoEnded?: PStyle;
338
+ readonly whenVideoEndedAndMuted?: PStyle;
339
+ readonly whenVideoPlaying?: PStyle;
340
+ readonly whenVideoPlayingAndMuted?: PStyle;
341
+ readonly whenAudioPlaying?: PStyle;
342
+ readonly whenAudioPaused?: PStyle;
343
+ readonly whenAudioBlocked?: PStyle;
344
+ readonly whenVideoBlocked?: PStyle;
345
+ readonly whenAudioUnblocked?: PStyle;
346
+ readonly whenVideoUnblocked?: PStyle;
347
+ readonly whenResponseBlocked?: PStyle;
348
+ readonly whenResponseUnblocked?: PStyle;
349
+ readonly whenFormInputBlocked?: PStyle;
350
+ readonly whenFormInputUnblocked?: PStyle;
296
351
  }
297
352
  declare abstract class DElement<T extends HTMLElement> {
298
353
  protected readonly el: T;
299
354
  protected readonly dto: DElementBaseDto;
300
355
  protected readonly scale: ScaleService;
356
+ private prevState;
301
357
  protected currStyle: Partial<DStyle>;
302
358
  protected constructor(el: T, dto: DElementBaseDto, scale: ScaleService);
303
359
  /**
304
360
  * This method is called when the element is clicked.
305
361
  * This method shall be overridden by the pageClass.
306
- * @param actions
362
+ * @param style
307
363
  */
308
- onclick(): void;
309
364
  setStyle(style: PStyle): void;
365
+ getElementByDangerousReference(): T;
310
366
  appendYourself(parent: {
311
367
  append: (el: HTMLElement) => void;
312
368
  }): void;
313
- private normalize;
369
+ updateState(state: TaskStateDiff): void;
370
+ setState(state: TaskState): void;
371
+ private handleStateChanges;
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 };