@churchapps/content-providers 0.1.12 → 0.1.13
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.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +56 -56
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,7 +17,8 @@ function slugify(text) {
|
|
|
17
17
|
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
18
18
|
}
|
|
19
19
|
function detectMediaType(url, explicitType) {
|
|
20
|
-
if (explicitType === "video") return "video";
|
|
20
|
+
if (explicitType === "video" || explicitType?.startsWith("video/")) return "video";
|
|
21
|
+
if (explicitType === "image" || explicitType?.startsWith("image/")) return "image";
|
|
21
22
|
const videoPatterns = [".mp4", ".webm", ".m3u8", ".mov", "stream.mux.com"];
|
|
22
23
|
return videoPatterns.some((p) => url.includes(p)) ? "video" : "image";
|
|
23
24
|
}
|
|
@@ -943,6 +944,7 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
943
944
|
const actionThumbnailMap = /* @__PURE__ */ new Map();
|
|
944
945
|
const actionUrlMap = /* @__PURE__ */ new Map();
|
|
945
946
|
const actionContentMap = /* @__PURE__ */ new Map();
|
|
947
|
+
const actionMediaTypeMap = /* @__PURE__ */ new Map();
|
|
946
948
|
if (feedResponse?.sections) {
|
|
947
949
|
for (const section of feedResponse.sections) {
|
|
948
950
|
for (const action of section.actions || []) {
|
|
@@ -951,7 +953,10 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
951
953
|
if (action.files?.length) {
|
|
952
954
|
const firstFile = action.files[0];
|
|
953
955
|
if (firstFile?.thumbnail) actionThumbnailMap.set(action.id, firstFile.thumbnail);
|
|
954
|
-
if (firstFile?.url)
|
|
956
|
+
if (firstFile?.url) {
|
|
957
|
+
actionUrlMap.set(action.id, firstFile.url);
|
|
958
|
+
actionMediaTypeMap.set(action.id, detectMediaType(firstFile.url, firstFile.fileType));
|
|
959
|
+
}
|
|
955
960
|
}
|
|
956
961
|
}
|
|
957
962
|
}
|
|
@@ -966,11 +971,12 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
966
971
|
const hasFiles = rawActionType === "play" || rawActionType === "add-on";
|
|
967
972
|
const thumbnail = action.id && actionThumbnailMap.get(action.id) || lessonImage;
|
|
968
973
|
const downloadUrl = action.id ? actionUrlMap.get(action.id) : void 0;
|
|
974
|
+
const mediaType = action.id ? actionMediaTypeMap.get(action.id) : void 0;
|
|
969
975
|
const fullContent = action.id ? actionContentMap.get(action.id) : void 0;
|
|
970
976
|
const label = fullContent ? truncateForLabel(fullContent) : action.name;
|
|
971
977
|
const needsFullContent = fullContent && (fullContent.length > 100 || fullContent.includes("\n"));
|
|
972
978
|
const content = needsFullContent ? fullContent : void 0;
|
|
973
|
-
return { id: action.id, itemType: "action", relatedId: action.id, label, actionType: rawActionType || void 0, content, seconds, downloadUrl, thumbnail, children: hasFiles ? [{ id: action.id + "-file", itemType: "file", label: action.name, seconds, downloadUrl, thumbnail }] : void 0 };
|
|
979
|
+
return { id: action.id, itemType: "action", relatedId: action.id, label, actionType: rawActionType || void 0, content, seconds, downloadUrl, mediaType, thumbnail, children: hasFiles ? [{ id: action.id + "-file", itemType: "file", label: action.name, seconds, downloadUrl, mediaType, thumbnail }] : void 0 };
|
|
974
980
|
}));
|
|
975
981
|
}
|
|
976
982
|
}
|
|
@@ -990,7 +996,9 @@ function processInstructionItem(item, sectionActionsMap, thumbnail) {
|
|
|
990
996
|
const childItemType = normalizeItemType(rawChildItemType);
|
|
991
997
|
if (childRelatedId && sectionActionsMap.has(childRelatedId)) {
|
|
992
998
|
const sectionActions = sectionActionsMap.get(childRelatedId);
|
|
993
|
-
const
|
|
999
|
+
const firstAction = sectionActions?.[0];
|
|
1000
|
+
const firstActionUrl = firstAction?.downloadUrl;
|
|
1001
|
+
const firstActionMediaType = firstAction?.mediaType;
|
|
994
1002
|
return {
|
|
995
1003
|
id: child.id,
|
|
996
1004
|
itemType: childItemType,
|
|
@@ -1001,6 +1009,7 @@ function processInstructionItem(item, sectionActionsMap, thumbnail) {
|
|
|
1001
1009
|
seconds: child.seconds,
|
|
1002
1010
|
children: sectionActions,
|
|
1003
1011
|
downloadUrl: firstActionUrl,
|
|
1012
|
+
mediaType: firstActionMediaType,
|
|
1004
1013
|
thumbnail
|
|
1005
1014
|
};
|
|
1006
1015
|
}
|
|
@@ -1038,13 +1047,15 @@ async function convertAddOnCategoryToInstructions(category) {
|
|
|
1038
1047
|
const file = await convertAddOnToFile(addOn);
|
|
1039
1048
|
const seconds = file?.seconds || addOn.seconds || 10;
|
|
1040
1049
|
const downloadUrl = file?.url;
|
|
1050
|
+
const mediaType = file?.mediaType;
|
|
1041
1051
|
children.push({
|
|
1042
1052
|
id,
|
|
1043
1053
|
itemType: "action",
|
|
1044
1054
|
relatedId: id,
|
|
1045
1055
|
label,
|
|
1046
1056
|
seconds,
|
|
1047
|
-
|
|
1057
|
+
mediaType,
|
|
1058
|
+
children: [{ id: id + "-file", itemType: "file", label, seconds, downloadUrl, mediaType, thumbnail: addOnImage }]
|
|
1048
1059
|
});
|
|
1049
1060
|
}
|
|
1050
1061
|
if (children.length === 0) return null;
|