@media-quest/builder 0.0.34 → 0.0.36

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.
@@ -17,29 +17,33 @@ declare abstract class BuilderObject<T extends BuilderObjectType, Dto extends {}
17
17
  interface AudioFile {
18
18
  readonly kind: "audio-file";
19
19
  readonly id: string;
20
- readonly downloadUrl: string;
20
+ downloadUrl: string;
21
21
  readonly duration: number;
22
22
  readonly originalFileName: string;
23
23
  readonly name: string;
24
24
  readonly size: number;
25
+ readonly relativePath?: string;
25
26
  }
26
27
  interface VideoFile {
27
28
  readonly kind: "video-file";
28
29
  readonly id: string;
29
- readonly downloadUrl: string;
30
+ downloadUrl: string;
30
31
  readonly duration: number;
31
32
  readonly name: string;
32
33
  readonly size: number;
33
34
  readonly type: string;
34
35
  readonly originalFileName: string;
36
+ readonly relativePath?: string;
35
37
  }
36
38
  interface ImageFile {
37
39
  readonly kind: "image-file";
38
40
  readonly id: string;
39
- readonly downloadUrl: string;
41
+ downloadUrl: string;
40
42
  readonly name: string;
41
43
  readonly size: number;
42
44
  readonly type: string;
45
+ readonly originalFileName?: string;
46
+ readonly relativePath?: string;
43
47
  }
44
48
 
