mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-18 20:12:12 +00:00
refactor!: Drop support for CommonJS
This commit is contained in:
1
bundle/react-native.d.ts
vendored
Normal file
1
bundle/react-native.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from '../dist/src/platform/lib.js';
|
||||
@@ -1,10 +0,0 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
export default {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
transform: { '^.+\\.(ts|tsx)$': 'ts-jest' },
|
||||
testTimeout: 30000,
|
||||
moduleFileExtensions: [ 'ts', 'tsx', 'js' ],
|
||||
testMatch: [ '**/*.test.ts' ],
|
||||
setupFiles: []
|
||||
};
|
||||
5306
package-lock.json
generated
5306
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -31,7 +31,7 @@
|
||||
"deno": "./dist/src/platform/deno.js",
|
||||
"node": {
|
||||
"import": "./dist/src/platform/node.js",
|
||||
"require": "./bundle/node.cjs"
|
||||
"default": "./dist/src/platform/node.js"
|
||||
},
|
||||
"types": "./dist/src/platform/lib.d.ts",
|
||||
"browser": "./dist/src/platform/web.js",
|
||||
@@ -71,17 +71,16 @@
|
||||
"Absidue (https://github.com/absidue)"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest --verbose",
|
||||
"test": "vitest run --reporter verbose",
|
||||
"lint": "eslint ./src",
|
||||
"lint:fix": "eslint --fix ./src",
|
||||
"clean:source-maps": "rimraf ./bundle/browser.js.map ./bundle/node.cjs.map ./bundle/cf-worker.js.map ./bundle/react-native.js.map",
|
||||
"clean:build-output": "rimraf ./dist ./bundle/browser.js ./bundle/node.cjs ./bundle/cf-worker.js ./bundle/react-native.js ./deno",
|
||||
"build": "npm run clean:build-output && npm run clean:source-maps && npm run build:parser-map && npm run build:esm && npm run bundle:node && npm run bundle:browser && npm run bundle:cf-worker && npm run bundle:react-native",
|
||||
"clean:source-maps": "rimraf ./bundle/browser.js.map ./bundle/cf-worker.js.map ./bundle/react-native.js.map",
|
||||
"clean:build-output": "rimraf ./dist ./bundle/browser.js ./bundle/cf-worker.js ./bundle/react-native.js ./deno",
|
||||
"build": "npm run clean:build-output && npm run clean:source-maps && npm run build:parser-map && npm run build:esm && npm run bundle:browser && npm run bundle:cf-worker && npm run bundle:react-native",
|
||||
"build:esm": "tspc",
|
||||
"build:deno": "cpy ./src ./deno && cpy ./protos ./deno && esbuild ./src/utils/DashManifest.tsx --keep-names --format=esm --platform=neutral --target=es2020 --outfile=./deno/src/utils/DashManifest.js && cpy ./package.json ./deno && replace \".js';\" \".ts';\" ./deno -r && replace '.js\";' '.ts\";' ./deno -r && replace \"'./DashManifest.ts';\" \"'./DashManifest.js';\" ./deno -r && replace \"'jintr';\" \"'jsr:@luanrt/jintr';\" ./deno -r && replace \"@bufbuild/protobuf/wire\" \"https://esm.sh/@bufbuild/protobuf@2.0.0/wire\" ./deno -r",
|
||||
"build:proto": "rimraf ./protos/generated && node ./dev-scripts/generate-proto.mjs",
|
||||
"build:parser-map": "node ./dev-scripts/gen-parser-map.mjs",
|
||||
"bundle:node": "esbuild ./dist/src/platform/node.js --bundle --sourcemap --target=node20 --keep-names --format=cjs --platform=node --outfile=./bundle/node.cjs --external:undici --external:linkedom --external:tslib --banner:js=\"/* eslint-disable */\"",
|
||||
"bundle:browser": "esbuild ./dist/src/platform/web.js --banner:js=\"/* eslint-disable */\" --bundle --sourcemap --target=chrome70 --keep-names --format=esm --define:global=globalThis --conditions=module --outfile=./bundle/browser.js --platform=browser",
|
||||
"bundle:react-native": "esbuild ./dist/src/platform/react-native.js --bundle --sourcemap --target=es2020 --keep-names --format=esm --platform=neutral --define:global=globalThis --conditions=module --outfile=./bundle/react-native.js",
|
||||
"bundle:cf-worker": "esbuild ./dist/src/platform/cf-worker.js --banner:js=\"/* eslint-disable */\" --bundle --sourcemap --target=es2020 --keep-names --format=esm --define:global=globalThis --conditions=module --outfile=./bundle/cf-worker.js --platform=node",
|
||||
@@ -114,24 +113,22 @@
|
||||
"@eslint/js": "^9.9.0",
|
||||
"@types/estree": "^1.0.6",
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/jest": "^28.1.7",
|
||||
"@types/node": "^17.0.45",
|
||||
"@types/node": "^24.0.14",
|
||||
"cpy-cli": "^4.2.0",
|
||||
"esbuild": "^0.25.6",
|
||||
"eslint": "^9.9.0",
|
||||
"glob": "^8.0.3",
|
||||
"globals": "^15.9.0",
|
||||
"jest": "^29.7.0",
|
||||
"replace": "^1.2.2",
|
||||
"rimraf": "^6.0.1",
|
||||
"ts-jest": "^29.1.4",
|
||||
"ts-patch": "^3.0.2",
|
||||
"ts-proto": "^2.2.0",
|
||||
"ts-transformer-inline-file": "^0.2.0",
|
||||
"typedoc": "^0.26.7",
|
||||
"typedoc-plugin-markdown": "^4.2.7",
|
||||
"typescript": "^5.0.0",
|
||||
"typescript-eslint": "^8.2.0"
|
||||
"typescript-eslint": "^8.2.0",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/LuanRT/YouTube.js/issues"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Innertube, YT, YTMusic, YTNodes } from '../bundle/node.cjs';
|
||||
import { describe, it, expect, beforeAll, test } from 'vitest';
|
||||
|
||||
jest.useRealTimers();
|
||||
import { Innertube, YT, YTMusic, YTNodes } from '../dist/src/platform/node.js';
|
||||
|
||||
describe('YouTube.js Tests', () => {
|
||||
let innertube: Innertube;
|
||||
@@ -337,11 +337,10 @@ describe('YouTube.js Tests', () => {
|
||||
});
|
||||
|
||||
test('Innertube#music.getInfo.NavEndpoint.getUpNextContinuation', async () => {
|
||||
// Fetch some video from Homepage
|
||||
const home = await innertube.music.getHomeFeed()
|
||||
const homeItemFirst = home.sections!.first().as(YTNodes.MusicCarouselShelf).contents[0].as(YTNodes.MusicResponsiveListItem)
|
||||
const homeItemFirst = home.sections!.first().as(YTNodes.MusicCarouselShelf).contents.firstOfType(YTNodes.MusicResponsiveListItem)
|
||||
|
||||
const info = await innertube.music.getInfo(homeItemFirst.id ?? homeItemFirst.endpoint!)
|
||||
const info = await innertube.music.getInfo(homeItemFirst?.id ?? homeItemFirst?.endpoint!)
|
||||
expect(info).toBeDefined();
|
||||
|
||||
const upNext = await info.getUpNext();
|
||||
@@ -11,7 +11,7 @@
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
"jsx": "react", /* Specify what JSX code is generated. */
|
||||
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
||||
|
||||
Reference in New Issue
Block a user