Skip to content

Commit

Permalink
beta.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sjc5 committed Oct 23, 2023
1 parent 593fddb commit c230da3
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 62 deletions.
8 changes: 8 additions & 0 deletions .changeset/large-worms-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"create-hwy": patch
"@hwy-js/build": patch
"hwy": patch
"@hwy-js/dev": patch
---

clean up types
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"changesets": [
"early-readers-rule",
"famous-adults-push",
"large-worms-sparkle",
"light-carpets-cough",
"neat-moles-brush",
"poor-phones-lie",
Expand Down
24 changes: 12 additions & 12 deletions docs/package-lock.json

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

6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"@hono/node-server": "^1.2.0",
"highlight.js": "^11.9.0",
"hono": "^3.8.3",
"hwy": "0.4.2-beta.5"
"hwy": "0.4.2-beta.6"
},
"devDependencies": {
"@hwy-js/build": "0.4.2-beta.5",
"@hwy-js/dev": "0.4.2-beta.5",
"@hwy-js/build": "0.4.2-beta.6",
"@hwy-js/dev": "0.4.2-beta.6",
"@types/node": "^20.8.7",
"@types/nprogress": "^0.2.2",
"htmx.org": "^1.9.6",
Expand Down
6 changes: 6 additions & 0 deletions packages/build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @hwy-js/build

## 0.4.2-beta.6

### Patch Changes

- clean up types

## 0.4.2-beta.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hwy-js/build",
"version": "0.4.2-beta.5",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# hwy

## 0.4.2-beta.6

### Patch Changes

- clean up types

## 0.4.2-beta.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hwy",
"version": "0.4.2-beta.5",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/create-hwy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# create-hwy

## 0.4.2-beta.6

### Patch Changes

- clean up types

## 0.4.2-beta.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create-hwy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-hwy",
"version": "0.4.2-beta.5",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/dev/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @hwy-js/dev

## 0.4.2-beta.6

### Patch Changes

- clean up types

## 0.4.2-beta.5

### Patch Changes
Expand Down
70 changes: 27 additions & 43 deletions packages/dev/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
type BooleanLike = boolean | `${boolean}`;
import type { HtmlEscapedString } from "hono/utils/html";

type BooleanLike = boolean | `${boolean}`;
type NumberLike = number | `${number}`;

type IfValueTypeIsBooleanConvertToBooleanOrBooleanString<T> = T extends boolean
? BooleanLike
: T;

type IfValueTypeIsNumberConvertToNumberOrNumberString<T> = T extends number
? NumberLike
: T;
type BooleanToBooleanLike<T> = T extends boolean ? BooleanLike : T;
type NumberToNumberLike<T> = T extends number ? NumberLike : T;

type StripNever<T> = {
[K in keyof T as T[K] extends never ? never : K]: T[K];
};

type IfKeyStartsWithOnConvertValueToString<
type FunctionToStringOrStrip<
T extends {
[key: string]: any;
},
Expand All @@ -28,49 +24,37 @@ type IfKeyStartsWithOnConvertValueToString<
: T[K];
}>;

type HandleConversions<T> = IfValueTypeIsBooleanConvertToBooleanOrBooleanString<
IfValueTypeIsNumberConvertToNumberOrNumberString<T>
>;
type HandleConversions<T> = BooleanToBooleanLike<NumberToNumberLike<T>>;

type Child = string | number | boolean | null | undefined | HtmlEscapedString;

type AdditionalAttributes = {
children: Child | Child[];
class: string;
dangerouslySetInnerHTML: {
__html: string;
};
style: Partial<CSSStyleDeclaration>;
};

type HTMLAttributesOuter<E> = Partial<
{
children: any;
class: string;
dangerouslySetInnerHTML: {
__html: string;
};
style: Partial<CSSStyleDeclaration>;
} & Omit<
{
[K in keyof E]: HandleConversions<E[K]>;
},
"children" | "class" | "dangerouslySetInnerHTML" | "style"
>
AdditionalAttributes &
Omit<
{
[K in keyof E]: HandleConversions<E[K]>;
},
keyof AdditionalAttributes
>
>;

type Bob = IfKeyStartsWithOnConvertValueToString<{
onClick: (e: Event) => void;
onHover: ((this: GlobalEventHandlers, ev: Event) => any) | null;
addEventListener: (e: Event) => void;
foo: string;
onFoo: number;
}>;

type HTMLAttributes<
E extends {
[key: string]: any;
},
> = HTMLAttributesOuter<Partial<IfKeyStartsWithOnConvertValueToString<E>>>;

type Jerry = HTMLAttributes<HTMLAnchorElement>;

const asdf: Jerry = {
ontimeupdate: "asdf",
onclick: "asdf",
};
> = HTMLAttributesOuter<Partial<FunctionToStringOrStrip<E>>>;

/*
BEGIN JSX INTRISIC ELEMENTS CODE
BEGIN ADAPTED YUDAI-NKT CODE
Adapted from: https://github.com/yudai-nkt/hono-jsx-types/blob/main/index.d.ts
Original license: MIT
Copied from source on: October 22, 2023
Expand Down Expand Up @@ -262,7 +246,7 @@ interface CustomIntrinsicElements {
}

/*
END JSX INTRISIC ELEMENTS CODE
END ADAPTED YUDAI-NKT CODE
*/

declare global {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hwy-js/dev",
"version": "0.4.2-beta.5",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand Down

0 comments on commit c230da3

Please sign in to comment.