@react-native-video/drm 7.0.0-alpha.9

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.
Files changed (50) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +95 -0
  3. package/ReactNativeVideoDrm.podspec +31 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +135 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/twg/videodrm/DRMManager/DRMManager.kt +107 -0
  10. package/android/src/main/java/com/twg/videodrm/DRMPlugin.kt +12 -0
  11. package/android/src/main/java/com/twg/videodrm/PluginManager.kt +53 -0
  12. package/android/src/main/java/com/twg/videodrm/VideoDrmPackage.kt +22 -0
  13. package/ios/DRMManager/DRMManager+AVContentKeySessionDelegate.swift +63 -0
  14. package/ios/DRMManager/DRMManager.swift +229 -0
  15. package/ios/DRMPlugin.swift +21 -0
  16. package/ios/PluginManager.swift +72 -0
  17. package/lib/module/PluginManager.nitro.js +4 -0
  18. package/lib/module/PluginManager.nitro.js.map +1 -0
  19. package/lib/module/index.js +12 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/package.json +1 -0
  22. package/lib/typescript/package.json +1 -0
  23. package/lib/typescript/src/PluginManager.nitro.d.ts +10 -0
  24. package/lib/typescript/src/PluginManager.nitro.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +4 -0
  26. package/lib/typescript/src/index.d.ts.map +1 -0
  27. package/nitro.json +17 -0
  28. package/nitrogen/generated/android/ReactNativeVideoDrm+autolinking.cmake +81 -0
  29. package/nitrogen/generated/android/ReactNativeVideoDrm+autolinking.gradle +27 -0
  30. package/nitrogen/generated/android/ReactNativeVideoDrmOnLoad.cpp +44 -0
  31. package/nitrogen/generated/android/ReactNativeVideoDrmOnLoad.hpp +25 -0
  32. package/nitrogen/generated/android/c++/JHybridPluginManagerSpec.cpp +53 -0
  33. package/nitrogen/generated/android/c++/JHybridPluginManagerSpec.hpp +65 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/videodrm/HybridPluginManagerSpec.kt +58 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/videodrm/ReactNativeVideoDrmOnLoad.kt +35 -0
  36. package/nitrogen/generated/ios/ReactNativeVideoDrm+autolinking.rb +60 -0
  37. package/nitrogen/generated/ios/ReactNativeVideoDrm-Swift-Cxx-Bridge.cpp +32 -0
  38. package/nitrogen/generated/ios/ReactNativeVideoDrm-Swift-Cxx-Bridge.hpp +51 -0
  39. package/nitrogen/generated/ios/ReactNativeVideoDrm-Swift-Cxx-Umbrella.hpp +43 -0
  40. package/nitrogen/generated/ios/ReactNativeVideoDrmAutolinking.mm +33 -0
  41. package/nitrogen/generated/ios/ReactNativeVideoDrmAutolinking.swift +25 -0
  42. package/nitrogen/generated/ios/c++/HybridPluginManagerSpecSwift.cpp +11 -0
  43. package/nitrogen/generated/ios/c++/HybridPluginManagerSpecSwift.hpp +79 -0
  44. package/nitrogen/generated/ios/swift/HybridPluginManagerSpec.swift +50 -0
  45. package/nitrogen/generated/ios/swift/HybridPluginManagerSpec_cxx.swift +138 -0
  46. package/nitrogen/generated/shared/c++/HybridPluginManagerSpec.cpp +23 -0
  47. package/nitrogen/generated/shared/c++/HybridPluginManagerSpec.hpp +63 -0
  48. package/package.json +135 -0
  49. package/src/PluginManager.nitro.ts +8 -0
  50. package/src/index.tsx +15 -0
