@lookit/record 4.0.0 → 4.1.0

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/dist/index.d.ts CHANGED
@@ -132,6 +132,11 @@ declare const info$3: {
132
132
  readonly default: false;
133
133
  };
134
134
  };
135
+ readonly data: {
136
+ readonly chs_type: {
137
+ readonly type: ParameterType.STRING;
138
+ };
139
+ };
135
140
  };
136
141
  type Info$3 = typeof info$3;
137
142
  /** The video consent plugin. */
@@ -269,6 +274,11 @@ declare class VideoConsentPlugin implements JsPsychPlugin<Info$3> {
269
274
  readonly default: false;
270
275
  };
271
276
  };
277
+ readonly data: {
278
+ readonly chs_type: {
279
+ readonly type: ParameterType.STRING;
280
+ };
281
+ };
272
282
  };
273
283
  private readonly recorder;
274
284
  private readonly video_container_id;
@@ -393,7 +403,9 @@ declare class VideoConsentPlugin implements JsPsychPlugin<Info$3> {
393
403
 
394
404
  declare const info$2: {
395
405
  readonly name: "start-record-plugin";
406
+ readonly version: string;
396
407
  readonly parameters: {};
408
+ readonly data: {};
397
409
  };
398
410
  type Info$2 = typeof info$2;
399
411
  /** Start recording. Used by researchers who want to record across trials. */
@@ -401,7 +413,9 @@ declare class StartRecordPlugin implements JsPsychPlugin<Info$2> {
401
413
  private jsPsych;
402
414
  static readonly info: {
403
415
  readonly name: "start-record-plugin";
416
+ readonly version: string;
404
417
  readonly parameters: {};
418
+ readonly data: {};
405
419
  };
406
420
  private recorder;
407
421
  /**
@@ -416,12 +430,32 @@ declare class StartRecordPlugin implements JsPsychPlugin<Info$2> {
416
430
 
417
431
  declare const info$1: {
418
432
  readonly name: "stop-record-plugin";
433
+ readonly version: string;
419
434
  readonly parameters: {
435
+ /**
436
+ * This string can contain HTML markup. Any content provided will be
437
+ * displayed while the recording is uploading. If null (the default), then
438
+ * the default 'uploading video, please wait' (or appropriate translation
439
+ * based on 'locale') will be displayed. Use a blank string for no
440
+ * message/content.
441
+ */
442
+ readonly wait_for_upload_message: {
443
+ readonly type: ParameterType.HTML_STRING;
444
+ readonly default: string | null;
445
+ };
446
+ /**
447
+ * Locale code used for translating the default 'uploading video, please
448
+ * wait' message. This code must be present in the translation files. If the
449
+ * code is not found then English will be used. If the
450
+ * 'wait_for_upload_message' parameter is specified then this value is
451
+ * ignored.
452
+ */
420
453
  readonly locale: {
421
454
  readonly type: ParameterType.STRING;
422
455
  readonly default: "en-us";
423
456
  };
424
457
  };
458
+ readonly data: {};
425
459
  };
426
460
  type Info$1 = typeof info$1;
427
461
  /** Stop recording. Used by researchers who want to record across trials. */