45
49
  type ID<B extends string> = string & {
@@ -595,6 +599,89 @@ declare class BuilderTag extends BuilderObject<"builder-tag", BuilderTagDto> {
595
599
  toJson(): BuilderTagDto;
596
600
  }
597
601
 
602
+ interface SumScoreVariableDto {
603
+ id: SumScoreVariableID;
604
+ name: string;
605
+ description: string;
606
+ useAvg: boolean;
607
+ }
608
+ declare class SumScoreVariable extends BuilderObject<"builder-sum-score-variable", SumScoreVariableDto> {
609
+ readonly objectType = "builder-sum-score-variable";
610
+ readonly id: SumScoreVariableID;
611
+ private _useAvg;
612
+ private _name;
613
+ private _description;
614
+ private _error;
615
+ private _usedIn;
616
+ get usedIn(): BuilderPage[];
617
+ static readonly create: (data: {
618
+ name: string;
619
+ description: string;
620
+ useAvg: boolean;
621
+ }) => SumScoreVariable;
622
+ get hasErrors(): boolean;
623
+ static fromDto: (dto: SumScoreVariableDto) => SumScoreVariable;
624
+ private constructor();
625
+ toJson(): SumScoreVariableDto;
626
+ clone(): SumScoreVariableDto;
627
+ get name(): string;
628
+ get description(): string;
629
+ get useAvg(): boolean;
630
+ }
631
+
632
+ /**
633
+ * Interface representing a code book question sum-score.
634
+ *
635
+ * @interface
636
+ */
637
+ interface CodeBookQuestionVariable {
638
+ readonly kind: "codebook-question-variable";
639
+ readonly label: string;
640
+ readonly varId: string;
641
+ readonly pageId: PageID;
642
+ readonly pagePrefix: string;
643
+ readonly modulePrefix: string;
644
+ readonly pagePosition: number;
645
+ readonly options: ReadonlyArray<{
646
+ label: string;
647
+ value: number;
648
+ }>;
649
+ readonly includedInSumScores: ReadonlyArray<SumScoreVariableDto>;
650
+ }
651
+ interface CodebookPredefinedVariable {
652
+ readonly kind: "codebook-predefined-variable";
653
+ readonly modulePrefix: string;
654
+ readonly moduleID: string;
655
+ defaultValue: number;
656
+ options: Array<{
657
+ label: string;
658
+ value: number;
659
+ }>;
660
+ }
661
+
662
+ interface BuilderSchemaDto {
663
+ readonly id: SchemaID;
664
+ readonly prefix: SchemaPrefixValue;
665
+ readonly mainImage: ImageFile | false;
666
+ readonly backgroundColor: string;
667
+ readonly name: string;
668
+ readonly pages: ReadonlyArray<BuilderPageDto>;
669
+ readonly baseHeight: number;
670
+ readonly baseWidth: number;
671
+ readonly predefinedVariables?: Array<CodebookPredefinedVariable>;
672
+ readonly sumScoreVariables?: ReadonlyArray<SumScoreVariableDto>;
673
+ readonly rules: ReadonlyArray<BuilderRuleDto>;
674
+ readonly tags: ReadonlyArray<BuilderTagDto>;
675
+ }
676
+ declare const BuilderSchemaDto: {
677
+ blockAutoplayVideo: (dto: BuilderPageDto) => BuilderPageDto;
678
+ overrideAllMediaUrls: (schema: BuilderSchemaDto, options: {
679
+ videoFilesBaseUrl: string;
680
+ audioFilesBaseUrl: string;
681
+ imageFilesBaseUrl: string;
682
+ }) => BuilderSchemaDto;
683
+ };
684
+
598
685
  interface ThemeCompiler<ThemeSchema> {
599
686
  currentTheme: ThemeSchema;
600
687
  allThemes: ThemeSchema[];
@@ -768,66 +855,6 @@ declare class DefaultThemeCompiler implements ThemeCompiler<IDefaultTheme> {
768
855
  private compileButton;
769
856
  }
770
857
 
771
- interface SumScoreVariableDto {
772
- id: SumScoreVariableID;
773
- name: string;
774
- description: string;
775
- useAvg: boolean;
776
- }
777
- declare class SumScoreVariable extends BuilderObject<"builder-sum-score-variable", SumScoreVariableDto> {
778
- readonly objectType = "builder-sum-score-variable";
779
- readonly id: SumScoreVariableID;
780
- private _useAvg;
781
- private _name;
782
- private _description;
783
- private _error;
784
- private _usedIn;
785
- get usedIn(): BuilderPage[];
786
- static readonly create: (data: {
787
- name: string;
788
- description: string;
789
- useAvg: boolean;
790
- }) => SumScoreVariable;
791
- get hasErrors(): boolean;
792
- static fromDto: (dto: SumScoreVariableDto) => SumScoreVariable;
793
- private constructor();
794
- toJson(): SumScoreVariableDto;
795
- clone(): SumScoreVariableDto;
796
- get name(): string;
797
- get description(): string;
798
- get useAvg(): boolean;
799
- }
800
-
801
- /**
802
- * Interface representing a code book question sum-score.
803
- *
804
- * @interface
805
- */
806
- interface CodeBookQuestionVariable {
807
- readonly kind: "codebook-question-variable";
808
- readonly label: string;
809
- readonly varId: string;
810
- readonly pageId: PageID;
811
- readonly pagePrefix: string;
812
- readonly modulePrefix: string;
813
- readonly pagePosition: number;
814
- readonly options: ReadonlyArray<{
815
- label: string;
816
- value: number;
817
- }>;
818
- readonly includedInSumScores: ReadonlyArray<SumScoreVariableDto>;
819
- }
820
- interface CodebookPredefinedVariable {
821
- readonly kind: "codebook-predefined-variable";
822
- readonly modulePrefix: string;
823
- readonly moduleID: string;
824
- defaultValue: number;
825
- options: Array<{
826
- label: string;
827
- value: number;
828
- }>;
829
- }
830
-
831
858
  interface Codebook {
832
859
  readonly predefinedVariables: ReadonlyArray<CodebookPredefinedVariable>;
833
860
  readonly pageVariables: ReadonlyArray<CodeBookQuestionVariable>;
@@ -861,22 +888,14 @@ interface CompilerOutput {
861
888
  interface CompilerOption {
862
889
  blockAutoplayQuestion: boolean;
863
890
  blockAutoplayVideo: boolean;
891
+ mediaAssets: {
892
+ audioFilesBaseUrl: string;
893
+ videoFilesBaseUrl: string;
894
+ imageFilesBaseUrl: string;
895
+ fileNameStrategy: "id" | "newFileName" | "originalFileName" | "relativePath";
896
+ } | null;
864
897
  }
865
898
 
866
- interface BuilderSchemaDto {
867
- readonly id: SchemaID;
868
- readonly prefix: SchemaPrefixValue;
869
- readonly mainImage: ImageFile | false;
870
- readonly backgroundColor: string;
871
- readonly name: string;
872
- readonly pages: ReadonlyArray<BuilderPageDto>;
873
- readonly baseHeight: number;
874
- readonly baseWidth: number;
875
- readonly predefinedVariables?: Array<CodebookPredefinedVariable>;
876
- readonly sumScoreVariables?: ReadonlyArray<SumScoreVariableDto>;
877
- readonly rules: ReadonlyArray<BuilderRuleDto>;
878
- readonly tags: ReadonlyArray<BuilderTagDto>;
879
- }
880
899
  declare class BuilderSchema {
881
900
  readonly id: SchemaID;
882
901
  name: string;
@@ -996,4 +1015,4 @@ declare class TagCollection implements Iterable<BuilderTag> {
996
1015
 
997
1016
  declare const DefaultTheme: IDefaultTheme;
998
1017
 
999
- export { type AudioFile, BuilderCondition, type BuilderConditionDto, BuilderConditionGroup, type BuilderConditionGroupDto, type BuilderMainImageDto, BuilderMainText, type BuilderMainTextDto, type BuilderMainVideoDto, BuilderOperator, BuilderOption, type BuilderOptionDto, BuilderPage, type BuilderPageDto, type BuilderPageType, BuilderQuestion, type BuilderQuestionDto, type BuilderQuestionType, BuilderRule, type BuilderRuleDto, BuilderSchema, type BuilderSchemaDto, BuilderTag, type BuilderTagDto, BuilderText, type BuilderTextDto, CodeBook, type CodeBookQuestionVariable, type Codebook, type CodebookPredefinedVariable, type CompilerOption, type CompilerOutput, ConditionGroupType, DefaultTheme, type ExcludeByPageAction, ExcludeByPageIdSelectItem, type ExcludeByTagAction, ExcludeByTagSelectItem, type ID, type ImageFile, JumpToActionManager, type JumpToPageAction, JumpToPageSelectItem, MultiSelectItem, OperatorSelectItem, OptionID, PageActionManager, PageID, PagePrefix, type PagePrefixValue, QuestionID, RuleCustomVariable, RuleInput, RuleOptionSelectItem, RuleQuestionVariable, type RuleVariable, RuleVariableOption, RuleVariableSelectItem, SchemaConfig, SchemaID, SchemaPrefix, type SchemaPrefixValue, SingleSelectItem, SumScore, type SumScoreAnswer, SumScoreVariable, type SumScoreVariableDto, SumScoreVariableID, TagActionManager, TagCollection, TagID, TextID, VarID, type VideoFile, _CodeBook, createTypedIdSingleton };
1018
+ export { type AudioFile, BuilderCondition, type BuilderConditionDto, BuilderConditionGroup, type BuilderConditionGroupDto, type BuilderMainImageDto, BuilderMainText, type BuilderMainTextDto, type BuilderMainVideoDto, BuilderOperator, BuilderOption, type BuilderOptionDto, BuilderPage, type BuilderPageDto, type BuilderPageType, BuilderQuestion, type BuilderQuestionDto, type BuilderQuestionType, BuilderRule, type BuilderRuleDto, BuilderSchema, BuilderSchemaDto, BuilderTag, type BuilderTagDto, BuilderText, type BuilderTextDto, CodeBook, type CodeBookQuestionVariable, type Codebook, type CodebookPredefinedVariable, type CompilerOption, type CompilerOutput, ConditionGroupType, DefaultTheme, type ExcludeByPageAction, ExcludeByPageIdSelectItem, type ExcludeByTagAction, ExcludeByTagSelectItem, type ID, type ImageFile, JumpToActionManager, type JumpToPageAction, JumpToPageSelectItem, MultiSelectItem, OperatorSelectItem, OptionID, PageActionManager, PageID, PagePrefix, type PagePrefixValue, QuestionID, RuleCustomVariable, RuleInput, RuleOptionSelectItem, RuleQuestionVariable, type RuleVariable, RuleVariableOption, RuleVariableSelectItem, SchemaConfig, SchemaID, SchemaPrefix, type SchemaPrefixValue, SingleSelectItem, SumScore, type SumScoreAnswer, SumScoreVariable, type SumScoreVariableDto, SumScoreVariableID, TagActionManager, TagCollection, TagID, TextID, VarID, type VideoFile, _CodeBook, createTypedIdSingleton };
@@ -29,6 +29,7 @@ __export(public_api_exports, {
29
29
  BuilderQuestion: () => BuilderQuestion,
30
30
  BuilderRule: () => BuilderRule,
31
31
  BuilderSchema: () => BuilderSchema,
32
+ BuilderSchemaDto: () => BuilderSchemaDto,
32
33
  BuilderTag: () => BuilderTag,
33
34
  BuilderText: () => BuilderText,
34
35
  CodeBook: () => CodeBook,
@@ -1418,11 +1419,16 @@ var BuilderOptionTheme;
1418
1419
  const BLUE = "#2F5597";
1419
1420
  const BTN_BORDER_WIDTH = 3;
1420
1421
  const BTN_BORDER_RADIUS = 10;
1422
+ const BTN_HEIGHT = 130;
1423
+ const BTN_WIDTH_LONG = { _unit: "percent", value: 19 };
1424
+ const BTN_WIDTH_SHORT = { _unit: "percent", value: 15 };
1421
1425
  const BTN_BORDER_STYLE = "solid";
1422
- const FONT_WEIGHT = 600;
1423
- const FONT_SIZE = 50;
1424
- const BTN_PADDING_LEFT = 40;
1425
- const BTN_PADDING_TOP = 40;
1426
+ const FONT_WEIGHT = 500;
1427
+ const FONT_SIZE = 36;
1428
+ const MAIN_TEXT_FONT_SIZE = { _unit: "px", value: 36 };
1429
+ const MAIN_TEXT_WIDTH = { _unit: "percent", value: 80 };
1430
+ const BTN_PADDING_LEFT = 10;
1431
+ const BTN_PADDING_TOP = 10;
1426
1432
  const buttonBaseCss = () => ({
1427
1433
  css: {
1428
1434
  fontWeight: FONT_WEIGHT,
@@ -1434,6 +1440,8 @@ var BuilderOptionTheme;
1434
1440
  paddingRight: { _unit: "px", value: BTN_PADDING_LEFT },
1435
1441
  borderRadius: { _unit: "px", value: BTN_BORDER_RADIUS },
1436
1442
  borderWidth: { _unit: "px", value: BTN_BORDER_WIDTH },
1443
+ width: BTN_WIDTH_LONG,
1444
+ height: { _unit: "px", value: BTN_HEIGHT },
1437
1445
  borderStyle: BTN_BORDER_STYLE,
1438
1446
  // boxShadow: "3px 3px gray",
1439
1447
  position: "relative",
@@ -1468,7 +1476,8 @@ var BuilderOptionTheme;
1468
1476
  ...css,
1469
1477
  backgroundColor: WHITE,
1470
1478
  borderColor: LIGHT_BLUE,
1471
- textColor: BLUE
1479
+ textColor: BLUE,
1480
+ width: BTN_WIDTH_SHORT
1472
1481
  },
1473
1482
  cssDisabled,
1474
1483
  cssEnabled
@@ -1486,9 +1495,10 @@ var textLowTop = 55;
1486
1495
  var audioHighTop = 20;
1487
1496
  var audioLowTop = 55;
1488
1497
  var textBase = {
1489
- width: 80,
1498
+ width: 76,
1499
+ // backgroundColor: "red",
1490
1500
  top: textHighTop,
1491
- left: 10,
1501
+ left: 12,
1492
1502
  textAlign: "center",
1493
1503
  textColor: "black",
1494
1504
  fontSize: { _unit: "px", value: 40 }
@@ -1558,8 +1568,8 @@ var DefaultTheme = {
1558
1568
  bottom: 0,
1559
1569
  left: 0,
1560
1570
  // h: 10,
1561
- alignItems: "center",
1562
- backgroundColor: "yellow"
1571
+ alignItems: "center"
1572
+ // backgroundColor: "yellow",
1563
1573
  },
1564
1574
  whenSingle: { justifyContent: "space-evenly" },
1565
1575
  whenMany: { justifyContent: "space-evenly" }
@@ -1778,15 +1788,15 @@ var responseButtonBaseCss = () => ({
1778
1788
  borderColor: Colors.primary,
1779
1789
  textColor: Colors.white,
1780
1790
  fontWeight: 600,
1781
- fontSize: { _unit: "px", value: 30 },
1782
- lineHeight: 1,
1783
- maxWidth: 30,
1791
+ fontSize: { _unit: "px", value: 28 },
1792
+ lineHeight: 1.1,
1793
+ maxWidth: 25,
1784
1794
  // width: 20,
1785
1795
  // flex: "0 0 auto",
1786
- paddingLeft: { _unit: "px", value: 30 },
1787
- paddingTop: { _unit: "px", value: 10 },
1788
- paddingBottom: { _unit: "px", value: 10 },
1789
- paddingRight: { _unit: "px", value: 30 },
1796
+ paddingLeft: { _unit: "px", value: 10 },
1797
+ paddingTop: { _unit: "px", value: 5 },
1798
+ paddingBottom: { _unit: "px", value: 5 },
1799
+ paddingRight: { _unit: "px", value: 10 },
1790
1800
  borderRadius: { _unit: "px", value: 20 },
1791
1801
  borderStyle: "solid",
1792
1802
  boxShadow: "3px 3px gray",
@@ -1986,11 +1996,11 @@ var Theme2 = {
1986
1996
  display: "flex",
1987
1997
  justifyContent: "flex-start",
1988
1998
  width: BUTTON_BAR_WIDTH,
1989
- height: 8,
1999
+ height: 6,
1990
2000
  bottom: Q_AREA_BOTTOM + H_M3,
1991
2001
  left: Q_AREA_LEFT + W_M3,
1992
2002
  // backgroundColor: "green",
1993
- gap: { _unit: "px", value: 20 },
2003
+ gap: { _unit: "px", value: 40 },
1994
2004
  alignItems: "stretch"
1995
2005
  },
1996
2006
  whenSingle: { justifyContent: "center" },
@@ -2006,7 +2016,7 @@ var DefaultThemeCompiler = class {
2006
2016
  name = "Ispe default theme.";
2007
2017
  defaultTheme = DefaultTheme;
2008
2018
  theme2 = Theme2;
2009
- currentTheme = Theme2;
2019
+ currentTheme = DefaultTheme;
2010
2020
  allThemes = [DefaultTheme, Theme2];
2011
2021
  TAG = "[ DEFAULT_THEME_COMPILER ]: ";
2012
2022
  setTheme(theme) {
@@ -2078,6 +2088,7 @@ var DefaultThemeCompiler = class {
2078
2088
  let initialVideoTaskList = [];
2079
2089
  const newPage = {
2080
2090
  background: "white",
2091
+ pageNumber,
2081
2092
  elements,
2082
2093
  id,
2083
2094
  prefix,
@@ -2939,6 +2950,45 @@ var BuilderPageCollection = class _BuilderPageCollection {
2939
2950
  }
2940
2951
  };
2941
2952
 
2953
+ // src/Builder-schema-dto.ts
2954
+ var blockAutoplayVideo = (dto) => {
2955
+ if (dto.mainMedia && dto.mainMedia.kind === "main-video") {
2956
+ dto.mainMedia.mode = "optional";
2957
+ }
2958
+ return dto;
2959
+ };
2960
+ var overrideVideoUrl = (dto, baseUrl) => {
2961
+ if (dto.mainMedia && dto.mainMedia.kind === "main-video") {
2962
+ dto.mainMedia.file.downloadUrl = [baseUrl, dto.mainMedia.file.id].join("/");
2963
+ }
2964
+ return dto;
2965
+ };
2966
+ var overrideImageUrl = (dto, baseUrl) => {
2967
+ if (dto.mainMedia && dto.mainMedia.kind === "main-image") {
2968
+ dto.mainMedia.file.downloadUrl = [baseUrl, dto.mainMedia.file.id].join("/");
2969
+ }
2970
+ return dto;
2971
+ };
2972
+ var overrideAudioUrl = (dto, baseUrl) => {
2973
+ if (dto.mainText.audioFile) {
2974
+ dto.mainText.audioFile.downloadUrl = [baseUrl, dto.mainText.audioFile.id].join("/");
2975
+ }
2976
+ return dto;
2977
+ };
2978
+ var overrideAllMediaUrls = (schema, options) => {
2979
+ const pages = schema.pages.map((page) => {
2980
+ page = overrideVideoUrl(page, options.videoFilesBaseUrl);
2981
+ page = overrideImageUrl(page, options.imageFilesBaseUrl);
2982
+ page = overrideAudioUrl(page, options.audioFilesBaseUrl);
2983
+ return page;
2984
+ });
2985
+ return { ...schema, pages };
2986
+ };
2987
+ var BuilderSchemaDto = {
2988
+ blockAutoplayVideo,
2989
+ overrideAllMediaUrls
2990
+ };
2991
+
2942
2992
  // src/Builder-schema.ts
2943
2993
  var BuilderSchema = class _BuilderSchema {
2944
2994
  constructor(id, name, prefix) {
@@ -3132,8 +3182,12 @@ var BuilderSchema = class _BuilderSchema {
3132
3182
  addTag(builderTag) {
3133
3183
  this._tagCollection.add(builderTag);
3134
3184
  }
3135
- compile(options = { blockAutoplayQuestion: false, blockAutoplayVideo: false }) {
3136
- const builderSchema = _BuilderSchema.fromJson(this.toJson());
3185
+ compile(options = {
3186
+ blockAutoplayQuestion: false,
3187
+ blockAutoplayVideo: false,
3188
+ mediaAssets: null
3189
+ }) {
3190
+ let builderSchema = _BuilderSchema.fromJson(this.toJson());
3137
3191
  builderSchema._pageCollection.pages.forEach((p) => {
3138
3192
  if (options.blockAutoplayQuestion) {
3139
3193
  p.mainText.autoplay = false;
@@ -3144,7 +3198,15 @@ var BuilderSchema = class _BuilderSchema {
3144
3198
  }
3145
3199
  }
3146
3200
  });
3147
- const moduleDto = builderSchema.toJson();
3201
+ let moduleDto = builderSchema.toJson();
3202
+ if (options.mediaAssets) {
3203
+ const { videoFilesBaseUrl, audioFilesBaseUrl, imageFilesBaseUrl } = options.mediaAssets;
3204
+ moduleDto = BuilderSchemaDto.overrideAllMediaUrls(moduleDto, {
3205
+ videoFilesBaseUrl,
3206
+ audioFilesBaseUrl,
3207
+ imageFilesBaseUrl
3208
+ });
3209
+ }
3148
3210
  const codebook = CodeBook.fromSchema(moduleDto);
3149
3211
  const schema = this.compiler.compile(moduleDto);
3150
3212
  const schemaConfig = SchemaConfig.fromSchema(moduleDto);
@@ -3331,6 +3393,7 @@ var SumScore = {
3331
3393
  BuilderQuestion,
3332
3394
  BuilderRule,
3333
3395
  BuilderSchema,
3396
+ BuilderSchemaDto,
3334
3397
  BuilderTag,
3335
3398
  BuilderText,
3336
3399
  CodeBook,