@dominevo/addon-media-library 0.1.9 → 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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.10] - 2026-12-03
11
+
12
+ ### Changed
13
+
14
+ - Adds an admin-only 'Media (plugin)' app, a React Native plugin spike the viewer loads from the addon.
15
+
10
16
  ## [0.1.9] - 2026-12-03
11
17
 
12
18
  ### Changed
@@ -4,8 +4,8 @@ Object.defineProperties(exports, {
4
4
  });
5
5
  let node_fs_promises = require("node:fs/promises");
6
6
  let node_path = require("node:path");
7
- let node_fs = require("node:fs");
8
7
  let node_crypto = require("node:crypto");
8
+ let node_fs = require("node:fs");
9
9
  let node_child_process = require("node:child_process");
10
10
  let node_dns_promises = require("node:dns/promises");
11
11
  let node_net = require("node:net");
@@ -8690,6 +8690,17 @@ var AppEntrySchema = /* @__PURE__ */ discriminatedUnion("kind", [
8690
8690
  /* @__PURE__ */ object({
8691
8691
  kind: /* @__PURE__ */ literal("addon-page"),
8692
8692
  pageId: /* @__PURE__ */ string()
8693
+ }),
8694
+ /* @__PURE__ */ object({
8695
+ kind: /* @__PURE__ */ literal("rn-plugin"),
8696
+ /** Asset path of the bundle for iOS and Android, served at `/api/addon-assets/<addonId>/<path>`. */
8697
+ native: /* @__PURE__ */ string().min(1),
8698
+ /** Asset path of the bundle for the web viewer (same source; `react-native` maps to react-native-web). */
8699
+ web: /* @__PURE__ */ string().min(1),
8700
+ /** The host API the bundle was built against; the shell refuses a plugin newer than its own. */
8701
+ hostApi: /* @__PURE__ */ number().int().min(1),
8702
+ /** Cache key of the bundle on the device: a new value fetches it again. */
8703
+ version: /* @__PURE__ */ string().min(1)
8693
8704
  })
8694
8705
  ]);
8695
8706
  /**
@@ -9078,6 +9089,23 @@ function buildAddressRoles() {
9078
9089
  }];
9079
9090
  }
9080
9091
  //#endregion
9092
+ //#region src/rn-app/plugin-version.ts
9093
+ /** Where the build writes the plugin, relative to the package root; these paths are the `rn-plugin` entry's assets. */
9094
+ var PLUGIN_NATIVE_ASSET = "dist/rn-app/index.native.js";
9095
+ var PLUGIN_WEB_ASSET = "dist/rn-app/index.web.js";
9096
+ /**
9097
+ * The cache key of the built plugin: the package version plus a hash of both bundles, so a rebuild
9098
+ * of the same package version still reaches a device that cached the old one. `null` when the
9099
+ * bundles are not built (a dev checkout): the plugin app is then not declared.
9100
+ */
9101
+ function readPluginVersion(packageDir) {
9102
+ const native = (0, node_path.join)(packageDir, PLUGIN_NATIVE_ASSET);
9103
+ const web = (0, node_path.join)(packageDir, PLUGIN_WEB_ASSET);
9104
+ if (!(0, node_fs.existsSync)(native) || !(0, node_fs.existsSync)(web)) return null;
9105
+ const pkg = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(packageDir, "package.json"), "utf8"));
9106
+ return `${typeof pkg === "object" && pkg !== null && "version" in pkg && typeof pkg.version === "string" ? pkg.version : "0"}+${(0, node_crypto.createHash)("sha256").update((0, node_fs.readFileSync)(native)).update((0, node_fs.readFileSync)(web)).digest("hex").slice(0, 12)}`;
9107
+ }
9108
+ //#endregion
9081
9109
  //#region src/app-source.ts
9082
9110
  var APP_ID = "media";
9083
9111
  function buildApp() {
@@ -9102,6 +9130,38 @@ function buildApp() {
9102
9130
  settings: null
9103
9131
  };
9104
9132
  }
