pluginManager.ts (33d529550b6205d83b1bee02bb839fb71b46cd36) pluginManager.ts (ab012f7f9483042c2f0de470231e96a189319868)
1import RNFS, {
2 copyFile,
3 exists,
4 readDir,
5 readFile,
6 stat,
7 unlink,
8 writeFile,

--- 35 unchanged lines hidden (view full) ---

44import {useEffect, useState} from 'react';
45import {addFileScheme, getFileName} from '@/utils/fileUtils';
46import {URL} from 'react-native-url-polyfill';
47import Base64 from '@/utils/base64';
48import MediaCache from './mediaCache';
49import {produce} from 'immer';
50import objectPath from 'object-path';
51import notImplementedFunction from '@/utils/notImplementedFunction.ts';
1import RNFS, {
2 copyFile,
3 exists,
4 readDir,
5 readFile,
6 stat,
7 unlink,
8 writeFile,

--- 35 unchanged lines hidden (view full) ---

44import {useEffect, useState} from 'react';
45import {addFileScheme, getFileName} from '@/utils/fileUtils';
46import {URL} from 'react-native-url-polyfill';
47import Base64 from '@/utils/base64';
48import MediaCache from './mediaCache';
49import {produce} from 'immer';
50import objectPath from 'object-path';
51import notImplementedFunction from '@/utils/notImplementedFunction.ts';
52import deviceInfoModule from "react-native-device-info";
52
53axios.defaults.timeout = 2000;
54
55const sha256 = CryptoJs.SHA256;
56
57export enum PluginStateCode {
58 /** 版本不匹配 */
59 VersionNotMatch = 'VERSION NOT MATCH',

--- 38 unchanged lines hidden (view full) ---

98
99const _console = {
100 log: _consoleBind.bind(null, 'log'),
101 warn: _consoleBind.bind(null, 'warn'),
102 info: _consoleBind.bind(null, 'info'),
103 error: _consoleBind.bind(null, 'error'),
104};
105
53
54axios.defaults.timeout = 2000;
55
56const sha256 = CryptoJs.SHA256;
57
58export enum PluginStateCode {
59 /** 版本不匹配 */
60 VersionNotMatch = 'VERSION NOT MATCH',

--- 38 unchanged lines hidden (view full) ---

99
100const _console = {
101 log: _consoleBind.bind(null, 'log'),
102 warn: _consoleBind.bind(null, 'warn'),
103 info: _consoleBind.bind(null, 'info'),
104 error: _consoleBind.bind(null, 'error'),
105};
106
107const appVersion = deviceInfoModule.getVersion();
108
106function formatAuthUrl(url: string) {
107 const urlObj = new URL(url);
108
109 try {
110 if (urlObj.username && urlObj.password) {
111 const auth = `Basic ${Base64.btoa(
112 `${decodeURIComponent(urlObj.username)}:${decodeURIComponent(
113 urlObj.password,

--- 45 unchanged lines hidden (view full) ---

159 if (typeof funcCode === 'string') {
160 // 插件的环境变量
161 const env = {
162 getUserVariables: () => {
163 return (
164 PluginMeta.getPluginMeta(this)?.userVariables ?? {}
165 );
166 },
109function formatAuthUrl(url: string) {
110 const urlObj = new URL(url);
111
112 try {
113 if (urlObj.username && urlObj.password) {
114 const auth = `Basic ${Base64.btoa(
115 `${decodeURIComponent(urlObj.username)}:${decodeURIComponent(
116 urlObj.password,

--- 45 unchanged lines hidden (view full) ---

162 if (typeof funcCode === 'string') {
163 // 插件的环境变量
164 const env = {
165 getUserVariables: () => {
166 return (
167 PluginMeta.getPluginMeta(this)?.userVariables ?? {}
168 );
169 },
170 appVersion,
167 os: 'android',
171 os: 'android',
172 lang: 'zh-CN'
168 };
173 };
174 const _process = {
175 platform: 'android',
176 version: appVersion,
177 env,
178 }
169
170 // eslint-disable-next-line no-new-func
171 _instance = Function(`
172 'use strict';
179
180 // eslint-disable-next-line no-new-func
181 _instance = Function(`
182 'use strict';
173 return function(require, __musicfree_require, module, exports, console, env, URL) {
183 return function(require, __musicfree_require, module, exports, console, env, URL, process) {
174 ${funcCode}
175 }
176 `)()(
177 _require,
178 _require,
179 _module,
180 _module.exports,
181 _console,
182 env,
183 URL,
184 ${funcCode}
185 }
186 `)()(
187 _require,
188 _require,
189 _module,
190 _module.exports,
191 _console,
192 env,
193 URL,
194 _process
184 );
185 if (_module.exports.default) {
186 _instance = _module.exports
187 .default as IPlugin.IPluginInstance;
188 } else {
189 _instance = _module.exports as IPlugin.IPluginInstance;
190 }
191 } else {

--- 1280 unchanged lines hidden ---
195 );
196 if (_module.exports.default) {
197 _instance = _module.exports
198 .default as IPlugin.IPluginInstance;
199 } else {
200 _instance = _module.exports as IPlugin.IPluginInstance;
201 }
202 } else {

--- 1280 unchanged lines hidden ---