Compare commits

..

1 Commits

Author SHA1 Message Date
cce804d1c3 build: bump vitest from 2.1.8 to 2.1.9
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.1.8 to 2.1.9.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.9/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-04 17:40:06 +00:00
10 changed files with 765 additions and 577 deletions

1265
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
{
"name": "@tcgdex/sdk",
"version": "2.7.0",
"main": "./dist/tcgdex.js",
"module": "./dist/tcgdex.mjs",
"types": "./dist/tcgdex.d.ts",
"browser": "./dist/tcgdex.global.js",
"version": "2.6.0",
"main": "./dist/tcgdex.node.js",
"module": "./dist/tcgdex.node.mjs",
"types": "./dist/tcgdex.node.d.ts",
"browser": "./dist/tcgdex.browser.global.js",
"exports": {
".": {
"require": {
"types": "./dist/tcgdex.d.ts",
"default": "./dist/tcgdex.js"
"types": "./dist/tcgdex.node.d.ts",
"default": "./dist/tcgdex.node.js"
},
"import": {
"types": "./dist/tcgdex.d.mts",
"default": "./dist/tcgdex.mjs"
"types": "./dist/tcgdex.node.d.mts",
"default": "./dist/tcgdex.node.mjs"
}
}
},
@ -57,11 +57,12 @@
"dependencies": {
"@cachex/memory": "^1",
"@cachex/web-storage": "^1",
"@dzeio/object-util": "^1"
"@dzeio/object-util": "^1",
"isomorphic-unfetch": "^3"
},
"scripts": {
"prebuild": "node scripts/export-version-number.js",
"build": "rm -rf dist && tsup ./src/tcgdex.ts --format cjs,esm,iife --global-name TCGdex --sourcemap --dts --clean",
"build": "rm -rf dist && tsup ./src/tcgdex.node.ts --format cjs,esm --dts --clean && tsup ./src/tcgdex.browser.ts --format iife --global-name TCGdex --sourcemap",
"prepublishOnly": "npm run build",
"lint": "eslint",
"test": "vitest run --coverage"

13
src/interfaces.d.ts vendored
View File

@ -22,18 +22,9 @@ interface variants {
firstEdition?: boolean
}
interface booster {
id: string
name: string
logo?: string
artwork_front?: string
artwork_back?: string
}
export type SetList = Array<SetResume>
export type SerieList = Array<SerieResume>
export type CardList = Array<CardResume>
export type BoosterList = Array<booster>
export interface SetResume {
id: string
@ -114,8 +105,6 @@ export interface Set extends SetResume {
}
cards: CardList
boosters?: BoosterList
}
export interface CardResume {
@ -313,8 +302,6 @@ export interface Card<SetType extends SetResume = SetResume> extends CardResume
*/
expanded: boolean
}
boosters?: BoosterList
}
export type StringEndpointList = Array<string>

View File

@ -1,5 +1,5 @@
import CardResume from './CardResume'
import type { Booster, Variants } from './Other'
import type { Variants } from './Other'
import type TCGdexSet from './Set'
import type SetResume from './SetResume'
@ -188,8 +188,6 @@ export default class Card extends CardResume {
expanded: boolean
}
public boosters?: Array<Booster>
public override async getCard(): Promise<Card> {
return this
}

View File

@ -4,12 +4,3 @@ export interface Variants {
holo?: boolean
firstEdition?: boolean
}
export interface Booster {
id: string
name: string
logo?: string
artwork_front?: string
artwork_back?: string
}

View File

@ -1,7 +1,7 @@
import { objectLoop } from '@dzeio/object-util'
import CardResume from './CardResume'
import Model from './Model'
import type { Booster, Variants } from './Other'
import type { Variants } from './Other'
import type SerieResume from './SerieResume'
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
@ -70,8 +70,6 @@ export default class Set extends Model {
public cards!: Array<CardResume>
public boosters?: Array<Booster>
public async getSerie() {
return this.sdk.serie.get(this.serie.id)
}

5
src/tcgdex.browser.ts Normal file
View File

@ -0,0 +1,5 @@
import TCGdex from './tcgdex'
TCGdex.fetch = window.fetch
export default TCGdex

7
src/tcgdex.node.ts Normal file
View File

@ -0,0 +1,7 @@
import TCGdex from './tcgdex'
import fetch from 'isomorphic-unfetch'
TCGdex.fetch = fetch as any
export default TCGdex
export * from './tcgdex'

View File

@ -31,11 +31,7 @@ export default class TCGdex {
/**
* How the remote data is going to be fetched
*/
public static fetch: typeof fetch =
detectContext() === 'browser'
// fixe: TypeError: 'fetch' called on an object that does not implement interface Window.
? (...params: Parameters<typeof fetch>) => window.fetch(...params)
: fetch
public static fetch: typeof fetch = fetch
/**
* @deprecated to change the lang use {@link TCGdex.getLang} and {@link TCGdex.setLang}
@ -46,9 +42,7 @@ export default class TCGdex {
* the previously hidden caching system used by TCGdex to not kill the API
*/
public cache: CacheInterface =
detectContext() === 'browser'
? new LocalStorageCache('tcgdex-cache')
: new MemoryCache()
detectContext() === 'browser' ? new LocalStorageCache('tcgdex-cache') : new MemoryCache()
/**
* the default cache TTL, only subsequent requests will have their ttl changed

View File

@ -1,7 +1,7 @@
import type { Endpoints } from './interfaces'
/**
* detect the current running context of the program
* detect the current running context ofthe program
*/
export function detectContext(): 'browser' | 'server' {
try {