9133
+ var PLUGIN_APP_ID = "media-plugin";
9134
+ /** The host API the plugin bundle is built against (`hostApi` of its `index.tsx`). */
9135
+ var PLUGIN_HOST_API = 1;
9136
+ /**
9137
+ * The React Native plugin spike (planning#908), declared next to the native Media app and
9138
+ * admin-only until phase 2 replaces it. `version` is the build's cache key (`readPluginVersion`).
9139
+ */
9140
+ function buildPluginApp(version) {
9141
+ return {
9142
+ id: PLUGIN_APP_ID,
9143
+ label: {
9144
+ key: "media-library:apps.mediaPlugin",
9145
+ fallback: "Media (plugin)"
9146
+ },
9147
+ icon: {
9148
+ kind: "image",
9149
+ asset: "assets/app-icon.svg"
9150
+ },
9151
+ entry: {
9152
+ kind: "rn-plugin",
9153
+ native: PLUGIN_NATIVE_ASSET,
9154
+ web: PLUGIN_WEB_ASSET,
9155
+ hostApi: PLUGIN_HOST_API,
9156
+ version
9157
+ },
9158
+ reach: { kind: "hub" },
9159
+ adminOnly: true,
9160
+ nav: [],
9161
+ takesSharedSearch: false,
9162
+ settings: null
9163
+ };
9164
+ }
9105
9165
  //#endregion
9106
9166
  //#region src/arr-client.ts
