Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix package.json configuration for types #2769

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 90 additions & 81 deletions dist/htmx.d.ts → dist/htmx.esm.d.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,6 @@
declare namespace htmx {
const onLoad: (callback: (elt: Node) => void) => EventListener;
const process: (elt: string | Element) => void;
const on: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
const off: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
const trigger: (elt: string | EventTarget, eventName: string, detail?: any) => boolean;
const ajax: (verb: HttpVerb, path: string, context: string | Element | HtmxAjaxHelperContext) => Promise<void>;
const find: (eltOrSelector: string | ParentNode, selector?: string) => Element;
const findAll: (eltOrSelector: string | ParentNode, selector?: string) => NodeListOf<Element>;
const closest: (elt: string | Element, selector: string) => Element;
function values(elt: Element, type: HttpVerb): any;
const remove: (elt: Node, delay?: number) => void;
const addClass: (elt: string | Element, clazz: string, delay?: number) => void;
const removeClass: (node: string | Node, clazz: string, delay?: number) => void;
const toggleClass: (elt: string | Element, clazz: string) => void;
const takeClass: (elt: string | Node, clazz: string) => void;
const swap: (target: string | Element, content: string, swapSpec: HtmxSwapSpecification, swapOptions?: SwapOptions) => void;
const defineExtension: (name: string, extension: any) => void;
const removeExtension: (name: string) => void;
const logAll: () => void;
const logNone: () => void;
const logger: any;
namespace config {
const historyEnabled: boolean;
const historyCacheSize: number;
const refreshOnHistoryMiss: boolean;
const defaultSwapStyle: HtmxSwapStyle;
const defaultSwapDelay: number;
const defaultSettleDelay: number;
const includeIndicatorStyles: boolean;
const indicatorClass: string;
const requestClass: string;
const addedClass: string;
const settlingClass: string;
const swappingClass: string;
const allowEval: boolean;
const allowScriptTags: boolean;
const inlineScriptNonce: string;
const inlineStyleNonce: string;
const attributesToSettle: string[];
const withCredentials: boolean;
const timeout: number;
const wsReconnectDelay: "full-jitter" | ((retryCount: number) => number);
const wsBinaryType: BinaryType;
const disableSelector: string;
const scrollBehavior: 'auto' | 'instant' | 'smooth';
const defaultFocusScroll: boolean;
const getCacheBusterParam: boolean;
const globalViewTransitions: boolean;
const methodsThatUseUrlParams: (HttpVerb)[];
const selfRequestsOnly: boolean;
const ignoreTitle: boolean;
const scrollIntoViewOnBoost: boolean;
const triggerSpecsCache: any | null;
const disableInheritance: boolean;
const responseHandling: HtmxResponseHandlingConfig[];
const allowNestedOobSwaps: boolean;
}
const parseInterval: (str: string) => number;
const _: (str: string) => any;
const version: string;
}
type HttpVerb = 'get' | 'head' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace' | 'patch';
type SwapOptions = {
export default htmx;
export type HttpVerb = 'get' | 'head' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace' | 'patch';
export type SwapOptions = {
select?: string;
selectOOB?: string;
eventInfo?: any;
Expand All @@ -70,9 +9,9 @@ type SwapOptions = {
afterSwapCallback?: swapCallback;
afterSettleCallback?: swapCallback;
};
type swapCallback = () => any;
type HtmxSwapStyle = 'innerHTML' | 'outerHTML' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'delete' | 'none' | string;
type HtmxSwapSpecification = {
export type swapCallback = () => any;
export type HtmxSwapStyle = 'innerHTML' | 'outerHTML' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' | 'delete' | 'none' | string;
export type HtmxSwapSpecification = {
swapStyle: HtmxSwapStyle;
swapDelay: number;
settleDelay: number;
Expand All @@ -85,10 +24,10 @@ type HtmxSwapSpecification = {
showTarget?: string;
focusScroll?: boolean;
};
type ConditionalFunction = ((this: Node, evt: Event) => boolean) & {
export type ConditionalFunction = ((this: Node, evt: Event) => boolean) & {
source: string;
};
type HtmxTriggerSpecification = {
export type HtmxTriggerSpecification = {
trigger: string;
pollInterval?: number;
eventFilter?: ConditionalFunction;
Expand All @@ -103,13 +42,13 @@ type HtmxTriggerSpecification = {
root?: string;
threshold?: string;
};
type HtmxElementValidationError = {
export type HtmxElementValidationError = {
elt: Element;
message: string;
validity: ValidityState;
};
type HtmxHeaderSpecification = Record<string, string>;
type HtmxAjaxHelperContext = {
export type HtmxHeaderSpecification = Record<string, string>;
export type HtmxAjaxHelperContext = {
source?: Element | string;
event?: Event;
handler?: HtmxAjaxHandler;
Expand All @@ -119,7 +58,7 @@ type HtmxAjaxHelperContext = {
headers?: Record<string, string>;
select?: string;
};
type HtmxRequestConfig = {
export type HtmxRequestConfig = {
boosted: boolean;
useUrlParams: boolean;
formData: FormData;
Expand All @@ -141,7 +80,7 @@ type HtmxRequestConfig = {
path: string;
triggeringEvent: Event;
};
type HtmxResponseInfo = {
export type HtmxResponseInfo = {
xhr: XMLHttpRequest;
target: Element;
requestConfig: HtmxRequestConfig;
Expand All @@ -157,7 +96,7 @@ type HtmxResponseInfo = {
failed?: boolean;
successful?: boolean;
};
type HtmxAjaxEtc = {
export type HtmxAjaxEtc = {
returnPromise?: boolean;
handler?: HtmxAjaxHandler;
select?: string;
Expand All @@ -168,7 +107,7 @@ type HtmxAjaxEtc = {
credentials?: boolean;
timeout?: number;
};
type HtmxResponseHandlingConfig = {
export type HtmxResponseHandlingConfig = {
code?: string;
swap: boolean;
error?: boolean;
Expand All @@ -178,18 +117,88 @@ type HtmxResponseHandlingConfig = {
swapOverride?: string;
event?: string;
};
type HtmxBeforeSwapDetails = HtmxResponseInfo & {
export type HtmxBeforeSwapDetails = HtmxResponseInfo & {
shouldSwap: boolean;
serverResponse: any;
isError: boolean;
ignoreTitle: boolean;
selectOverride: string;
};
type HtmxAjaxHandler = (elt: Element, responseInfo: HtmxResponseInfo) => any;
type HtmxSettleTask = (() => void);
type HtmxSettleInfo = {
export type HtmxAjaxHandler = (elt: Element, responseInfo: HtmxResponseInfo) => any;
export type HtmxSettleTask = (() => void);
export type HtmxSettleInfo = {
tasks: HtmxSettleTask[];
elts: Element[];
title?: string;
};
type HtmxExtension = any;
export type HtmxExtension = {
init: (api: any) => void;
onEvent: (name: string, event: Event | CustomEvent) => boolean;
transformResponse: (text: string, xhr: XMLHttpRequest, elt: Element) => string;
isInlineSwap: (swapStyle: HtmxSwapStyle) => boolean;
handleSwap: (swapStyle: HtmxSwapStyle, target: Node, fragment: Node, settleInfo: HtmxSettleInfo) => boolean | Node[];
encodeParameters: (xhr: XMLHttpRequest, parameters: FormData, elt: Node) => any | string | null;
getSelectors: () => string[] | null;
};
declare namespace htmx {
const onLoad: (callback: (elt: Node) => void) => EventListener;
const process: (elt: string | Element) => void;
const on: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
const off: (arg1: string | EventTarget, arg2: string | EventListener, arg3?: EventListener) => EventListener;
const trigger: (elt: string | EventTarget, eventName: string, detail?: any) => boolean;
const ajax: (verb: HttpVerb, path: string, context: string | Element | HtmxAjaxHelperContext) => Promise<void>;
const find: (eltOrSelector: string | ParentNode, selector?: string) => Element;
const findAll: (eltOrSelector: string | ParentNode, selector?: string) => NodeListOf<Element>;
const closest: (elt: string | Element, selector: string) => Element;
function values(elt: Element, type: HttpVerb): any;
const remove: (elt: Node, delay?: number) => void;
const addClass: (elt: string | Element, clazz: string, delay?: number) => void;
const removeClass: (node: string | Node, clazz: string, delay?: number) => void;
const toggleClass: (elt: string | Element, clazz: string) => void;
const takeClass: (elt: string | Node, clazz: string) => void;
const swap: (target: string | Element, content: string, swapSpec: HtmxSwapSpecification, swapOptions?: SwapOptions) => void;
const defineExtension: (name: string, extension: HtmxExtension) => void;
const removeExtension: (name: string) => void;
const logAll: () => void;
const logNone: () => void;
const logger: any;
namespace config {
const historyEnabled: boolean;
const historyCacheSize: number;
const refreshOnHistoryMiss: boolean;
const defaultSwapStyle: HtmxSwapStyle;
const defaultSwapDelay: number;
const defaultSettleDelay: number;
const includeIndicatorStyles: boolean;
const indicatorClass: string;
const requestClass: string;
const addedClass: string;
const settlingClass: string;
const swappingClass: string;
const allowEval: boolean;
const allowScriptTags: boolean;
const inlineScriptNonce: string;
const inlineStyleNonce: string;
const attributesToSettle: string[];
const withCredentials: boolean;
const timeout: number;
const wsReconnectDelay: "full-jitter" | ((retryCount: number) => number);
const wsBinaryType: BinaryType;
const disableSelector: string;
const scrollBehavior: 'auto' | 'instant' | 'smooth';
const defaultFocusScroll: boolean;
const getCacheBusterParam: boolean;
const globalViewTransitions: boolean;
const methodsThatUseUrlParams: (HttpVerb)[];
const selfRequestsOnly: boolean;
const ignoreTitle: boolean;
const scrollIntoViewOnBoost: boolean;
const triggerSpecsCache: any | null;
const disableInheritance: boolean;
const responseHandling: HtmxResponseHandlingConfig[];
const allowNestedOobSwaps: boolean;
}
const parseInterval: (str: string) => number;
const _: (str: string) => any;
const version: string;
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
"files": [
"LICENSE",
"README.md",
"dist/htmx.d.ts",
"dist/htmx.esm.d.ts",
"dist/*.js",
"dist/ext/*.js",
"dist/*.js.gz",
"editors/jetbrains/htmx.web-types.json"
],
"main": "dist/htmx.esm.js",
"types": "dist/htmx.d.ts",
"types": "dist/htmx.esm.d.ts",
"unpkg": "dist/htmx.min.js",
"web-types": "editors/jetbrains/htmx.web-types.json",
"scripts": {
"dist": "./scripts/dist.sh && npm run types-generate",
"lint": "eslint src/htmx.js test/attributes/ test/core/ test/util/",
"format": "eslint --fix src/htmx.js test/attributes/ test/core/ test/util/",
"types-check": "tsc src/htmx.js --noEmit --checkJs --target es6 --lib dom,dom.iterable",
"types-generate": "tsc src/htmx.js --declaration --emitDeclarationOnly --allowJs --outDir dist",
"types-generate": "tsc dist/htmx.esm.js --declaration --emitDeclarationOnly --allowJs --outDir dist",
"test": "npm run lint && npm run types-check && mocha-chrome test/index.html",
"type-declarations": "tsc --project ./jsconfig.json",
"ws-tests": "cd ./test/ws-sse && node ./server.js",
Expand Down