Compare commits

...

5 Commits

Author SHA1 Message Date
github-actions[bot]
beb4733e84 chore(main): release 5.0.4 (#399)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-10 15:35:11 -03:00
absidue
66b026bf49 fix(Utils): Circular dependency introduced in 38a83c3c2a (#400) 2023-05-10 15:32:00 -03:00
absidue
26734194ab fix(bundles): Use ESM tslib build for the browser bundles (#397) 2023-05-06 15:54:18 -03:00
absidue
38a83c3c2a fix(Utils): Use instanceof in deepCompare instead of the constructor name (#398) 2023-05-06 15:47:51 -03:00
absidue
b1f19f16ac refactor(constants): Use namespace import internally (#396) 2023-05-06 15:46:20 -03:00
15 changed files with 27 additions and 25 deletions

View File

@@ -1,5 +1,14 @@
# Changelog
## [5.0.4](https://github.com/LuanRT/YouTube.js/compare/v5.0.3...v5.0.4) (2023-05-10)
### Bug Fixes
* **bundles:** Use ESM tslib build for the browser bundles ([#397](https://github.com/LuanRT/YouTube.js/issues/397)) ([2673419](https://github.com/LuanRT/YouTube.js/commit/26734194ab0bc5a9f57e1c509d7646ce8903d0c6))
* **Utils:** Circular dependency introduced in 38a83c3c2aa814150d1d9b8ed99fca915c1d67fe ([#400](https://github.com/LuanRT/YouTube.js/issues/400)) ([66b026b](https://github.com/LuanRT/YouTube.js/commit/66b026bf493d71a39e12825938fe54dc63aefd16))
* **Utils:** Use instanceof in deepCompare instead of the constructor name ([#398](https://github.com/LuanRT/YouTube.js/issues/398)) ([38a83c3](https://github.com/LuanRT/YouTube.js/commit/38a83c3c2aa814150d1d9b8ed99fca915c1d67fe))
## [5.0.3](https://github.com/LuanRT/YouTube.js/compare/v5.0.2...v5.0.3) (2023-05-03)

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "youtubei.js",
"version": "5.0.3",
"version": "5.0.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "youtubei.js",
"version": "5.0.3",
"version": "5.0.4",
"funding": [
"https://github.com/sponsors/LuanRT"
],

View File

@@ -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 \".js';\" \".ts';\" ./deno -r && npx replace '.js\";' '.ts\";' ./deno -r && npx replace \"'linkedom';\" \"'https://esm.sh/linkedom';\" ./deno -r && npx replace \"'jintr';\" \"'https://esm.sh/jintr';\" ./deno -r && npx replace \"new Jinter.default\" \"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"

View File

@@ -20,7 +20,7 @@ import { AccountManager, InteractionManager, PlaylistManager } from './core/mana
import { Feed, TabbedFeed } from './core/mixins/index.js';
import Proto from './proto/index.js';
import Constants from './utils/Constants.js';
import * as Constants from './utils/Constants.js';
import { InnertubeError, generateRandomString, throwIfMissing } from './utils/Utils.js';
import {

View File

@@ -1,4 +1,4 @@
import Constants from '../utils/Constants.js';
import * as Constants from '../utils/Constants.js';
import { OAuthError, Platform } from '../utils/Utils.js';
import type Session from './Session.js';

View File

@@ -1,6 +1,6 @@
import { Platform, getRandomUserAgent, getStringBetweenStrings, PlayerError } from '../utils/Utils.js';
import Constants from '../utils/Constants.js';
import * as Constants from '../utils/Constants.js';
import type { ICache } from '../types/Cache.js';
import type { FetchFunction } from '../types/PlatformShim.js';

View File

@@ -1,4 +1,4 @@
import Constants, { CLIENTS } from '../utils/Constants.js';
import * as Constants from '../utils/Constants.js';
import EventEmitterLike from '../utils/EventEmitterLike.js';
import Actions from './Actions.js';
import Player from './Player.js';
@@ -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<void> {

View File

@@ -1,5 +1,5 @@
import Proto from '../../proto/index.js';
import { Constants } from '../../utils/index.js';
import * as Constants from '../../utils/Constants.js';
import { InnertubeError, MissingParamError, Platform } from '../../utils/Utils.js';
import type { UpdateVideoMetadataOptions, UploadedVideoMetadataOptions } from '../../types/Clients.js';

View File

@@ -1,6 +1,6 @@
import type { ApiResponse } from '../Actions.js';
import type Actions from '../Actions.js';
import Constants from '../../utils/Constants.js';
import * as Constants from '../../utils/Constants.js';
import type { DownloadOptions, FormatFilter, FormatOptions, URLTransformer } from '../../utils/FormatUtils.js';
import FormatUtils from '../../utils/FormatUtils.js';
import { InnertubeError } from '../../utils/Utils.js';

View File

@@ -1,4 +1,4 @@
import Constants from '../../../utils/Constants.js';
import * as Constants from '../../../utils/Constants.js';
import type { YTNode} from '../../helpers.js';
import { observe, type ObservedArray } from '../../helpers.js';
import Parser, { type RawNode } from '../../index.js';

View File

@@ -1,7 +1,7 @@
import type Actions from '../../core/Actions.js';
import type { ApiResponse } from '../../core/Actions.js';
import Constants from '../../utils/Constants.js';
import * as Constants from '../../utils/Constants.js';
import { InnertubeError } from '../../utils/Utils.js';
import AutomixPreviewVideo from '../classes/AutomixPreviewVideo.js';

View File

@@ -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
};

View File

@@ -5,7 +5,7 @@ import type Format from '../parser/classes/misc/Format.js';
import type AudioOnlyPlayability from '../parser/classes/AudioOnlyPlayability.js';
import type { YTNode } from '../parser/helpers.js';
import { Constants } from './index.js';
import * as Constants from './Constants.js';
import { getStringBetweenStrings, InnertubeError, Platform, streamToIterable } from './Utils.js';
export type URLTransformer = (url: URL) => URL;

View File

@@ -1,7 +1,7 @@
import type { Context } from '../core/Session.js';
import type Session from '../core/Session.js';
import type { FetchFunction } from '../types/PlatformShim.js';
import Constants from './Constants.js';
import * as Constants from './Constants.js';
import {
Platform,
generateSidAuth,

View File

@@ -1,5 +1,6 @@
import { Memo } from '../parser/helpers.js';
import type { EmojiRun, TextRun } from '../parser/misc.js';
import { Text } from '../parser/misc.js';
import type { FetchFunction } from '../types/PlatformShim.js';
import type PlatformShim from '../types/PlatformShim.js';
import userAgents from './user-agents.js';
@@ -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]);
}