@@ -429,12 +463,32 @@ declare class StopRecordPlugin implements JsPsychPlugin<Info$1> {
429
463
  private jsPsych;
430
464
  static readonly info: {
431
465
  readonly name: "stop-record-plugin";
466
+ readonly version: string;
432
467
  readonly parameters: {
468
+ /**
469
+ * This string can contain HTML markup. Any content provided will be
470
+ * displayed while the recording is uploading. If null (the default), then
471
+ * the default 'uploading video, please wait' (or appropriate translation
472
+ * based on 'locale') will be displayed. Use a blank string for no
473
+ * message/content.
474
+ */
475
+ readonly wait_for_upload_message: {
476
+ readonly type: ParameterType.HTML_STRING;
477
+ readonly default: string | null;
478
+ };
479
+ /**
480
+ * Locale code used for translating the default 'uploading video, please
481
+ * wait' message. This code must be present in the translation files. If the
482
+ * code is not found then English will be used. If the
483
+ * 'wait_for_upload_message' parameter is specified then this value is
484
+ * ignored.
485
+ */
433
486
  readonly locale: {
434
487
  readonly type: ParameterType.STRING;
435
488
  readonly default: "en-us";
436
489
  };
437
490
  };
491
+ readonly data: {};
438
492
  };
439
493
  private recorder;
440
494
  /**
@@ -454,12 +508,39 @@ declare class StopRecordPlugin implements JsPsychPlugin<Info$1> {
454
508
  trial(display_element: HTMLElement, trial: TrialType<Info$1>): void;
455
509
  }
456
510
 
457
- /** This extension will allow reasearchers to record trials. */
511
+ interface Parameters {
512
+ /**
513
+ * Content that should be displayed while the recording is uploading. If null
514
+ * (the default), then the default 'uploading video, please wait...' (or
515
+ * appropriate translation based on 'locale') will be displayed. Use a blank
516
+ * string for no message/content. Otherwise this parameter can be set to a
517
+ * custom string and can contain HTML markup. If you want to embed
518
+ * images/video/audio in this HTML string, be sure to preload the media files
519
+ * with the `preload` plugin and manual preloading. Use a blank string (`""`)
520
+ * for no message/content.
521
+ *
522
+ * @default null
523
+ */
524
+ wait_for_upload_message?: null | string;
525
+ /**
526
+ * Locale code used for translating the default 'uploading video, please
527
+ * wait...' message. This code must be present in the translation files. If
528
+ * the code is not found then English will be used. If the
529
+ * 'wait_for_upload_message' parameter is specified then this value
530
+ * isignored.
531
+ *
532
+ * @default "en-us"
533
+ */
534
+ locale?: string;
535
+ }
536
+ /** This extension allows researchers to record webcam audio/video during trials. */
458
537
  declare class TrialRecordExtension implements JsPsychExtension {
459
538
  private jsPsych;
460
539
  static readonly info: JsPsychExtensionInfo;
461
540
  private recorder?;
462
541
  private pluginName;
542
+ private uploadMsg;
543
+ private locale;
463
544
  /**
464
545
  * Video recording extension.
465
546
  *
@@ -467,20 +548,34 @@ declare class TrialRecordExtension implements JsPsychExtension {
467
548
  */
468
549
  constructor(jsPsych: JsPsych);
469
550
  /**
470
- * Ran on the initialize step for extensions, called when an instance of
551
+ * Runs on the initialize step for extensions, called when an instance of
471
552
  * jsPsych is first initialized through initJsPsych().
553
+ *
554
+ * @param params - Parameters object
555
+ * @param params.wait_for_upload_message - Message to display while waiting
556
+ * for upload. String or null (default)
557
+ * @param params.locale - Message to display while waiting for upload. String
558
+ * or null (default).
559
+ */
560
+ initialize(params?: Parameters): Promise<void>;
561
+ /**
562
+ * Runs at the start of a trial.
563
+ *
564
+ * @param startParams - Parameters object
565
+ * @param startParams.wait_for_upload_message - Message to display while
566
+ * waiting for upload. String or null (default). If given, this will
567
+ * overwrite the value used during initialization.
472
568
  */
473
- initialize(): Promise<void>;
474
- /** Ran at the start of a trial. */
475
- on_start(): void;
476
- /** Ran when the trial has loaded. */
569
+ on_start(startParams?: Parameters): void;
570
+ /** Runs when the trial has loaded. */
477
571
  on_load(): void;
478
572
  /**
479
- * Ran when trial has finished.
573
+ * Runs when trial has finished.
480
574
  *
481
- * @returns Trial data.
575
+ * @returns Any data from the trial extension that should be added to the rest
576
+ * of the trial data.
482
577
  */
483
- on_finish(): {};
578
+ on_finish(): Promise<{}>;
484
579
  /**
485
580
  * Gets the plugin name for the trial that is being extended. This is same as
486
581
  * the "trial_type" value that is stored in the data for this trial.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import Handlebars from 'handlebars';
6
6
 
7
7
  var _package = {
8
8
  name: "@lookit/record",
9
- version: "4.0.0",
9
+ version: "4.1.0",
10
10
  description: "Recording extensions and plugins for CHS studies.",
11
11
  homepage: "https://github.com/lookit/lookit-jspsych#readme",
12
12
  bugs: {
@@ -287,6 +287,7 @@ class Recorder {
287
287
  } else {
288
288
  await this.s3.completeUpload();
289
289
  }
290
+ this.reset();
290
291
  resolve();
291
292
  };
292
293
  }
@@ -381,6 +382,11 @@ const info$3 = {
381
382
  prompt_only_adults: { type: ParameterType.BOOL, default: false },
382
383
  consent_statement_text: { type: ParameterType.STRING, default: "" },
383
384
  omit_injury_phrase: { type: ParameterType.BOOL, default: false }
385
+ },
386
+ data: {
387
+ chs_type: {
388
+ type: ParameterType.STRING
389
+ }
384
390
  }
385
391
  };
386
392
  const _VideoConsentPlugin = class {
@@ -509,7 +515,6 @@ const _VideoConsentPlugin = class {
509
515
  stop.disabled = true;
510
516
  this.addMessage(display, this.uploadingMsg);
511
517
  await this.recorder.stop(true);
512
- this.recorder.reset();
513
518
  this.recordFeed(display);
514
519
  this.getImg(display, "record-icon").style.visibility = "hidden";
515
520
  this.addMessage(display, this.notRecordingMsg);
@@ -534,7 +539,12 @@ const _VideoConsentPlugin = class {
534
539
  let VideoConsentPlugin = _VideoConsentPlugin;
535
540
  VideoConsentPlugin.info = info$3;
536
541
 
537
- const info$2 = { name: "start-record-plugin", parameters: {} };
542
+ const info$2 = {
543
+ name: "start-record-plugin",
544
+ version: _package.version,
545
+ parameters: {},
546
+ data: {}
547
+ };
538
548
  const _StartRecordPlugin = class {
539
549
  constructor(jsPsych) {
540
550
  this.jsPsych = jsPsych;
@@ -556,9 +566,18 @@ StartRecordPlugin.info = info$2;
556
566
 
557
567
  const info$1 = {
558
568
  name: "stop-record-plugin",
569
+ version: _package.version,
559
570
  parameters: {
560
- locale: { type: ParameterType.STRING, default: "en-us" }
561
- }
571
+ wait_for_upload_message: {
572
+ type: ParameterType.HTML_STRING,
573
+ default: null
574
+ },
575
+ locale: {
576
+ type: ParameterType.STRING,
577
+ default: "en-us"
578
+ }
579
+ },
580
+ data: {}
562
581
  };
563
582
  class StopRecordPlugin {
564
583
  constructor(jsPsych) {
@@ -570,11 +589,17 @@ class StopRecordPlugin {
570
589
  }
571
590
  }
572
591
  trial(display_element, trial) {
573
- display_element.innerHTML = chsTemplates.uploadingVideo(trial);
592
+ if (trial.wait_for_upload_message == null) {
593
+ display_element.innerHTML = chsTemplates.uploadingVideo(trial);
594
+ } else {
595
+ display_element.innerHTML = trial.wait_for_upload_message;
596
+ }
574
597
  this.recorder.stop().then(() => {
575
598
  window.chs.sessionRecorder = null;
576
599
  display_element.innerHTML = "";
577
600
  this.jsPsych.finishTrial();
601
+ }).catch((err) => {
602
+ console.error("StopRecordPlugin: recorder stop/upload failed.", err);
578
603
  });
579
604
  }
580
605
  }
@@ -583,19 +608,50 @@ StopRecordPlugin.info = info$1;
583
608
  class TrialRecordExtension {
584
609
  constructor(jsPsych) {
585
610
  this.jsPsych = jsPsych;
611
+ this.uploadMsg = null;
612
+ this.locale = "en-us";
586
613
  autoBind(this);
587
614
  }
588
- async initialize() {
615
+ async initialize(params) {
616
+ await new Promise((resolve) => {
617
+ this.uploadMsg = params?.wait_for_upload_message ? params.wait_for_upload_message : null;
618
+ this.locale = params?.locale ? params.locale : "en-us";
619
+ console.log(this.uploadMsg);
620
+ console.log(this.locale);
621
+ resolve();
622
+ });
589
623
  }
590
- on_start() {
624
+ on_start(startParams) {
625
+ if (startParams?.wait_for_upload_message) {
626
+ this.uploadMsg = startParams.wait_for_upload_message;
627
+ }
628
+ if (startParams?.locale) {
629
+ this.locale = startParams.locale;
630
+ }
631
+ console.log(this.uploadMsg);
632
+ console.log(this.locale);
591
633
  this.recorder = new Recorder(this.jsPsych);
592
634
  }
593
635
  on_load() {
594
636
  this.pluginName = this.getCurrentPluginName();
595
637
  this.recorder?.start(false, `${this.pluginName}`);
596
638
  }
597
- on_finish() {
598
- this.recorder?.stop();
639
+ async on_finish() {
640
+ const displayEl = this.jsPsych.getDisplayElement();
641
+ if (this.uploadMsg == null) {
642
+ displayEl.innerHTML = chsTemplates.uploadingVideo({
643
+ type: this.jsPsych.getCurrentTrial().type,
644
+ locale: this.locale
645
+ });
646
+ } else {
647
+ displayEl.innerHTML = this.uploadMsg;
648
+ }
649
+ try {
650
+ await this.recorder?.stop();
651
+ displayEl.innerHTML = "";
652
+ } catch (err) {
653
+ console.error("TrialRecordExtension: recorder stop/upload failed.", err);
654
+ }
599
655
  return {};
600
656
  }
601
657
  getCurrentPluginName() {
@@ -604,7 +660,9 @@ class TrialRecordExtension {
604
660
  }
605
661
  }
606
662
  TrialRecordExtension.info = {
607
- name: "chs-trial-record-extension"
663
+ name: "chs-trial-record-extension",
664
+ version: _package.version,
665
+ data: {}
608
666
  };
609
667
 
610
668
  var img$6 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAnCAYAAAB9qAq4AAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAACigAwAEAAAAAQAAACcAAAAAC4ycfgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWR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