diff --git a/build-bundled.js b/build-bundled.js index 31c917b..9f26a92 100644 --- a/build-bundled.js +++ b/build-bundled.js @@ -150,6 +150,44 @@ async function buildProvider(providerName) { return { providerName, modules: results }; } +async function buildUtilityFiles() { + const utilityFiles = ["getBaseUrl", "headers", "providerContext"]; + + for (const utilityName of utilityFiles) { + const utilityPath = path.join(providersDir, `${utilityName}.ts`); + + if (!fs.existsSync(utilityPath)) { + continue; + } + + try { + const result = await esbuild.build({ + entryPoints: [utilityPath], + bundle: true, + platform: "node", + format: "cjs", + target: "es2015", + write: false, + external: [], + minify: false, + keepNames: true, + treeShaking: true, + outfile: `${utilityName}.js`, + }); + + let code = result.outputFiles[0].text; + code = code.replace(/require\(['"]node:.*?['"]\)/g, "{}"); + + const outputPath = path.join(__dirname, "dist", `${utilityName}.js`); + fs.writeFileSync(outputPath, code); + + console.log(`✓ ${utilityName}.js (${(code.length / 1024).toFixed(1)}kb)`); + } catch (error) { + console.error(`✗ Error building ${utilityName}:`, error.message); + } + } +} + async function buildAll() { const startTime = Date.now(); console.log( @@ -163,6 +201,9 @@ async function buildAll() { } fs.mkdirSync(distDir, { recursive: true }); + // Build utility files first + await buildUtilityFiles(); + // Build all providers const results = await Promise.all(providerDirs.map(buildProvider)); diff --git a/dist/getBaseUrl.js b/dist/getBaseUrl.js new file mode 100644 index 0000000..d1a15d1 --- /dev/null +++ b/dist/getBaseUrl.js @@ -0,0 +1,67 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; + +// providers/getBaseUrl.ts +var getBaseUrl_exports = {}; +__export(getBaseUrl_exports, { + getBaseUrl: () => getBaseUrl +}); +module.exports = __toCommonJS(getBaseUrl_exports); +var expireTime = 60 * 60 * 1e3; +var getBaseUrl = /* @__PURE__ */ __name((providerValue) => __async(null, null, function* () { + try { + let baseUrl = ""; + const cacheKey = "CacheBaseUrl" + providerValue; + const timeKey = "baseUrlTime" + providerValue; + const baseUrlRes = yield fetch( + "https://himanshu8443.github.io/providers/modflix.json" + ); + const baseUrlData = yield baseUrlRes.json(); + baseUrl = baseUrlData[providerValue].url; + return baseUrl; + } catch (error) { + console.error(`Error fetching baseUrl: ${providerValue}`, error); + return ""; + } +}), "getBaseUrl"); +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + getBaseUrl +}); diff --git a/dist/headers.js b/dist/headers.js new file mode 100644 index 0000000..c027bbe --- /dev/null +++ b/dist/headers.js @@ -0,0 +1,37 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// providers/headers.ts +var headers_exports = {}; +__export(headers_exports, { + headers: () => headers +}); +module.exports = __toCommonJS(headers_exports); +var headers = { + "sec-ch-ua": '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + // 'Sec-Fetch-Site': 'none', + // 'Sec-Fetch-User': '?1', + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" +}; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + headers +});