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

0.4.2 #36

Closed
wants to merge 13 commits into from
Closed
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
40 changes: 20 additions & 20 deletions docs/package-lock.json

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

14 changes: 7 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
},
"dependencies": {
"@hono/node-server": "^1.2.0",
"highlight.js": "^11.8.0",
"hono": "^3.7.5",
"hwy": "^0.4.1"
"highlight.js": "^11.9.0",
"hono": "^3.8.3",
"hwy": "0.4.2-beta.6"
},
"devDependencies": {
"@hwy-js/build": "^0.4.1",
"@hwy-js/dev": "^0.4.1",
"@types/node": "^20.8.3",
"@types/nprogress": "^0.2.1",
"@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",
"nprogress": "^0.2.0",
"tailwindcss": "^3.3.3",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/inline-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function InlineCode({
high_contrast
? "bg-black text-white dark:bg-white dark:text-black"
: "bg-[#7772] dark:bg-[#7773] rounded",
rest.class
rest.class,
)}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ app.all("*", async (c, next) => {
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<HeadElements
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/docs.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ app.all('*', async (c, next) => {
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<HeadElements
Expand Down
8 changes: 4 additions & 4 deletions 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.1",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand All @@ -24,13 +24,13 @@
"dependencies": {
"chokidar": "^3.5.3",
"dotenv": "^16.3.1",
"esbuild": "^0.19.2",
"esbuild": "^0.19.5",
"picocolors": "^1.0.0",
"readdirp": "^3.6.0"
},
"devDependencies": {
"@types/node": "^20.8.3",
"hono": "^3.7.5",
"@types/node": "^20.8.7",
"hono": "^3.8.3",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hwy",
"version": "0.4.1",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand All @@ -21,8 +21,8 @@
"@hono/node-server": "^1.2.0",
"@hwy-js/build": "workspace:*",
"@hwy-js/dev": "workspace:*",
"@types/node": "^20.8.3",
"hono": "^3.7.5",
"@types/node": "^20.8.7",
"hono": "^3.8.3",
"tsup": "^7.2.0"
},
"repository": {
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/components/client-entry-script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function ClientScripts({
.map((x) => {
return (
<script
key={x.path}
src={getPublicUrl("dist/pages/" + x.fileRefFromPagesDirWithJsExt)}
{...{ [pageStrategy]: true }}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/head-elements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ function HeadElements(props: {
<>
{head_blocks.map((block, i) => {
if ("title" in block) {
return <title key={i}>{block.title}</title>;
return <title>{block.title}</title>;
} else {
return <block.tag key={i} {...block.props} />;
return <block.tag {...block.props} />;
}
})}
</>
Expand Down
23 changes: 22 additions & 1 deletion packages/core/src/router/get-matching-path-data-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,28 @@ function get_matching_paths_internal(__paths: Array<SemiDecoratedPath>) {
: x.realSegmentsLength;

// make sure any remaining matches are not longer than the path itself
return x.segments.length <= index_adjusted_real_segments_length;
const should_move_on =
x.segments.length <= index_adjusted_real_segments_length;

if (!should_move_on) {
return false;
}

// now we need to remove ineligible indices
if (!x.isIndex) {
// if not an index, then you're already confirmed good
return true;
}

const truthy_segments_length = x.segments.filter((x) => x.segment).length;

const path_segments_length = x.path.split("/").filter(Boolean).length;

if (truthy_segments_length === path_segments_length) {
return true;
}

return false;
});

// if there are multiple matches, filter out the ultimate catch-all
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/router/get-matching-path-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ function fully_decorate_paths({
throw e;
}
},
loader: async (loader_args: DataFunctionArgs) => {
loader: async (loaderArgs: DataFunctionArgs) => {
try {
const imported = await get_imported();
return imported.loader ? imported.loader(loader_args) : undefined;
return imported.loader ? imported.loader(loaderArgs) : undefined;
} catch (e) {
if (e instanceof Response) return e;
console.error(e);
throw e;
}
},
action: async (action_args: DataFunctionArgs) => {
action: async (actionArgs: DataFunctionArgs) => {
try {
const imported = await get_imported();
return imported.action ? imported.action(action_args) : undefined;
return imported.action ? imported.action(actionArgs) : undefined;
} catch (e) {
if (e instanceof Response) return e;
console.error(e);
Expand Down
12 changes: 12 additions & 0 deletions packages/create-hwy/__common/pages/_index.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference lib="dom" />

const el = document.getElementById("increment-button");

if (el) {
let count = 0;

el.addEventListener("click", () => {
count++;
el.innerHTML = count.toString();
});
}
9 changes: 9 additions & 0 deletions packages/create-hwy/__common/pages/_index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ export default function () {
The nav bar above is being rendered from <code>src/main.tsx</code>,
which is your site's main server "entry point".
</p>

<p>
Click the button below to increment the number (my click handler is in{" "}
<code>src/pages/_index.client.ts</code>):
</p>

<button id="increment-button" class="btn">
0
</button>
</>
);
}
21 changes: 15 additions & 6 deletions packages/create-hwy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ async function main() {
is_jsx: false,
});

// pages
const pages_to_copy = [
// pages dir in __common
const tsx_list = [
"about.page",
"$.page",
"_index.page",
Expand All @@ -365,15 +365,24 @@ async function main() {
"__auth/login.page",
];

const ts_list = ["_index.client"];

const files_to_copy = [...tsx_list, ...ts_list];

await Promise.all(
pages_to_copy.map(async (page) => {
files_to_copy.map(async (file) => {
const is_jsx = tsx_list.includes(file);

return handle_ts_or_js_file_copy({
code: fs.readFileSync(
path.join(root_dir_path, "__common/pages/" + page + ".tsx"),
path.join(
root_dir_path,
"__common/pages/" + file + (is_jsx ? ".tsx" : ".ts"),
),
"utf8",
),
destination_without_extension: "src/pages/" + page,
is_jsx: true,
destination_without_extension: "src/pages/" + file,
is_jsx,
});
}),
);
Expand Down
10 changes: 5 additions & 5 deletions 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.1",
"version": "0.4.2-beta.6",
"author": {
"name": "Samuel J. Cook"
},
Expand Down Expand Up @@ -28,10 +28,10 @@
"picocolors": "^1.0.0"
},
"devDependencies": {
"@types/inquirer": "^9.0.3",
"@types/node": "^20.8.3",
"@types/nprogress": "^0.2.1",
"hono": "^3.7.5",
"@types/inquirer": "^9.0.6",
"@types/node": "^20.8.7",
"@types/nprogress": "^0.2.2",
"hono": "^3.8.3",
"hwy": "workspace:*",
"nprogress": "^0.2.0",
"prettier": "^3.0.3",
Expand Down
8 changes: 2 additions & 6 deletions packages/create-hwy/src/get-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ ${
: `await hwyInit({
app,
importMetaUrl: import.meta.url,
serveStatic,${
options.css_preference === "tailwind"
? `\n watchExclusions: ["src/styles/tw-output.bundle.css"],`
: ""
}
serveStatic,
});`
}

Expand All @@ -81,7 +77,7 @@ app.all("*", async (c, next) => {
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<HeadElements
Expand Down
1 change: 0 additions & 1 deletion packages/create-hwy/src/get-readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ await hwyInit({
* to add a publicUrlPrefix.
*/
publicUrlPrefix: process.env.NODE_ENV === "production" ? "docs/" : undefined,
watchExclusions: ["src/styles/tw-output.bundle.css"],
});
\`\`\`
`.trim() +
Expand Down
8 changes: 8 additions & 0 deletions packages/create-hwy/src/get-tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function get_ts_config(options: Options) {
return JSON.stringify(deno_config).trim() + "\n";
}

if (
options.deployment_target === "node" ||
options.deployment_target === "vercel-lambda"
) {
// @ts-ignore
ts_config.compilerOptions.types = ["node"];
}

if (options.deployment_target === "bun") {
// @ts-ignore
ts_config.compilerOptions.types = ["bun-types"];
Expand Down
Loading