9107
9167
  var ImageSchema$1 = object({
@@ -15314,7 +15374,10 @@ var MediaLibraryAddon = class extends BaseAddon {
15314
15374
  const settings = await this.readSettings();
15315
15375
  scans.schedule(settings.rescanMinutes);
15316
15376
  scans.start("boot");
15317
- const apps = { listApps: async () => [buildApp()] };
15377
+ const apps = { listApps: async () => {
15378
+ const pluginVersion = readPluginVersion((0, node_path.join)(__dirname, ".."));
15379
+ return pluginVersion === null ? [buildApp()] : [buildApp(), buildPluginApp(pluginVersion)];
15380
+ } };
15318
15381
  const addressRoles = { listAddressRoles: async () => buildAddressRoles() };
15319
15382
  logger.info("media-library initialized");
15320
15383
  return {
@@ -1,7 +1,7 @@
1
1
  import { mkdir, open, readFile, readdir, realpath, rename, stat, unlink, writeFile } from "node:fs/promises";
2
2
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
- import { createReadStream } from "node:fs";
4
3
  import { createHash } from "node:crypto";
4
+ import { createReadStream, existsSync, readFileSync } from "node:fs";
5
5
  import { execFile } from "node:child_process";
6
6
  import { lookup } from "node:dns/promises";
7
7
  import { isIP } from "node:net";
@@ -8686,6 +8686,17 @@ var AppEntrySchema = /* @__PURE__ */ discriminatedUnion("kind", [
8686
8686
  /* @__PURE__ */ object({
8687
8687
  kind: /* @__PURE__ */ literal("addon-page"),
8688
8688
  pageId: /* @__PURE__ */ string()
8689
+ }),
8690
+ /* @__PURE__ */ object({
8691
+ kind: /* @__PURE__ */ literal("rn-plugin"),
8692
+ /** Asset path of the bundle for iOS and Android, served at `/api/addon-assets/<addonId>/<path>`. */
8693
+ native: /* @__PURE__ */ string().min(1),
8694
+ /** Asset path of the bundle for the web viewer (same source; `react-native` maps to react-native-web). */
8695
+ web: /* @__PURE__ */ string().min(1),
8696
+ /** The host API the bundle was built against; the shell refuses a plugin newer than its own. */
8697
+ hostApi: /* @__PURE__ */ number().int().min(1),
8698
+ /** Cache key of the bundle on the device: a new value fetches it again. */
8699
+ version: /* @__PURE__ */ string().min(1)
8689
8700
  })
8690
8701
  ]);
8691
8702
  /**
@@ -9074,6 +9085,23 @@ function buildAddressRoles() {
9074
9085
  }];
9075
9086
  }
9076
9087
  //#endregion
9088
+ //#region src/rn-app/plugin-version.ts
9089
+ /** Where the build writes the plugin, relative to the package root; these paths are the `rn-plugin` entry's assets. */
9090
+ var PLUGIN_NATIVE_ASSET = "dist/rn-app/index.native.js";
9091
+ var PLUGIN_WEB_ASSET = "dist/rn-app/index.web.js";
9092
+ /**
9093
+ * The cache key of the built plugin: the package version plus a hash of both bundles, so a rebuild
9094
+ * of the same package version still reaches a device that cached the old one. `null` when the
9095
+ * bundles are not built (a dev checkout): the plugin app is then not declared.
9096
+ */
9097
+ function readPluginVersion(packageDir) {
9098
+ const native = join(packageDir, PLUGIN_NATIVE_ASSET);
9099
+ const web = join(packageDir, PLUGIN_WEB_ASSET);
9100
+ if (!existsSync(native) || !existsSync(web)) return null;
9101
+ const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
9102
+ return `${typeof pkg === "object" && pkg !== null && "version" in pkg && typeof pkg.version === "string" ? pkg.version : "0"}+${createHash("sha256").update(readFileSync(native)).update(readFileSync(web)).digest("hex").slice(0, 12)}`;
9103
+ }
9104
+ //#endregion
9077
9105
  //#region src/app-source.ts
9078
9106
  var APP_ID = "media";
9079
9107
  function buildApp() {
@@ -9098,6 +9126,38 @@ function buildApp() {
9098
9126
  settings: null
9099
9127
  };
9100
9128
  }
9129
+ var PLUGIN_APP_ID = "media-plugin";
9130
+ /** The host API the plugin bundle is built against (`hostApi` of its `index.tsx`). */
9131
+ var PLUGIN_HOST_API = 1;
9132
+ /**
9133
+ * The React Native plugin spike (planning#908), declared next to the native Media app and
9134
+ * admin-only until phase 2 replaces it. `version` is the build's cache key (`readPluginVersion`).
9135
+ */
9136
+ function buildPluginApp(version) {
9137
+ return {
9138
+ id: PLUGIN_APP_ID,
9139
+ label: {
9140
+ key: "media-library:apps.mediaPlugin",
9141
+ fallback: "Media (plugin)"
9142
+ },
9143
+ icon: {
9144
+ kind: "image",
9145
+ asset: "assets/app-icon.svg"
9146
+ },
9147
+ entry: {
9148
+ kind: "rn-plugin",
9149
+ native: PLUGIN_NATIVE_ASSET,
9150
+ web: PLUGIN_WEB_ASSET,
9151
+ hostApi: PLUGIN_HOST_API,
9152
+ version
9153
+ },
9154
+ reach: { kind: "hub" },
9155
+ adminOnly: true,
9156
+ nav: [],
9157
+ takesSharedSearch: false,
9158
+ settings: null
9159
+ };
9160
+ }
9101
9161
  //#endregion
9102
9162
  //#region src/arr-client.ts
9103
9163
  var ImageSchema$1 = object({
@@ -15310,7 +15370,10 @@ var MediaLibraryAddon = class extends BaseAddon {
15310
15370
  const settings = await this.readSettings();
15311
15371
  scans.schedule(settings.rescanMinutes);
15312
15372
  scans.start("boot");
15313
- const apps = { listApps: async () => [buildApp()] };
15373
+ const apps = { listApps: async () => {
15374
+ const pluginVersion = readPluginVersion(join(__dirname, ".."));
15375
+ return pluginVersion === null ? [buildApp()] : [buildApp(), buildPluginApp(pluginVersion)];
15376
+ } };
15314
15377
  const addressRoles = { listAddressRoles: async () => buildAddressRoles() };
15315
15378
  logger.info("media-library initialized");
15316
15379
  return {
@@ -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.9",
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.63"
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
  },