Skip to content

Commit

Permalink
chore: more packaging madness
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestmarcinko committed Oct 16, 2023
1 parent e543056 commit a6d5633
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "htmx-serverless",
"version": "0.1.4",
"version": "0.1.5",
"description": "HTMX serverless XHR requests",
"main": "dist/index.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ htmxServerless.handlers.set('/handler', '<div>Custom HTML</div>');
import htmx from "htmx.org";
import htmxServerless from "htmx-serverless";

// Initialize on your local htmx
htmxServerless.init(htmx);

// Requests to "/handler" are replaced with "<div>Custom HTML</div>"
htmxServerless.handlers.set('/handler', '<div>Custom HTML</div>');
```
Expand Down
2 changes: 1 addition & 1 deletion src/Serverless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type path = string;
type HTML = string;
export default class Serverless {
handlers: Map<path, HTML>;
constructor(h?: typeof htmx);
constructor();
init(h?: typeof htmx): void;
onEvent(name: string, evt: any): void;
transformResponse(text: string, xhr: XMLHttpRequest, elt: Element & {
Expand Down
4 changes: 2 additions & 2 deletions src/Serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ type HTML = string;
export default class Serverless {
handlers: Map<path, HTML>;

constructor(h?: typeof htmx) {
constructor() {
this.handlers = new Map();
this.init(h);
this.init(window?.htmx);
}

init(h?: typeof htmx) {
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Serverless from "./Serverless";

const htmxServerless = new Serverless(window.htmx);
window.htmxServerless = htmxServerless;
const htmxServerless = new Serverless();

export default htmxServerless;

0 comments on commit a6d5633

Please sign in to comment.