@dominevo/addon-media-library 0.1.8 → 0.1.10
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/CHANGELOG.md +13 -0
- package/dist/media-library.addon.js +455 -30
- package/dist/media-library.addon.mjs +455 -30
- package/dist/rn-app/index.native.js +136 -0
- package/dist/rn-app/index.web.js +136 -0
- package/i18n/en.json +1 -0
- package/i18n/it.json +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/rn-app/index.tsx
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
default: () => index_default,
|
|
33
|
+
hostApi: () => hostApi
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/rn-app/MediaPluginApp.tsx
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_react_native = require("react-native");
|
|
40
|
+
var import_expo_image = require("expo-image");
|
|
41
|
+
var import_react_native_video = __toESM(require("react-native-video"));
|
|
42
|
+
var import_viewer_kit = require("@dominevo/viewer-kit");
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === "object" && value !== null;
|
|
45
|
+
}
|
|
46
|
+
function isPosterItem(value) {
|
|
47
|
+
return isRecord(value) && typeof value["id"] === "string" && typeof value["title"] === "string" && typeof value["playable"] === "boolean";
|
|
48
|
+
}
|
|
49
|
+
function readPosterItems(data) {
|
|
50
|
+
const items = isRecord(data) ? data["items"] : null;
|
|
51
|
+
return Array.isArray(items) ? items.filter(isPosterItem) : [];
|
|
52
|
+
}
|
|
53
|
+
function readPlayPath(data) {
|
|
54
|
+
if (!isRecord(data)) return { title: "", playPath: null };
|
|
55
|
+
const { title, playPath } = data;
|
|
56
|
+
return {
|
|
57
|
+
title: typeof title === "string" ? title : "",
|
|
58
|
+
playPath: typeof playPath === "string" ? playPath : null
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var PAGE_SIZE = 60;
|
|
62
|
+
var COLUMNS = 3;
|
|
63
|
+
function Player({
|
|
64
|
+
itemId,
|
|
65
|
+
onClose
|
|
66
|
+
}) {
|
|
67
|
+
const t = (0, import_viewer_kit.useT)();
|
|
68
|
+
const theme = (0, import_viewer_kit.useKitTheme)();
|
|
69
|
+
const hubUrl = (0, import_viewer_kit.useHubUrl)();
|
|
70
|
+
const headersFor = (0, import_viewer_kit.useAuthHeaders)();
|
|
71
|
+
const detail = (0, import_viewer_kit.useCapQuery)("media-library", "getItem", { itemId });
|
|
72
|
+
const { title, playPath } = readPlayPath(detail.data);
|
|
73
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: "#000000" } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.ScreenHeader, { title, onBack: onClose }), playPath !== null ? /* @__PURE__ */ import_react.default.createElement(
|
|
74
|
+
import_react_native_video.default,
|
|
75
|
+
{
|
|
76
|
+
source: { uri: hubUrl(playPath), headers: headersFor(hubUrl(playPath)) },
|
|
77
|
+
style: { flex: 1, backgroundColor: "#000000" },
|
|
78
|
+
controls: true,
|
|
79
|
+
resizeMode: "contain"
|
|
80
|
+
}
|
|
81
|
+
) : detail.isLoading ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.SkeletonBox, { style: { flex: 1 } }) : /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: theme.colors.background } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.EmptyState, { title: t("media.player.failed", "This cannot be played") })));
|
|
82
|
+
}
|
|
83
|
+
function MediaPluginApp(_props) {
|
|
84
|
+
const t = (0, import_viewer_kit.useT)();
|
|
85
|
+
const theme = (0, import_viewer_kit.useKitTheme)();
|
|
86
|
+
const hubUrl = (0, import_viewer_kit.useHubUrl)();
|
|
87
|
+
const headersFor = (0, import_viewer_kit.useAuthHeaders)();
|
|
88
|
+
const [playing, setPlaying] = (0, import_react.useState)(null);
|
|
89
|
+
const movies = (0, import_viewer_kit.useCapQuery)("media-library", "listMovies", { limit: PAGE_SIZE });
|
|
90
|
+
if (playing !== null) return /* @__PURE__ */ import_react.default.createElement(Player, { itemId: playing, onClose: () => setPlaying(null) });
|
|
91
|
+
const items = readPosterItems(movies.data).filter((item) => item.playable);
|
|
92
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: theme.colors.background } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.ScreenHeader, { title: t("mediaLibrary.apps.mediaPlugin", "Media (plugin)") }), movies.isLoading ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.SkeletonBox, { style: { height: 240 } }) : items.length === 0 ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.EmptyState, { title: t("media.empty", "Nothing to watch yet") }) : /* @__PURE__ */ import_react.default.createElement(
|
|
93
|
+
import_react_native.FlatList,
|
|
94
|
+
{
|
|
95
|
+
data: items,
|
|
96
|
+
numColumns: COLUMNS,
|
|
97
|
+
keyExtractor: (item) => item.id,
|
|
98
|
+
contentContainerStyle: { padding: theme.spacing.md },
|
|
99
|
+
renderItem: ({ item }) => /* @__PURE__ */ import_react.default.createElement(
|
|
100
|
+
import_react_native.Pressable,
|
|
101
|
+
{
|
|
102
|
+
style: { flex: 1, padding: theme.spacing.sm },
|
|
103
|
+
onPress: () => setPlaying(item.id)
|
|
104
|
+
},
|
|
105
|
+
item.posterPath !== null ? /* @__PURE__ */ import_react.default.createElement(
|
|
106
|
+
import_expo_image.Image,
|
|
107
|
+
{
|
|
108
|
+
source: {
|
|
109
|
+
uri: hubUrl(item.posterPath),
|
|
110
|
+
headers: headersFor(hubUrl(item.posterPath))
|
|
111
|
+
},
|
|
112
|
+
style: { width: "100%", aspectRatio: 2 / 3, borderRadius: theme.radius.lg },
|
|
113
|
+
contentFit: "cover"
|
|
114
|
+
}
|
|
115
|
+
) : /* @__PURE__ */ import_react.default.createElement(
|
|
116
|
+
import_react_native.View,
|
|
117
|
+
{
|
|
118
|
+
style: { width: "100%", aspectRatio: 2 / 3, borderRadius: theme.radius.lg }
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
122
|
+
import_react_native.Text,
|
|
123
|
+
{
|
|
124
|
+
numberOfLines: 1,
|
|
125
|
+
style: { color: theme.colors.foreground, fontSize: theme.typography.size.sm }
|
|
126
|
+
},
|
|
127
|
+
item.title
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/rn-app/index.tsx
|
|
135
|
+
var hostApi = 1;
|
|
136
|
+
var index_default = MediaPluginApp;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/rn-app/index.tsx
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
default: () => index_default,
|
|
33
|
+
hostApi: () => hostApi
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/rn-app/MediaPluginApp.tsx
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_react_native = require("react-native");
|
|
40
|
+
var import_expo_image = require("expo-image");
|
|
41
|
+
var import_react_native_video = __toESM(require("react-native-video"));
|
|
42
|
+
var import_viewer_kit = require("@dominevo/viewer-kit");
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === "object" && value !== null;
|
|
45
|
+
}
|
|
46
|
+
function isPosterItem(value) {
|
|
47
|
+
return isRecord(value) && typeof value["id"] === "string" && typeof value["title"] === "string" && typeof value["playable"] === "boolean";
|
|
48
|
+
}
|
|
49
|
+
function readPosterItems(data) {
|
|
50
|
+
const items = isRecord(data) ? data["items"] : null;
|
|
51
|
+
return Array.isArray(items) ? items.filter(isPosterItem) : [];
|
|
52
|
+
}
|
|
53
|
+
function readPlayPath(data) {
|
|
54
|
+
if (!isRecord(data)) return { title: "", playPath: null };
|
|
55
|
+
const { title, playPath } = data;
|
|
56
|
+
return {
|
|
57
|
+
title: typeof title === "string" ? title : "",
|
|
58
|
+
playPath: typeof playPath === "string" ? playPath : null
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var PAGE_SIZE = 60;
|
|
62
|
+
var COLUMNS = 3;
|
|
63
|
+
function Player({
|
|
64
|
+
itemId,
|
|
65
|
+
onClose
|
|
66
|
+
}) {
|
|
67
|
+
const t = (0, import_viewer_kit.useT)();
|
|
68
|
+
const theme = (0, import_viewer_kit.useKitTheme)();
|
|
69
|
+
const hubUrl = (0, import_viewer_kit.useHubUrl)();
|
|
70
|
+
const headersFor = (0, import_viewer_kit.useAuthHeaders)();
|
|
71
|
+
const detail = (0, import_viewer_kit.useCapQuery)("media-library", "getItem", { itemId });
|
|
72
|
+
const { title, playPath } = readPlayPath(detail.data);
|
|
73
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: "#000000" } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.ScreenHeader, { title, onBack: onClose }), playPath !== null ? /* @__PURE__ */ import_react.default.createElement(
|
|
74
|
+
import_react_native_video.default,
|
|
75
|
+
{
|
|
76
|
+
source: { uri: hubUrl(playPath), headers: headersFor(hubUrl(playPath)) },
|
|
77
|
+
style: { flex: 1, backgroundColor: "#000000" },
|
|
78
|
+
controls: true,
|
|
79
|
+
resizeMode: "contain"
|
|
80
|
+
}
|
|
81
|
+
) : detail.isLoading ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.SkeletonBox, { style: { flex: 1 } }) : /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: theme.colors.background } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.EmptyState, { title: t("media.player.failed", "This cannot be played") })));
|
|
82
|
+
}
|
|
83
|
+
function MediaPluginApp(_props) {
|
|
84
|
+
const t = (0, import_viewer_kit.useT)();
|
|
85
|
+
const theme = (0, import_viewer_kit.useKitTheme)();
|
|
86
|
+
const hubUrl = (0, import_viewer_kit.useHubUrl)();
|
|
87
|
+
const headersFor = (0, import_viewer_kit.useAuthHeaders)();
|
|
88
|
+
const [playing, setPlaying] = (0, import_react.useState)(null);
|
|
89
|
+
const movies = (0, import_viewer_kit.useCapQuery)("media-library", "listMovies", { limit: PAGE_SIZE });
|
|
90
|
+
if (playing !== null) return /* @__PURE__ */ import_react.default.createElement(Player, { itemId: playing, onClose: () => setPlaying(null) });
|
|
91
|
+
const items = readPosterItems(movies.data).filter((item) => item.playable);
|
|
92
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: { flex: 1, backgroundColor: theme.colors.background } }, /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.ScreenHeader, { title: t("mediaLibrary.apps.mediaPlugin", "Media (plugin)") }), movies.isLoading ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.SkeletonBox, { style: { height: 240 } }) : items.length === 0 ? /* @__PURE__ */ import_react.default.createElement(import_viewer_kit.EmptyState, { title: t("media.empty", "Nothing to watch yet") }) : /* @__PURE__ */ import_react.default.createElement(
|
|
93
|
+
import_react_native.FlatList,
|
|
94
|
+
{
|
|
95
|
+
data: items,
|
|
96
|
+
numColumns: COLUMNS,
|
|
97
|
+
keyExtractor: (item) => item.id,
|
|
98
|
+
contentContainerStyle: { padding: theme.spacing.md },
|
|
99
|
+
renderItem: ({ item }) => /* @__PURE__ */ import_react.default.createElement(
|
|
100
|
+
import_react_native.Pressable,
|
|
101
|
+
{
|
|
102
|
+
style: { flex: 1, padding: theme.spacing.sm },
|
|
103
|
+
onPress: () => setPlaying(item.id)
|
|
104
|
+
},
|
|
105
|
+
item.posterPath !== null ? /* @__PURE__ */ import_react.default.createElement(
|
|
106
|
+
import_expo_image.Image,
|
|
107
|
+
{
|
|
108
|
+
source: {
|
|
109
|
+
uri: hubUrl(item.posterPath),
|
|
110
|
+
headers: headersFor(hubUrl(item.posterPath))
|
|
111
|
+
},
|
|
112
|
+
style: { width: "100%", aspectRatio: 2 / 3, borderRadius: theme.radius.lg },
|
|
113
|
+
contentFit: "cover"
|
|
114
|
+
}
|
|
115
|
+
) : /* @__PURE__ */ import_react.default.createElement(
|
|
116
|
+
import_react_native.View,
|
|
117
|
+
{
|
|
118
|
+
style: { width: "100%", aspectRatio: 2 / 3, borderRadius: theme.radius.lg }
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
122
|
+
import_react_native.Text,
|
|
123
|
+
{
|
|
124
|
+
numberOfLines: 1,
|
|
125
|
+
style: { color: theme.colors.foreground, fontSize: theme.typography.size.sm }
|
|
126
|
+
},
|
|
127
|
+
item.title
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/rn-app/index.tsx
|
|
135
|
+
var hostApi = 1;
|
|
136
|
+
var index_default = MediaPluginApp;
|
package/i18n/en.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"manifest.media-library.name": "Media Library",
|
|
3
3
|
"manifest.media-library.description": "The series and movies on the hub's disks as a catalogue (from the arr apps and plain folders), with per-user progress, direct play and a native Media app in the viewer.",
|
|
4
4
|
"apps.media": "Media",
|
|
5
|
+
"apps.mediaPlugin": "Media (plugin)",
|
|
5
6
|
"mediaLibraryAddon.clusterSettings.s_series.title": "Series source",
|
|
6
7
|
"mediaLibraryAddon.clusterSettings.s_series.seriesArrUrl.label": "Sonarr URL",
|
|
7
8
|
"mediaLibraryAddon.clusterSettings.s_series.seriesArrUrl.description": "Address of the series app, for example http://192.168.1.20:8989. Empty turns the source off.",
|
package/i18n/it.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"manifest.media-library.name": "Libreria multimediale",
|
|
3
3
|
"manifest.media-library.description": "Le serie e i film sui dischi dell'hub come catalogo (dalle app arr e da cartelle semplici), con avanzamento per utente, riproduzione diretta e un'app Media nativa nel viewer.",
|
|
4
4
|
"apps.media": "Media",
|
|
5
|
+
"apps.mediaPlugin": "Media (plugin)",
|
|
5
6
|
"mediaLibraryAddon.clusterSettings.s_series.title": "Sorgente serie",
|
|
6
7
|
"mediaLibraryAddon.clusterSettings.s_series.seriesArrUrl.label": "URL di Sonarr",
|
|
7
8
|
"mediaLibraryAddon.clusterSettings.s_series.seriesArrUrl.description": "Indirizzo dell'app delle serie, per esempio http://192.168.1.20:8989. Vuoto disattiva la sorgente.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dominevo/addon-media-library",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "The self-hosted media library: a catalogue built from the arr apps and plain folders, probed files, per-user progress, direct play with Range and a native /media app in the viewer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dominevo",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
}
|
|
59
59
|
],
|
|
60
60
|
"requires": {
|
|
61
|
-
"server": ">=0.1.
|
|
61
|
+
"server": ">=0.1.65"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"files": [
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"CHANGELOG.md"
|
|
70
70
|
],
|
|
71
71
|
"scripts": {
|
|
72
|
-
"build": "vite build",
|
|
72
|
+
"build": "vite build && tsx ../../scripts/build-rn-plugin.ts src/rn-app/index.tsx dist/rn-app",
|
|
73
73
|
"typecheck": "tsc --noEmit -p tsconfig.spec.json",
|
|
74
74
|
"test": "vitest run"
|
|
75
75
|
},
|