mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 07:21:05 +00:00
commit
3ba3e87709
14
jsconfig.json
Normal file
14
jsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"noEmit": true,
|
||||
"checkJs": true,
|
||||
"jsx": "react",
|
||||
"strict": false,
|
||||
"lib": [ "dom" ]
|
||||
},
|
||||
"include": [
|
||||
"./src/htmx.js"
|
||||
],
|
||||
"verbose": true
|
||||
}
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -7239,6 +7239,12 @@
|
||||
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.3.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz",
|
||||
"integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==",
|
||||
"dev": true
|
||||
},
|
||||
"ua-parser-js": {
|
||||
"version": "0.7.28",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz",
|
||||
|
@ -19,9 +19,11 @@
|
||||
"dist/*.js.gz"
|
||||
],
|
||||
"main": "dist/htmx.min.js",
|
||||
"types": "src/htmx.d.ts",
|
||||
"unpkg": "dist/htmx.min.js",
|
||||
"scripts": {
|
||||
"test": "mocha-chrome test/index.html",
|
||||
"test-types": "tsc --project ./jsconfig.json",
|
||||
"dist": "cp -r src/* dist/ && npm run-script uglify && gzip -k -f dist/htmx.min.js > dist/htmx.min.js.gz && exit",
|
||||
"www": "node scripts/www.js",
|
||||
"uglify": "uglifyjs -m eval -o dist/htmx.min.js dist/htmx.js"
|
||||
@ -38,8 +40,9 @@
|
||||
"fs-extra": "^9.1.0",
|
||||
"mocha": "^7.2.0",
|
||||
"mocha-chrome": "^2.2.0",
|
||||
"sass": "^1.34.0",
|
||||
"sinon": "^9.2.4",
|
||||
"uglify-js": "^3.13.7",
|
||||
"sass": "^1.34.0"
|
||||
"typescript": "^4.3.5",
|
||||
"uglify-js": "^3.13.7"
|
||||
}
|
||||
}
|
||||
|
26
src/htmx.d.ts
vendored
Normal file
26
src/htmx.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
export interface HtmxApi {
|
||||
config?: HtmxConfig
|
||||
logger?: (a: HTMLElement, b: Event, c: any) => void | null
|
||||
}
|
||||
|
||||
export interface HtmxConfig {
|
||||
historyEnabled?: boolean;
|
||||
historyCacheSize?: number;
|
||||
refreshOnHistoryMiss?: boolean;
|
||||
defaultSwapStyle?: 'innerHTML' | string;
|
||||
defaultSwapDelay?: number;
|
||||
defaultSettleDelay?: number;
|
||||
includeIndicatorStyles?: boolean;
|
||||
indicatorClass?: 'htmx-indicator' | string;
|
||||
requestClass?: 'htmx-request' | string;
|
||||
settlingClass?: 'htmx-settling' | string;
|
||||
swappingClass?: 'htmx-swapping' | string;
|
||||
allowEval?: boolean;
|
||||
attributesToSettle?: ["class", "style", "width", "height"] | string[];
|
||||
withCredentials?: boolean;
|
||||
wsReconnectDelay?: 'full-jitter' | string;
|
||||
disableSelector?: "[hx-disable], [data-hx-disable]" | string;
|
||||
useTemplateFragments?: boolean;
|
||||
}
|
||||
|
||||
export declare var htmx: HtmxApi
|
12
src/htmx.js
12
src/htmx.js
@ -1,7 +1,9 @@
|
||||
//AMD insanity
|
||||
(function (root, factory) {
|
||||
//@ts-ignore
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
//@ts-ignore
|
||||
define([], factory);
|
||||
} else {
|
||||
// Browser globals
|
||||
@ -150,9 +152,11 @@ return (function () {
|
||||
var responseNode = responseDoc.body;
|
||||
while (depth > 0) {
|
||||
depth--;
|
||||
// @ts-ignore
|
||||
responseNode = responseNode.firstChild;
|
||||
}
|
||||
if (responseNode == null) {
|
||||
// @ts-ignore
|
||||
responseNode = getDocument().createDocumentFragment();
|
||||
}
|
||||
return responseNode;
|
||||
@ -1205,6 +1209,7 @@ return (function () {
|
||||
function getWebSocketReconnectDelay(retryCount) {
|
||||
var delay = htmx.config.wsReconnectDelay;
|
||||
if (typeof delay === 'function') {
|
||||
// @ts-ignore
|
||||
return delay(retryCount);
|
||||
}
|
||||
if (delay === 'full-jitter') {
|
||||
@ -1598,9 +1603,11 @@ return (function () {
|
||||
if (this.status >= 200 && this.status < 400) {
|
||||
triggerEvent(getDocument().body, "htmx:historyCacheMissLoad", details);
|
||||
var fragment = makeFragment(this.response);
|
||||
// @ts-ignore
|
||||
fragment = fragment.querySelector('[hx-history-elt],[data-hx-history-elt]') || fragment;
|
||||
var historyElement = getHistoryElement();
|
||||
var settleInfo = makeSettleInfo(historyElement);
|
||||
// @ts-ignore
|
||||
swapInnerHTML(historyElement, fragment, settleInfo)
|
||||
settleImmediately(settleInfo.tasks);
|
||||
currentPathForHistory = path;
|
||||
@ -2369,7 +2376,9 @@ return (function () {
|
||||
try {
|
||||
selectionInfo = {
|
||||
elt: activeElt,
|
||||
// @ts-ignore
|
||||
start: activeElt ? activeElt.selectionStart : null,
|
||||
// @ts-ignore
|
||||
end: activeElt ? activeElt.selectionEnd : null
|
||||
};
|
||||
} catch (e) {
|
||||
@ -2384,7 +2393,9 @@ return (function () {
|
||||
selectionInfo.elt.id) {
|
||||
var newActiveElt = document.getElementById(selectionInfo.elt.id);
|
||||
if (newActiveElt) {
|
||||
// @ts-ignore
|
||||
if (selectionInfo.start && newActiveElt.setSelectionRange) {
|
||||
// @ts-ignore
|
||||
newActiveElt.setSelectionRange(selectionInfo.start, selectionInfo.end);
|
||||
}
|
||||
newActiveElt.focus();
|
||||
@ -2536,6 +2547,7 @@ return (function () {
|
||||
function getMetaConfig() {
|
||||
var element = getDocument().querySelector('meta[name="htmx-config"]');
|
||||
if (element) {
|
||||
// @ts-ignore
|
||||
return parseJSON(element.content);
|
||||
} else {
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user