bannerify-js 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/HTTPError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/errors/TimeoutError.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/is.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/merge.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/constants.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/normalize.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/timeout.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/delay.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/utils/options.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/core/Ky.ts","../node_modules/.pnpm/ky@1.1.3/node_modules/ky/source/index.ts","../package.json","../src/client.ts"],"sourcesContent":["export * from './client'\nexport { Modification } from './interface'\nexport { HTTPError, TimeoutError } from 'ky'","import type {NormalizedOptions} from '../types/options.js';\n\n// eslint-lint-disable-next-line @typescript-eslint/naming-convention\nexport class HTTPError extends Error {\n\tpublic response: Response;\n\tpublic request: Request;\n\tpublic options: NormalizedOptions;\n\n\tconstructor(response: Response, request: Request, options: NormalizedOptions) {\n\t\tconst code = (response.status || response.status === 0) ? response.status : '';\n\t\tconst title = response.statusText || '';\n\t\tconst status = `${code} ${title}`.trim();\n\t\tconst reason = status ? `status code ${status}` : 'an unknown error';\n\n\t\tsuper(`Request failed with ${reason}`);\n\n\t\tthis.name = 'HTTPError';\n\t\tthis.response = response;\n\t\tthis.request = request;\n\t\tthis.options = options;\n\t}\n}\n","export class TimeoutError extends Error {\n\tpublic request: Request;\n\n\tconstructor(request: Request) {\n\t\tsuper('Request timed out');\n\t\tthis.name = 'TimeoutError';\n\t\tthis.request = request;\n\t}\n}\n","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value: unknown): value is object => value !== null && typeof value === 'object';\n","import type {KyHeadersInit, Options} from '../types/options.js';\nimport {isObject} from './is.js';\n\nexport const validateAndMerge = (...sources: Array<Partial<Options> | undefined>): Partial<Options> => {\n\tfor (const source of sources) {\n\t\tif ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t}\n\t}\n\n\treturn deepMerge({}, ...sources);\n};\n\nexport const mergeHeaders = (source1: KyHeadersInit = {}, source2: KyHeadersInit = {}) => {\n\tconst result = new globalThis.Headers(source1 as HeadersInit);\n\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\tconst source = new globalThis.Headers(source2 as HeadersInit);\n\n\tfor (const [key, value] of source.entries()) {\n\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\tresult.delete(key);\n\t\t} else {\n\t\t\tresult.set(key, value);\n\t\t}\n\t}\n\n\treturn result;\n};\n\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => {\n\tlet returnValue: any = {};\n\tlet headers = {};\n\n\tfor (const source of sources) {\n\t\tif (Array.isArray(source)) {\n\t\t\tif (!Array.isArray(returnValue)) {\n\t\t\t\treturnValue = [];\n\t\t\t}\n\n\t\t\treturnValue = [...returnValue, ...source];\n\t\t} else if (isObject(source)) {\n\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\tif (isObject(value) && key in returnValue) {\n\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t}\n\n\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t}\n\n\t\t\tif (isObject((source as any).headers)) {\n\t\t\t\theaders = mergeHeaders(headers, (source as any).headers);\n\t\t\t\treturnValue.headers = headers;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnValue;\n};\n","import type {Expect, Equal} from '@type-challenges/utils';\nimport {type HttpMethod, type KyOptionsRegistry} from '../types/options.js';\nimport {type RequestInitRegistry} from '../types/request.js';\n\nexport const supportsRequestStreams = (() => {\n\tlet duplexAccessed = false;\n\tlet hasContentType = false;\n\tconst supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n\tconst supportsRequest = typeof globalThis.Request === 'function';\n\n\tif (supportsReadableStream && supportsRequest) {\n\t\thasContentType = new globalThis.Request('https://empty.invalid', {\n\t\t\tbody: new globalThis.ReadableStream(),\n\t\t\tmethod: 'POST',\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tget duplex() {\n\t\t\t\tduplexAccessed = true;\n\t\t\t\treturn 'half';\n\t\t\t},\n\t\t}).headers.has('Content-Type');\n\t}\n\n\treturn duplexAccessed && !hasContentType;\n})();\n\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\n\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;\n\nconst validate = <T extends Array<true>>() => undefined as unknown as T;\nvalidate<[\n\tExpect<Equal<typeof requestMethods[number], HttpMethod>>,\n]>();\n\nexport const responseTypes = {\n\tjson: 'application/json',\n\ttext: 'text/*',\n\tformData: 'multipart/form-data',\n\tarrayBuffer: '*/*',\n\tblob: '*/*',\n} as const;\n\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\n\nexport const stop = Symbol('stop');\n\nexport const kyOptionKeys: KyOptionsRegistry = {\n\tjson: true,\n\tparseJson: true,\n\tsearchParams: true,\n\tprefixUrl: true,\n\tretry: true,\n\ttimeout: true,\n\thooks: true,\n\tthrowHttpErrors: true,\n\tonDownloadProgress: true,\n\tfetch: true,\n};\n\nexport const requestOptionsRegistry: RequestInitRegistry = {\n\tmethod: true,\n\theaders: true,\n\tbody: true,\n\tmode: true,\n\tcredentials: true,\n\tcache: true,\n\tredirect: true,\n\treferrer: true,\n\treferrerPolicy: true,\n\tintegrity: true,\n\tkeepalive: true,\n\tsignal: true,\n\twindow: true,\n\tdispatcher: true,\n\tduplex: true,\n};\n","import {requestMethods} from '../core/constants.js';\nimport type {HttpMethod} from '../types/options.js';\nimport type {RetryOptions} from '../types/retry.js';\n\nexport const normalizeRequestMethod = (input: string): string =>\n\trequestMethods.includes(input as HttpMethod) ? input.toUpperCase() : input;\n\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n\nconst retryAfterStatusCodes = [413, 429, 503];\n\nconst defaultRetryOptions: Required<RetryOptions> = {\n\tlimit: 2,\n\tmethods: retryMethods,\n\tstatusCodes: retryStatusCodes,\n\tafterStatusCodes: retryAfterStatusCodes,\n\tmaxRetryAfter: Number.POSITIVE_INFINITY,\n\tbackoffLimit: Number.POSITIVE_INFINITY,\n\tdelay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\n\nexport const normalizeRetryOptions = (retry: number | RetryOptions = {}): Required<RetryOptions> => {\n\tif (typeof retry === 'number') {\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\tlimit: retry,\n\t\t};\n\t}\n\n\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\tthrow new Error('retry.methods must be an array');\n\t}\n\n\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\tthrow new Error('retry.statusCodes must be an array');\n\t}\n\n\treturn {\n\t\t...defaultRetryOptions,\n\t\t...retry,\n\t\tafterStatusCodes: retryAfterStatusCodes,\n\t};\n};\n","import {TimeoutError} from '../errors/TimeoutError.js';\n\nexport type TimeoutOptions = {\n\ttimeout: number;\n\tfetch: typeof fetch;\n};\n\n// `Promise.race()` workaround (#91)\nexport default async function timeout(\n\trequest: Request,\n\tinit: RequestInit,\n\tabortController: AbortController | undefined,\n\toptions: TimeoutOptions,\n): Promise<Response> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tif (abortController) {\n\t\t\t\tabortController.abort();\n\t\t\t}\n\n\t\t\treject(new TimeoutError(request));\n\t\t}, options.timeout);\n\n\t\tvoid options\n\t\t\t.fetch(request, init)\n\t\t\t.then(resolve)\n\t\t\t.catch(reject)\n\t\t\t.then(() => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t});\n\t});\n}\n","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n\nimport {type InternalOptions} from '../types/options.js';\n\nexport type DelayOptions = {\n\tsignal?: InternalOptions['signal'];\n};\n\nexport default async function delay(\n\tms: number,\n\t{signal}: DelayOptions,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal) {\n\t\t\tsignal.throwIfAborted();\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tfunction abortHandler() {\n\t\t\tclearTimeout(timeoutId);\n\t\t\treject(signal!.reason);\n\t\t}\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tsignal?.removeEventListener('abort', abortHandler);\n\t\t\tresolve();\n\t\t}, ms);\n\t});\n}\n","import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';\n\nexport const findUnknownOptions = (\n\trequest: Request,\n\toptions: Record<string, unknown>,\n): Record<string, unknown> => {\n\tconst unknownOptions: Record<string, unknown> = {};\n\n\tfor (const key in options) {\n\t\tif (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n\t\t\tunknownOptions[key] = options[key];\n\t\t}\n\t}\n\n\treturn unknownOptions;\n};\n","import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {type ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {type TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {type ObjectEntries} from '../utils/types.js';\nimport {findUnknownOptions} from '../utils/options.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise<Response> => {\n\t\t\tif (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries<typeof responseTypes>) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge<Required<Hooks>>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: options.timeout ?? 10_000,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record<string, string>)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryDelay = this._options.retry.delay(this._retryCount);\n\t\t\treturn Math.min(this._options.retry.backoffLimit, retryDelay);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry<T extends (...args: any) => Promise<any>>(fn: T): Promise<ReturnType<T> | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise<Response> {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tconst nonRequestOptions = findUnknownOptions(this.request, this._options);\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone(), nonRequestOptions);\n\t\t}\n\n\t\treturn timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n","/*! MIT License © Sindre Sorhus */\n\nimport {Ky} from './core/Ky.js';\nimport {requestMethods, stop} from './core/constants.js';\nimport type {KyInstance} from './types/ky.js';\nimport type {Input, Options} from './types/options.js';\nimport {validateAndMerge} from './utils/merge.js';\nimport {type Mutable} from './utils/types.js';\n\nconst createInstance = (defaults?: Partial<Options>): KyInstance => {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tconst ky: Partial<Mutable<KyInstance>> = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options));\n\n\tfor (const method of requestMethods) {\n\t\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\t\tky[method] = (input: Input, options?: Options) => Ky.create(input, validateAndMerge(defaults, options, {method}));\n\t}\n\n\tky.create = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(newDefaults));\n\tky.extend = (newDefaults?: Partial<Options>) => createInstance(validateAndMerge(defaults, newDefaults));\n\tky.stop = stop;\n\n\treturn ky as KyInstance;\n};\n\nconst ky = createInstance();\n\nexport default ky;\n\nexport type {KyInstance} from './types/ky.js';\n\nexport type {\n\tOptions,\n\tNormalizedOptions,\n\tRetryOptions,\n\tSearchParamsOption,\n\tDownloadProgress,\n} from './types/options.js';\n\nexport type {\n\tHooks,\n\tBeforeRequestHook,\n\tBeforeRetryHook,\n\tBeforeRetryState,\n\tBeforeErrorHook,\n\tAfterResponseHook,\n} from './types/hooks.js';\n\nexport type {ResponsePromise} from './types/ResponsePromise.js';\nexport type {KyResponse} from './types/response.js';\nexport {HTTPError} from './errors/HTTPError.js';\nexport {TimeoutError} from './errors/TimeoutError.js';\n","{\n \"name\": \"bannerify-node\",\n \"version\": \"0.0.7\",\n \"description\": \"\",\n \"type\": \"module\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"bun test\",\n \"play\": \"tsx playground/test.ts\",\n \"openapi\": \"openapi-typescript https://beta.bannerify.co/api/v1/openapi.json -o ./src/openapi.d.ts\",\n \"openapi-local\": \"openapi-typescript http://localhost:8788/api/v1/openapi.json -o ./src/openapi.d.ts\",\n \"build:watch\": \"tsup --watch\",\n \"build\": \"tsup\"\n },\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"keywords\": [],\n \"files\": [\n \"dist\"\n ],\n \"author\": \"Duc An <an@bannerify.co>\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@faker-js/faker\": \"^8.4.1\",\n \"@types/node\": \"18.15.3\",\n \"bun-types\": \"^1.0.20\",\n \"chart.js\": \"^4.4.1\",\n \"ky\": \"^1.1.3\",\n \"openapi-typescript\": \"^6.7.3\",\n \"tsup\": \"^8.0.1\",\n \"tsx\": \"^4.7.0\",\n \"typescript\": \"5.2.2\"\n }\n}\n","import ky from 'ky'\nimport { version } from '../package.json'\nimport { Modification } from './interface'\n\ninterface Options {\n apiKey: string\n fetch?: typeof fetch\n baseUrl?: string\n}\n\ntype CreateOptions = {\n modifications?: Modification[]\n container?: Modification\n // @default: png\n format?: 'svg' | 'png'\n // default 10s\n timeout?: number\n}\n\nexport function createClient(opts: Options) {\n return new Bannerify(opts)\n}\n\nexport class Bannerify {\n private readonly client: typeof ky\n\n private readonly baseUrl: string\n\n constructor(\n private readonly opts: Options\n ) {\n this.baseUrl = opts.baseUrl || 'https://beta.bannerify.co/api/v1'\n this.client = ky.create({\n fetch: opts.fetch || fetch,\n prefixUrl: this.baseUrl,\n headers: {\n Authorization: `Bearer ${opts.apiKey}`,\n 'X-SDK-Version': `${version}`,\n },\n })\n }\n\n async createImage(\n templateId: string,\n options?: CreateOptions,\n ) {\n const res = this.client.get('templates/createImage', {\n searchParams: {\n modifications: JSON.stringify(options?.modifications ?? []),\n container: JSON.stringify(options?.container ?? {}),\n templateId,\n apiKey: this.opts.apiKey,\n format: options?.format as string,\n },\n timeout: options?.timeout,\n })\n if (options?.format === 'svg') {\n return res.text()\n }\n return res.arrayBuffer()\n }\n\n async createPdf(\n templateId: string,\n options?: CreateOptions,\n ) {\n return this.client.get('templates/createPdf', {\n searchParams: {\n modifications: JSON.stringify(options?.modifications ?? []),\n templateId,\n apiKey: this.opts.apiKey,\n },\n timeout: options?.timeout,\n })\n .arrayBuffer()\n }\n\n async createPermanentImage() {\n throw new Error('Not yet implemented')\n }\n\n #hashText = async(text:string) => {\n const myText = new TextEncoder().encode('Hello world!');\n const myDigest = await crypto.subtle.digest({ name: 'SHA-256' }, myText);\n const hashArray = Array.from(new Uint8Array(myDigest));\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n return hashHex\n }\n\n async generateImageSignedUrl(\n templateId: string,\n options?: CreateOptions,\n ) {\n const apiKeyAsMd5 = await this.#hashText(this.opts.apiKey)\n const searchParams = new URLSearchParams()\n searchParams.set('apiKeyMd5', apiKeyAsMd5)\n if (options?.format === 'svg') {\n searchParams.set('format', 'svg')\n }\n if (options?.modifications) {\n searchParams.set('modifications', JSON.stringify(options?.modifications))\n }\n searchParams.set('templateId', templateId)\n searchParams.set('sign', await this.#hashText(searchParams.toString() + apiKeyAsMd5))\n return `${this.baseUrl}/templates/imageSignedUrl?${searchParams.toString()}`\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGM,IAAO,YAAP,cAAyB,MAAK;EAKnC,YAAY,UAAoB,SAAkB,SAA0B;AAC3E,UAAM,OAAQ,SAAS,UAAU,SAAS,WAAW,IAAK,SAAS,SAAS;AAC5E,UAAM,QAAQ,SAAS,cAAc;AACrC,UAAM,SAAS,GAAG,IAAI,IAAI,KAAK,GAAG,KAAI;AACtC,UAAM,SAAS,SAAS,eAAe,MAAM,KAAK;AAElD,UAAM,uBAAuB,MAAM,EAAE;AAV/B,WAAA,eAAA,MAAA,YAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AACA,WAAA,eAAA,MAAA,WAAA;;;;;;AAUN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,UAAU;EAChB;;;;ACpBK,IAAO,eAAP,cAA4B,MAAK;EAGtC,YAAY,SAAgB;AAC3B,UAAM,mBAAmB;AAHnB,WAAA,eAAA,MAAA,WAAA;;;;;;AAIN,SAAK,OAAO;AACZ,SAAK,UAAU;EAChB;;;;ACNM,IAAM,WAAW,CAAC,UAAoC,UAAU,QAAQ,OAAO,UAAU;;;ACEzF,IAAM,mBAAmB,IAAI,YAAkE;AACrG,aAAW,UAAU,SAAS;AAC7B,SAAK,CAAC,SAAS,MAAM,KAAK,MAAM,QAAQ,MAAM,MAAM,WAAW,QAAW;AACzE,YAAM,IAAI,UAAU,0CAA0C;;;AAIhE,SAAO,UAAU,CAAA,GAAI,GAAG,OAAO;AAChC;AAEO,IAAM,eAAe,CAAC,UAAyB,CAAA,GAAI,UAAyB,CAAA,MAAM;AACxF,QAAM,SAAS,IAAI,WAAW,QAAQ,OAAsB;AAC5D,QAAM,oB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M,UAAU,UAAU,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC3E,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,uBACJ,YACA,SACA;AACA,UAAM,cAAc,MAAM,KAAK,UAAU,KAAK,KAAK,MAAM;AACzD,UAAM,eAAe,IAAI,gBAAgB;AACzC,iBAAa,IAAI,aAAa,WAAW;AACzC,QAAI,SAAS,WAAW,OAAO;AAC7B,mBAAa,IAAI,UAAU,KAAK;AAAA,IAClC;AACA,QAAI,SAAS,eAAe;AAC1B,mBAAa,IAAI,iBAAiB,KAAK,UAAU,SAAS,aAAa,CAAC;AAAA,IAC1E;AACA,iBAAa,IAAI,cAAc,UAAU;AACzC,iBAAa,IAAI,QAAQ,MAAM,KAAK,UAAU,aAAa,SAAS,IAAI,WAAW,CAAC;AACpF,WAAO,GAAG,KAAK,OAAO,6BAA6B,aAAa,SAAS,CAAC;AAAA,EAC5E;AACF;","names":["ky","ky"]}
@@ -0,0 +1,95 @@
1
+ import { ChartData } from 'chart.js';
2
+ export { HTTPError, TimeoutError } from 'ky';
3
+
4
+ type Modification = {
5
+ name: string;
6
+ /**
7
+ * color
8
+ * @example #FF0000
9
+ * @default The default color of the layer
10
+ * @description The color for the modification, accept any valid CSS color value, for example: #FF0000, red, rgba(0,0,0,0.5), etc. You can only modify the color of the text layer with this field.
11
+ */
12
+ color?: string;
13
+ /**
14
+ * background color
15
+ * @example #FF0000
16
+ * @default The default background color of the layer
17
+ * @description The background color for the modification, accept any valid CSS color value, for example: #FF0000, red, rgba(0,0,0,0.5), etc.
18
+ */
19
+ background?: string;
20
+ /**
21
+ * font size
22
+ * @example 12
23
+ * @default The default font size of the layer
24
+ * @description The font size for the modification, accept any valid CSS font size value, for example: 12, 12px;
25
+ */
26
+ size?: number;
27
+ /**
28
+ * source image
29
+ * @example https://example.com/image.jpg
30
+ * @default The default source image of the layer
31
+ * @description The source image for the modification, accept any valid image URL, for example: https://example.com/image.jpg
32
+ */
33
+ src?: string;
34
+ /**
35
+ * chart data
36
+ * @example { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My First Dataset', data: [65, 59, 80, 81, 56, 55, 40], fill: false, borderColor: 'rgb(75, 192, 192)', tension: 0.1 }] }
37
+ * @default The default chart data of the layer
38
+ * @description Update chart layer's data, follow chart.js data structure
39
+ */
40
+ chart?: ChartData;
41
+ /**
42
+ * text content
43
+ * @example Hello World
44
+ * @default The default text content of the layer
45
+ * @description You can modify the text layer with this field
46
+ */
47
+ text?: string;
48
+ /**
49
+ * barcode content
50
+ * @example 1234567890
51
+ * @default The default barcode content of the layer
52
+ * @description Modify the barcode layer content with this field
53
+ */
54
+ qrcode?: string;
55
+ /**
56
+ * qrcode content
57
+ * @example Some text
58
+ * @default The default qrcode content of the layer
59
+ * @description Modify the qrcode layer content with this field
60
+ */
61
+ barcode?: string;
62
+ /**
63
+ * visibility
64
+ * @example true
65
+ * @default The default visibility of the layer
66
+ * @description Set the visibility of the field
67
+ */
68
+ visible?: boolean;
69
+ };
70
+
71
+ interface Options {
72
+ apiKey: string;
73
+ fetch?: typeof fetch;
74
+ baseUrl?: string;
75
+ }
76
+ type CreateOptions = {
77
+ modifications?: Modification[];
78
+ container?: Modification;
79
+ format?: 'svg' | 'png';
80
+ timeout?: number;
81
+ };
82
+ declare function createClient(opts: Options): Bannerify;
83
+ declare class Bannerify {
84
+ #private;
85
+ private readonly opts;
86
+ private readonly client;
87
+ private readonly baseUrl;
88
+ constructor(opts: Options);
89
+ createImage(templateId: string, options?: CreateOptions): Promise<string | ArrayBuffer>;
90
+ createPdf(templateId: string, options?: CreateOptions): Promise<ArrayBuffer>;
91
+ createPermanentImage(): Promise<void>;
92
+ generateImageSignedUrl(templateId: string, options?: CreateOptions): Promise<string>;
93
+ }
94
+
95
+ export { Bannerify, type Modification, createClient };
@@ -0,0 +1,95 @@
1
+ import { ChartData } from 'chart.js';
2
+ export { HTTPError, TimeoutError } from 'ky';
3
+
4
+ type Modification = {
5
+ name: string;
6
+ /**
7
+ * color
8
+ * @example #FF0000
9
+ * @default The default color of the layer
10
+ * @description The color for the modification, accept any valid CSS color value, for example: #FF0000, red, rgba(0,0,0,0.5), etc. You can only modify the color of the text layer with this field.
11
+ */
12
+ color?: string;
13
+ /**
14
+ * background color
15
+ * @example #FF0000
16
+ * @default The default background color of the layer
17
+ * @description The background color for the modification, accept any valid CSS color value, for example: #FF0000, red, rgba(0,0,0,0.5), etc.
18
+ */
19
+ background?: string;
20
+ /**
21
+ * font size
22
+ * @example 12
23
+ * @default The default font size of the layer
24
+ * @description The font size for the modification, accept any valid CSS font size value, for example: 12, 12px;
25
+ */
26
+ size?: number;
27
+ /**
28
+ * source image
29
+ * @example https://example.com/image.jpg
30
+ * @default The default source image of the layer
31
+ * @description The source image for the modification, accept any valid image URL, for example: https://example.com/image.jpg
32
+ */
33
+ src?: string;
34
+ /**
35
+ * chart data
36
+ * @example { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'My First Dataset', data: [65, 59, 80, 81, 56, 55, 40], fill: false, borderColor: 'rgb(75, 192, 192)', tension: 0.1 }] }
37
+ * @default The default chart data of the layer
38
+ * @description Update chart layer's data, follow chart.js data structure
39
+ */
40
+ chart?: ChartData;
41
+ /**
42
+ * text content
43
+ * @example Hello World
44
+ * @default The default text content of the layer
45
+ * @description You can modify the text layer with this field
46
+ */
47
+ text?: string;
48
+ /**
49
+ * barcode content
50
+ * @example 1234567890
51
+ * @default The default barcode content of the layer
52
+ * @description Modify the barcode layer content with this field
53
+ */
54
+ qrcode?: string;
55
+ /**
56
+ * qrcode content
57
+ * @example Some text
58
+ * @default The default qrcode content of the layer
59
+ * @description Modify the qrcode layer content with this field
60
+ */
61
+ barcode?: string;
62
+ /**
63
+ * visibility
64
+ * @example true
65
+ * @default The default visibility of the layer
66
+ * @description Set the visibility of the field
67
+ */
68
+ visible?: boolean;
69
+ };
70
+
71
+ interface Options {
72
+ apiKey: string;
73
+ fetch?: typeof fetch;
74
+ baseUrl?: string;
75
+ }
76
+ type CreateOptions = {
77
+ modifications?: Modification[];
78
+ container?: Modification;
79
+ format?: 'svg' | 'png';
80
+ timeout?: number;
81
+ };
82
+ declare function createClient(opts: Options): Bannerify;
83
+ declare class Bannerify {
84
+ #private;
85
+ private readonly opts;
86
+ private readonly client;
87
+ private readonly baseUrl;
88
+ constructor(opts: Options);
89
+ createImage(templateId: string, options?: CreateOptions): Promise<string | ArrayBuffer>;
90
+ createPdf(templateId: string, options?: CreateOptions): Promise<ArrayBuffer>;
91
+ createPermanentImage(): Promise<void>;
92
+ generateImageSignedUrl(templateId: string, options?: CreateOptions): Promise<string>;
93
+ }
94
+
95
+ export { Bannerify, type Modification, createClient };