@media-quest/builder 0.0.34 → 0.0.35

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,
@@ -1778,15 +1779,15 @@ var responseButtonBaseCss = () => ({
1778
1779
  borderColor: Colors.primary,
1779
1780
  textColor: Colors.white,
1780
1781
  fontWeight: 600,
1781
- fontSize: { _unit: "px", value: 30 },
1782
- lineHeight: 1,
1783
- maxWidth: 30,
1782
+ fontSize: { _unit: "px", value: 28 },
1783
+ lineHeight: 1.1,
1784
+ maxWidth: 25,
1784
1785
  // width: 20,
1785
1786
  // 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 },
1787
+ paddingLeft: { _unit: "px", value: 10 },
1788
+ paddingTop: { _unit: "px", value: 5 },
1789
+ paddingBottom: { _unit: "px", value: 5 },
1790
+ paddingRight: { _unit: "px", value: 10 },
1790
1791
  borderRadius: { _unit: "px", value: 20 },
1791
1792
  borderStyle: "solid",
1792
1793
  boxShadow: "3px 3px gray",
@@ -1986,11 +1987,11 @@ var Theme2 = {
1986
1987
  display: "flex",
1987
1988
  justifyContent: "flex-start",
1988
1989
  width: BUTTON_BAR_WIDTH,
1989
- height: 8,
1990
+ height: 6,
1990
1991
  bottom: Q_AREA_BOTTOM + H_M3,
1991
1992
  left: Q_AREA_LEFT + W_M3,
1992
1993
  // backgroundColor: "green",
1993
- gap: { _unit: "px", value: 20 },
1994
+ gap: { _unit: "px", value: 40 },
1994
1995
  alignItems: "stretch"
1995
1996
  },
1996
1997
  whenSingle: { justifyContent: "center" },
@@ -2939,6 +2940,45 @@ var BuilderPageCollection = class _BuilderPageCollection {
2939
2940
  }
2940
2941
  };
2941
2942
 
2943
+ // src/Builder-schema-dto.ts
2944
+ var blockAutoplayVideo = (dto) => {
2945
+ if (dto.mainMedia && dto.mainMedia.kind === "main-video") {
2946
+ dto.mainMedia.mode = "optional";
2947
+ }
2948
+ return dto;
2949
+ };
2950
+ var overrideVideoUrl = (dto, baseUrl) => {
2951
+ if (dto.mainMedia && dto.mainMedia.kind === "main-video") {
2952
+ dto.mainMedia.file.downloadUrl = [baseUrl, dto.mainMedia.file.id].join("/");
2953
+ }
2954
+ return dto;
2955
+ };
2956
+ var overrideImageUrl = (dto, baseUrl) => {
2957
+ if (dto.mainMedia && dto.mainMedia.kind === "main-image") {
2958
+ dto.mainMedia.file.downloadUrl = [baseUrl, dto.mainMedia.file.id].join("/");
2959
+ }
2960
+ return dto;
2961
+ };
2962
+ var overrideAudioUrl = (dto, baseUrl) => {
2963
+ if (dto.mainText.audioFile) {
2964
+ dto.mainText.audioFile.downloadUrl = [baseUrl, dto.mainText.audioFile.id].join("/");
2965
+ }
2966
+ return dto;
2967
+ };
2968
+ var overrideAllMediaUrls = (schema, options) => {
2969
+ const pages = schema.pages.map((page) => {
2970
+ page = overrideVideoUrl(page, options.videoFilesBaseUrl);
2971
+ page = overrideImageUrl(page, options.imageFilesBaseUrl);
2972
+ page = overrideAudioUrl(page, options.audioFilesBaseUrl);
2973
+ return page;
2974
+ });
2975
+ return { ...schema, pages };
2976
+ };
2977
+ var BuilderSchemaDto = {
2978
+ blockAutoplayVideo,
2979
+ overrideAllMediaUrls
2980
+ };
2981
+
2942
2982
  // src/Builder-schema.ts
2943
2983
  var BuilderSchema = class _BuilderSchema {
2944
2984
  constructor(id, name, prefix) {
@@ -3132,8 +3172,12 @@ var BuilderSchema = class _BuilderSchema {
3132
3172
  addTag(builderTag) {
3133
3173
  this._tagCollection.add(builderTag);
3134
3174
  }
3135
- compile(options = { blockAutoplayQuestion: false, blockAutoplayVideo: false }) {
3136
- const builderSchema = _BuilderSchema.fromJson(this.toJson());
3175
+ compile(options = {
3176
+ blockAutoplayQuestion: false,
3177
+ blockAutoplayVideo: false,
3178
+ mediaAssets: null
3179
+ }) {
3180
+ let builderSchema = _BuilderSchema.fromJson(this.toJson());
3137
3181
  builderSchema._pageCollection.pages.forEach((p) => {
3138
3182
  if (options.blockAutoplayQuestion) {
3139
3183
  p.mainText.autoplay = false;
@@ -3144,7 +3188,15 @@ var BuilderSchema = class _BuilderSchema {
3144
3188
  }
3145
3189
  }
3146
3190
  });
3147
- const moduleDto = builderSchema.toJson();
3191
+ let moduleDto = builderSchema.toJson();
3192
+ if (options.mediaAssets) {
3193
+ const { videoFilesBaseUrl, audioFilesBaseUrl, imageFilesBaseUrl } = options.mediaAssets;
3194
+ moduleDto = BuilderSchemaDto.overrideAllMediaUrls(moduleDto, {
3195
+ videoFilesBaseUrl,
3196
+ audioFilesBaseUrl,
3197
+ imageFilesBaseUrl
3198
+ });
3199
+ }
3148
3200
  const codebook = CodeBook.fromSchema(moduleDto);
3149
3201
  const schema = this.compiler.compile(moduleDto);
3150
3202
  const schemaConfig = SchemaConfig.fromSchema(moduleDto);
@@ -3331,6 +3383,7 @@ var SumScore = {
3331
3383
  BuilderQuestion,
3332
3384
  BuilderRule,
3333
3385
  BuilderSchema,
3386
+ BuilderSchemaDto,
3334
3387
  BuilderTag,
3335
3388
  BuilderText,
3336
3389
  CodeBook,