From 7d71f3d2cd99b955e9676bb647b401d6354af073 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Wed, 10 May 2023 18:45:39 +0000 Subject: [PATCH] chore: v5.0.4 release --- deno/package.json | 4 ++-- deno/src/Innertube.ts | 2 +- deno/src/core/OAuth.ts | 2 +- deno/src/core/Player.ts | 2 +- deno/src/core/Session.ts | 6 +++--- deno/src/core/clients/Studio.ts | 2 +- deno/src/core/mixins/MediaInfo.ts | 2 +- deno/src/parser/classes/misc/Author.ts | 2 +- deno/src/parser/ytmusic/TrackInfo.ts | 2 +- deno/src/utils/Constants.ts | 8 -------- deno/src/utils/FormatUtils.ts | 2 +- deno/src/utils/HTTPClient.ts | 2 +- deno/src/utils/Utils.ts | 3 ++- 13 files changed, 16 insertions(+), 23 deletions(-) diff --git a/deno/package.json b/deno/package.json index 9fa4831b..a22d18e1 100644 --- a/deno/package.json +++ b/deno/package.json @@ -1,6 +1,6 @@ { "name": "youtubei.js", - "version": "5.0.3", + "version": "5.0.4", "description": "A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).", "type": "module", "types": "./dist/src/platform/lib.d.ts", @@ -73,7 +73,7 @@ "build:esm": "npx tsc", "build:deno": "npx cpy ./src ./deno && npx cpy ./package.json ./deno && npx replace \".ts';\" \".ts';\" ./deno -r && npx replace '.js\";' '.ts\";' ./deno -r && npx replace \"'https://esm.sh/linkedom';\" \"'https://esm.sh/linkedom';\" ./deno -r && npx replace \"'https://esm.sh/jintr';\" \"'https://esm.sh/jintr';\" ./deno -r && npx replace \"new Jinter\" \"new Jinter\" ./deno -r", "bundle:node": "npx esbuild ./dist/src/platform/node.js --bundle --target=node10 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:jintr --external:undici --external:linkedom --external:tslib --sourcemap --banner:js=\"/* eslint-disable */\"", - "bundle:browser": "npx esbuild ./dist/src/platform/web.js --banner:js=\"/* eslint-disable */\" --bundle --target=chrome58 --keep-names --format=esm --sourcemap --define:global=globalThis --outfile=./bundle/browser.js --platform=browser", + "bundle:browser": "npx esbuild ./dist/src/platform/web.js --banner:js=\"/* eslint-disable */\" --bundle --target=chrome58 --keep-names --format=esm --sourcemap --define:global=globalThis --conditions=module --outfile=./bundle/browser.js --platform=browser", "bundle:browser:prod": "npm run bundle:browser -- --outfile=./bundle/browser.min.js --minify", "prepare": "npm run build", "watch": "npx tsc --watch" diff --git a/deno/src/Innertube.ts b/deno/src/Innertube.ts index dde5b2fc..409ffc1a 100644 --- a/deno/src/Innertube.ts +++ b/deno/src/Innertube.ts @@ -20,7 +20,7 @@ import { AccountManager, InteractionManager, PlaylistManager } from './core/mana import { Feed, TabbedFeed } from './core/mixins/index.ts'; import Proto from './proto/index.ts'; -import Constants from './utils/Constants.ts'; +import * as Constants from './utils/Constants.ts'; import { InnertubeError, generateRandomString, throwIfMissing } from './utils/Utils.ts'; import { diff --git a/deno/src/core/OAuth.ts b/deno/src/core/OAuth.ts index 38e945e3..ea90d90a 100644 --- a/deno/src/core/OAuth.ts +++ b/deno/src/core/OAuth.ts @@ -1,4 +1,4 @@ -import Constants from '../utils/Constants.ts'; +import * as Constants from '../utils/Constants.ts'; import { OAuthError, Platform } from '../utils/Utils.ts'; import type Session from './Session.ts'; diff --git a/deno/src/core/Player.ts b/deno/src/core/Player.ts index d77cf1a6..7a4cfc8f 100644 --- a/deno/src/core/Player.ts +++ b/deno/src/core/Player.ts @@ -1,6 +1,6 @@ import { Platform, getRandomUserAgent, getStringBetweenStrings, PlayerError } from '../utils/Utils.ts'; -import Constants from '../utils/Constants.ts'; +import * as Constants from '../utils/Constants.ts'; import type { ICache } from '../types/Cache.ts'; import type { FetchFunction } from '../types/PlatformShim.ts'; diff --git a/deno/src/core/Session.ts b/deno/src/core/Session.ts index a56fd045..661b109d 100644 --- a/deno/src/core/Session.ts +++ b/deno/src/core/Session.ts @@ -1,4 +1,4 @@ -import Constants, { CLIENTS } from '../utils/Constants.ts'; +import * as Constants from '../utils/Constants.ts'; import EventEmitterLike from '../utils/EventEmitterLike.ts'; import Actions from './Actions.ts'; import Player from './Player.ts'; @@ -325,7 +325,7 @@ export default class Session extends EventEmitterLike { screenWidthPoints: 1920, visitorData: Proto.encodeVisitorData(visitor_id, Math.floor(Date.now() / 1000)), clientName: options.client_name, - clientVersion: CLIENTS.WEB.VERSION, + clientVersion: Constants.CLIENTS.WEB.VERSION, osName: 'Windows', osVersion: '10.0', platform: options.device_category.toUpperCase(), @@ -343,7 +343,7 @@ export default class Session extends EventEmitterLike { } }; - return { context, api_key: CLIENTS.WEB.API_KEY, api_version: CLIENTS.WEB.API_VERSION }; + return { context, api_key: Constants.CLIENTS.WEB.API_KEY, api_version: Constants.CLIENTS.WEB.API_VERSION }; } async signIn(credentials?: Credentials): Promise { diff --git a/deno/src/core/clients/Studio.ts b/deno/src/core/clients/Studio.ts index 080054a7..9e496c9a 100644 --- a/deno/src/core/clients/Studio.ts +++ b/deno/src/core/clients/Studio.ts @@ -1,5 +1,5 @@ import Proto from '../../proto/index.ts'; -import { Constants } from '../../utils/index.ts'; +import * as Constants from '../../utils/Constants.ts'; import { InnertubeError, MissingParamError, Platform } from '../../utils/Utils.ts'; import type { UpdateVideoMetadataOptions, UploadedVideoMetadataOptions } from '../../types/Clients.ts'; diff --git a/deno/src/core/mixins/MediaInfo.ts b/deno/src/core/mixins/MediaInfo.ts index 58b83812..3edef240 100644 --- a/deno/src/core/mixins/MediaInfo.ts +++ b/deno/src/core/mixins/MediaInfo.ts @@ -1,6 +1,6 @@ import type { ApiResponse } from '../Actions.ts'; import type Actions from '../Actions.ts'; -import Constants from '../../utils/Constants.ts'; +import * as Constants from '../../utils/Constants.ts'; import type { DownloadOptions, FormatFilter, FormatOptions, URLTransformer } from '../../utils/FormatUtils.ts'; import FormatUtils from '../../utils/FormatUtils.ts'; import { InnertubeError } from '../../utils/Utils.ts'; diff --git a/deno/src/parser/classes/misc/Author.ts b/deno/src/parser/classes/misc/Author.ts index 860357b0..f134d0d7 100644 --- a/deno/src/parser/classes/misc/Author.ts +++ b/deno/src/parser/classes/misc/Author.ts @@ -1,4 +1,4 @@ -import Constants from '../../../utils/Constants.ts'; +import * as Constants from '../../../utils/Constants.ts'; import type { YTNode} from '../../helpers.ts'; import { observe, type ObservedArray } from '../../helpers.ts'; import Parser, { type RawNode } from '../../index.ts'; diff --git a/deno/src/parser/ytmusic/TrackInfo.ts b/deno/src/parser/ytmusic/TrackInfo.ts index e53f50a5..242383b1 100644 --- a/deno/src/parser/ytmusic/TrackInfo.ts +++ b/deno/src/parser/ytmusic/TrackInfo.ts @@ -1,7 +1,7 @@ import type Actions from '../../core/Actions.ts'; import type { ApiResponse } from '../../core/Actions.ts'; -import Constants from '../../utils/Constants.ts'; +import * as Constants from '../../utils/Constants.ts'; import { InnertubeError } from '../../utils/Utils.ts'; import AutomixPreviewVideo from '../classes/AutomixPreviewVideo.ts'; diff --git a/deno/src/utils/Constants.ts b/deno/src/utils/Constants.ts index cac3924f..21ec752b 100644 --- a/deno/src/utils/Constants.ts +++ b/deno/src/utils/Constants.ts @@ -78,11 +78,3 @@ export const INNERTUBE_HEADERS_BASE = Object.freeze({ 'accept-encoding': 'gzip, deflate', 'content-type': 'application/json' }); - -export default { - URLS, - OAUTH, - CLIENTS, - STREAM_HEADERS, - INNERTUBE_HEADERS_BASE -}; \ No newline at end of file diff --git a/deno/src/utils/FormatUtils.ts b/deno/src/utils/FormatUtils.ts index f30cfc4a..a0ec6ad6 100644 --- a/deno/src/utils/FormatUtils.ts +++ b/deno/src/utils/FormatUtils.ts @@ -5,7 +5,7 @@ import type Format from '../parser/classes/misc/Format.ts'; import type AudioOnlyPlayability from '../parser/classes/AudioOnlyPlayability.ts'; import type { YTNode } from '../parser/helpers.ts'; -import { Constants } from './index.ts'; +import * as Constants from './Constants.ts'; import { getStringBetweenStrings, InnertubeError, Platform, streamToIterable } from './Utils.ts'; export type URLTransformer = (url: URL) => URL; diff --git a/deno/src/utils/HTTPClient.ts b/deno/src/utils/HTTPClient.ts index 3cacec64..2636893f 100644 --- a/deno/src/utils/HTTPClient.ts +++ b/deno/src/utils/HTTPClient.ts @@ -1,7 +1,7 @@ import type { Context } from '../core/Session.ts'; import type Session from '../core/Session.ts'; import type { FetchFunction } from '../types/PlatformShim.ts'; -import Constants from './Constants.ts'; +import * as Constants from './Constants.ts'; import { Platform, generateSidAuth, diff --git a/deno/src/utils/Utils.ts b/deno/src/utils/Utils.ts index c1d20d9b..a14a543e 100644 --- a/deno/src/utils/Utils.ts +++ b/deno/src/utils/Utils.ts @@ -1,5 +1,6 @@ import { Memo } from '../parser/helpers.ts'; import type { EmojiRun, TextRun } from '../parser/misc.ts'; +import { Text } from '../parser/misc.ts'; import type { FetchFunction } from '../types/PlatformShim.ts'; import type PlatformShim from '../types/PlatformShim.ts'; import userAgents from './user-agents.ts'; @@ -47,7 +48,7 @@ export class ChannelError extends Error { } export function deepCompare(obj1: any, obj2: any): boolean { const keys = Reflect.ownKeys(obj1); return keys.some((key) => { - const is_text = obj2[key]?.constructor.name === 'Text'; + const is_text = obj2[key] instanceof Text; if (!is_text && typeof obj2[key] === 'object') { return JSON.stringify(obj1[key]) === JSON.stringify(obj2[key]); }