@@ -0,0 +1,138 @@
1
+ ///
2
+ /// HybridPluginManagerSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridPluginManagerSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridPluginManagerSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::videodrm::bridge::swift`)
23
+ * from `ReactNativeVideoDrm-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.videodrm.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridPluginManagerSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridPluginManagerSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridPluginManagerSpec_
37
+
38
+ /**
39
+ * Create a new `HybridPluginManagerSpec_cxx` that wraps the given `HybridPluginManagerSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridPluginManagerSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridPluginManagerSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridPluginManagerSpec() -> any HybridPluginManagerSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridPluginManagerSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridPluginManagerSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridPluginManagerSpec_cxx {
70
+ return Unmanaged<HybridPluginManagerSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridPluginManagerSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridPluginManagerSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if cachedCxxPart.__convertToBool() {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridPluginManagerSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridPluginManagerSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ // Properties
109
+ public final var isEnabled: Bool {
110
+ @inline(__always)
111
+ get {
112
+ return self.__implementation.isEnabled
113
+ }
114
+ }
115
+
116
+ // Methods
117
+ @inline(__always)
118
+ public final func enable() -> bridge.Result_void_ {
119
+ do {
120
+ try self.__implementation.enable()
121
+ return bridge.create_Result_void_()
122
+ } catch (let __error) {
123
+ let __exceptionPtr = __error.toCpp()
124
+ return bridge.create_Result_void_(__exceptionPtr)
125
+ }
126
+ }
127
+
128
+ @inline(__always)
129
+ public final func disable() -> bridge.Result_void_ {
130
+ do {
131
+ try self.__implementation.disable()
132
+ return bridge.create_Result_void_()
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_void_(__exceptionPtr)
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,23 @@
1
+ ///
2
+ /// HybridPluginManagerSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridPluginManagerSpec.hpp"
9
+
10
+ namespace margelo::nitro::videodrm {
11
+
12
+ void HybridPluginManagerSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("isEnabled", &HybridPluginManagerSpec::getIsEnabled);
18
+ prototype.registerHybridMethod("enable", &HybridPluginManagerSpec::enable);
19
+ prototype.registerHybridMethod("disable", &HybridPluginManagerSpec::disable);
20
+ });
21
+ }
22
+
23
+ } // namespace margelo::nitro::videodrm
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridPluginManagerSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+
19
+
20
+ namespace margelo::nitro::videodrm {
21
+
22
+ using namespace margelo::nitro;
23
+
24
+ /**
25
+ * An abstract base class for `PluginManager`
26
+ * Inherit this class to create instances of `HybridPluginManagerSpec` in C++.
27
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
28
+ * @example
29
+ * ```cpp
30
+ * class HybridPluginManager: public HybridPluginManagerSpec {
31
+ * public:
32
+ * HybridPluginManager(...): HybridObject(TAG) { ... }
33
+ * // ...
34
+ * };
35
+ * ```
36
+ */
37
+ class HybridPluginManagerSpec: public virtual HybridObject {
38
+ public:
39
+ // Constructor
40
+ explicit HybridPluginManagerSpec(): HybridObject(TAG) { }
41
+
42
+ // Destructor
43
+ ~HybridPluginManagerSpec() override = default;
44
+
45
+ public:
46
+ // Properties
47
+ virtual bool getIsEnabled() = 0;
48
+
49
+ public:
50
+ // Methods
51
+ virtual void enable() = 0;
52
+ virtual void disable() = 0;
53
+
54
+ protected:
55
+ // Hybrid Setup
56
+ void loadHybridMethods() override;
57
+
58
+ protected:
59
+ // Tag for logging
60
+ static constexpr auto TAG = "PluginManager";
61
+ };
62
+
63
+ } // namespace margelo::nitro::videodrm
package/package.json ADDED
@@ -0,0 +1,135 @@
1
+ {
2
+ "name": "@react-native-video/drm",
3
+ "version": "7.0.0-alpha.9",
4
+ "description": "DRM plugin for react-native-video",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "nitrogen",
22
+ "nitro.json",
23
+ "*.podspec",
24
+ "react-native.config.js",
25
+ "!ios/build",
26
+ "!android/build",
27
+ "!android/gradle",
28
+ "!android/gradlew",
29
+ "!android/gradlew.bat",
30
+ "!android/local.properties",
31
+ "!**/__tests__",
32
+ "!**/__fixtures__",
33
+ "!**/__mocks__",
34
+ "!**/.*"
35
+ ],
36
+ "scripts": {
37
+ "test": "jest",
38
+ "typecheck": "tsc",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
41
+ "prepare": "bun run build",
42
+ "build": "bob build",
43
+ "specs": "nitrogen",
44
+ "release": "release-it --preRelease alpha --npm.tag=next"
45
+ },
46
+ "keywords": [
47
+ "react-native",
48
+ "react-native-video",
49
+ "drm",
50
+ "ios",
51
+ "android"
52
+ ],
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/TheWidlarzGroup/react-native-video.git"
56
+ },
57
+ "author": "TheWidlarzGroup <hi@thewidlarzgroup.com> (https://github.com/TheWidlarzGroup)",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/TheWidlarzGroup/react-native-video/issues"
61
+ },
62
+ "homepage": "https://github.com/TheWidlarzGroup/react-native-video#readme",
63
+ "publishConfig": {
64
+ "registry": "https://registry.npmjs.org/",
65
+ "access": "public"
66
+ },
67
+ "devDependencies": {
68
+ "@react-native/babel-preset": "0.79.2",
69
+ "@release-it/conventional-changelog": "^9.0.2",
70
+ "@types/react": "^18.3.0",
71
+ "del-cli": "^5.1.0",
72
+ "eslint": "^8.51.0",
73
+ "eslint-config-prettier": "9.0.0",
74
+ "eslint-plugin-prettier": "^5.0.1",
75
+ "nitrogen": "^0.29.0",
76
+ "prettier": "^3.0.3",
77
+ "react": "18.3.1",
78
+ "react-native": "^0.77.0",
79
+ "react-native-builder-bob": "^0.40.13",
80
+ "react-native-nitro-modules": "^0.29.0",
81
+ "release-it": "^17.10.0",
82
+ "typescript": "^5.8.3",
83
+ "react-native-video": "*"
84
+ },
85
+ "peerDependencies": {
86
+ "react": "*",
87
+ "react-native": "*",
88
+ "react-native-video": ">=7.0.0-alpha.3",
89
+ "react-native-nitro-modules": ">=0.27.2"
90
+ },
91
+ "jest": {
92
+ "preset": "react-native",
93
+ "modulePathIgnorePatterns": [
94
+ "<rootDir>/example/node_modules",
95
+ "<rootDir>/lib/"
96
+ ]
97
+ },
98
+ "release-it": {
99
+ "git": false,
100
+ "npm": {
101
+ "publish": true,
102
+ "publishArgs": "--access public"
103
+ },
104
+ "github": {
105
+ "release": false
106
+ },
107
+ "hooks": {
108
+ "before:init": "bun typecheck && bun lint",
109
+ "after:bump": "bun run build && cp ../../LICENSE ./LICENSE"
110
+ }
111
+ },
112
+ "react-native-builder-bob": {
113
+ "source": "src",
114
+ "output": "lib",
115
+ "targets": [
116
+ [
117
+ "module",
118
+ {
119
+ "esm": true
120
+ }
121
+ ],
122
+ [
123
+ "typescript",
124
+ {
125
+ "project": "tsconfig.build.json"
126
+ }
127
+ ]
128
+ ]
129
+ },
130
+ "create-react-native-library": {
131
+ "languages": "kotlin-swift",
132
+ "type": "nitro-module",
133
+ "version": "0.52.0"
134
+ }
135
+ }
@@ -0,0 +1,8 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface PluginManager
4
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
5
+ enable(): void;
6
+ disable(): void;
7
+ readonly isEnabled: boolean;
8
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,15 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ import type { PluginManager as PluginManagerSpec } from './PluginManager.nitro';
3
+
4
+ const PluginManager =
5
+ NitroModules.createHybridObject<PluginManagerSpec>('PluginManager');
6
+
7
+ export function enable() {
8
+ return PluginManager.enable();
9
+ }
10
+
11
+ export function disable() {
12
+ return PluginManager.disable();
13
+ }
14
+
15
+ export const isEnabled: boolean = PluginManager.isEnabled;