Skip to content

Commit

Permalink
docs(changeset): fix: clean up old console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Dec 2, 2023
1 parent e7313f4 commit d8ef7c9
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 126 deletions.
7 changes: 7 additions & 0 deletions .changeset/silver-hotels-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@vinxi/server-functions": patch
"@vinxi/plugin-directives": patch
"vinxi": patch
---

fix: clean up old console logs
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react-dom": "0.0.0-experimental-dddfe6882-20231005",
"tailwindcss": "^3.3.3",
"unist-util-visit": "^5.0.0",
"vinxi": "0.0.34",
"vinxi": "0.0.47",
"vite-plugin-inspect": "^0.7.38",
"vite-tsconfig-paths": "^4.2.0",
"wouter": "^2.11.0",
Expand Down
33 changes: 2 additions & 31 deletions examples/vanilla/spa/app/client.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
/// <reference types="vinxi/types/client" />
import "vinxi/client";

import { sayHello } from "./actions";
import { world } from "./server-functions";
import "./style.css";
import { world2 } from "./inline";

export async function world2(x) {
"use server";
console.log("hello world 2", x);
}

async function world3(x, y) {
"use server";
console.log("hello world 3", x, y);
}

const world4 = async (x, y) => {
"use server";
console.log("hello world 4", x, y);
};

const world5 = async (x) => {
"use server";
console.log("hello world 4", x);
};

console.log(
await world(),
await world2(1),
await world3(2, 3),
await world4(5, 6),
await sayHello(),
await world5({ hello: 1, world: "aasd", x: true }),
);
console.log("Hello world!");
await world2(10);

document.getElementById("app").innerHTML = `Hello World`;
13 changes: 13 additions & 0 deletions examples/vanilla/spa/app/inline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { sayHello } from "./actions";
import { world } from "./server-functions";

export async function world2(x) {
"use server";
await world3(x, 1);
console.log("hello world 2", x);
}

async function world3(x, y) {
"use server";
console.log("hello world 3", x, y);
}
1 change: 1 addition & 0 deletions packages/vinxi-directives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"vinxi": "^0.0.48"
},
"dependencies": {
"@babel/parser": "^7.23.5",
"acorn": "^8.10.0",
"acorn-jsx": "^5.3.2",
"acorn-loose": "^8.3.0",
Expand Down
1 change: 0 additions & 1 deletion packages/vinxi-server-functions/server-runtime.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export function createServerReference(fn, id, name) {
console.log("creating reference");
return new Proxy(fn, {
get(target, prop, receiver) {
if (prop === "url") {
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const command = defineCommand({
},
async run({ args }) {
process.env.PORT ??= args.port ?? 3000;
process.env.HOST ??= args.host;
process.env.HOST ??= args.host ?? "0.0.0.0";
await import(process.cwd() + "/.output/server/index.mjs");
},
},
Expand Down
14 changes: 7 additions & 7 deletions packages/vinxi/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import resolve from "resolve";
import { isMainThread } from "worker_threads";

import invariant, { InvariantError } from "./invariant.js";
import { c, consola, log, withLogger } from "./logger.js";
import { c, consola, withLogger } from "./logger.js";
import { resolveRouterConfig, routerSchema } from "./router-modes.js";

/** @typedef {{
devtools?: boolean;
routers?: import("./router-modes.js").RouterSchemaInput[];
name?:
string;
server?: import('nitropack').NitroConfig;
/** @typedef {{
devtools?: boolean;
routers?: import("./router-modes.js").RouterSchemaInput[];
name?:
string;
server?: import('nitropack').NitroConfig;
root?: string
}} AppOptions */

Expand Down
132 changes: 65 additions & 67 deletions packages/vinxi/lib/router-modes.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,79 @@
import { setHeader } from "h3";
import * as v from "zod";
import * as z from "zod";

import { isMainThread } from "node:worker_threads";

import invariant from "./invariant.js";
import { handlerModule, join } from "./path.js";
import { resolve } from "./resolve.js";

export { v };
export { z };
/**
* @typedef {{ routes?: CompiledRouter; devServer?: import('vite').ViteDevServer; appWorker?: import('./app-worker-client.js').AppWorkerClient; mode: import("./router-mode.js").RouterMode }} Internals
* @typedef {{ getRoutes(): Promise<any[]>; } & EventTarget} CompiledRouter
* @typedef {(router: RouterSchemaInput, app: import("./app.js").AppOptions) => CompiledRouter} RouterStyleFn
* */
export const staticRouterSchema = v.object({
name: v.string(),
base: v.optional(v.string().default("/")),
mode: v.literal("static"),
dir: v.string(),
root: v.optional(v.string()),
export const staticRouterSchema = z.object({
name: z.string(),
base: z.optional(z.string().default("/")),
mode: z.literal("static"),
dir: z.string(),
root: z.optional(z.string()),
});
export const buildRouterSchema = v.object({
name: v.string(),
base: v.optional(v.string().default("/")),
root: v.optional(v.string()),
mode: v.literal("build"),
handler: v.string(),
/** @type {v.ZodOptionalType<v.ZodType<RouterStyleFn, v.ZodTypeDef, RouterStyleFn>>} */
routes: v.optional(v.custom((value) => value !== null)),
extensions: v.array(v.string()).optional(),
outDir: v.string().optional(),
target: v.literal("browser"),
plugins: v.optional(v.custom((value) => typeof value === "function")),
export const buildRouterSchema = z.object({
name: z.string(),
base: z.optional(z.string().default("/")),
root: z.optional(z.string()),
mode: z.literal("build"),
handler: z.string(),
/** @type {z.ZodOptionalType<z.ZodType<RouterStyleFn, z.ZodTypeDef, RouterStyleFn>>} */
routes: z.optional(z.custom((value) => value !== null)),
extensions: z.array(z.string()).optional(),
outDir: z.string().optional(),
target: z.literal("browser").optional().default("browser"),
plugins: z.optional(z.custom((value) => typeof value === "function")),
});
export const handlerRouterSchema = v.object({
name: v.string(),
base: v.optional(v.string().default("/")),
root: v.optional(v.string()),
export const handlerRouterSchema = z.object({
name: z.string(),
base: z.optional(z.string().default("/")),
root: z.optional(z.string()),

mode: v.literal("handler"),
mode: z.literal("handler"),

build: v.optional(v.boolean()),
worker: v.optional(v.boolean()),
handler: v.string(),
middleware: v.optional(v.string()),
/** @type {v.ZodOptionalType<v.ZodType<RouterStyleFn, v.ZodTypeDef, RouterStyleFn>>} */
routes: v.optional(v.custom((value) => value !== null)),
outDir: v.string().optional(),
target: v.literal("server").optional().default("server"),
plugins: v.optional(v.custom((value) => typeof value === "function")),
build: z.optional(z.boolean()),
worker: z.optional(z.boolean()),
handler: z.string(),
middleware: z.optional(z.string()),
/** @type {z.ZodOptionalType<z.ZodType<RouterStyleFn, z.ZodTypeDef, RouterStyleFn>>} */
routes: z.optional(z.custom((value) => value !== null)),
outDir: z.string().optional(),
target: z.literal("server").optional().default("server"),
plugins: z.optional(z.custom((value) => typeof value === "function")),
});
export const spaRouterSchema = v.object({
name: v.string(),
base: v.optional(v.string().default("/")),
root: v.optional(v.string()),
mode: v.literal("spa"),
/** @type {v.ZodOptionalType<v.ZodType<RouterStyleFn, v.ZodTypeDef, RouterStyleFn>>} */
routes: v.optional(v.custom((value) => value !== null)),
handler: v.string(),
outDir: v.string().optional(),
target: v.literal("browser").optional().default("browser"),
plugins: v.optional(v.custom((value) => typeof value === "function")),
export const spaRouterSchema = z.object({
name: z.string(),
base: z.optional(z.string().default("/")),
root: z.optional(z.string()),
mode: z.literal("spa"),
/** @type {z.ZodOptionalType<z.ZodType<RouterStyleFn, z.ZodTypeDef, RouterStyleFn>>} */
routes: z.optional(z.custom((value) => value !== null)),
handler: z.string(),
outDir: z.string().optional(),
target: z.literal("browser").optional().default("browser"),
plugins: z.optional(z.custom((value) => typeof value === "function")),
});
const customRouterSchema = v.object({
name: v.string(),
base: v.optional(v.string().default("/")),
root: v.optional(v.string()),
mode: v.object({
resolveConfig: v.function().args(v.any(), v.any()).returns(v.any()),
const customRouterSchema = z.object({
name: z.string(),
base: z.optional(z.string().default("/")),
root: z.optional(z.string()),
mode: z.object({
resolveConfig: z.function().args(z.any(), z.any()).returns(z.any()),
}),
/** @type {v.ZodOptionalType<v.ZodType<RouterStyleFn, v.ZodTypeDef, RouterStyleFn>>} */
routes: v.optional(v.custom((value) => value !== null)),
handler: v.string(),
outDir: v.string().optional(),
target: v.literal("server"),
plugins: v.optional(v.custom((value) => typeof value === "function")),
/** @type {z.ZodOptionalType<z.ZodType<RouterStyleFn, z.ZodTypeDef, RouterStyleFn>>} */
routes: z.optional(z.custom((value) => value !== null)),
handler: z.string(),
outDir: z.string().optional(),
target: z.literal("server"),
plugins: z.optional(z.custom((value) => typeof value === "function")),
});
export const routerSchema = {
static: staticRouterSchema,
Expand All @@ -83,20 +82,19 @@ export const routerSchema = {
handler: handlerRouterSchema,
custom: customRouterSchema,
};
/** @typedef {v.infer<typeof buildRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} BuildRouterSchema */
/** @typedef {v.infer<typeof customRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} CustomRouterSchema */
/** @typedef {v.infer<typeof staticRouterSchema> & { outDir: string; base: string; order: number; internals: Internals }} StaticRouterSchema */
/** @typedef {v.infer<typeof handlerRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} HandlerRouterSchema */
/** @typedef {v.infer<typeof spaRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} SPARouterSchema */
/** @typedef {z.infer<typeof buildRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} BuildRouterSchema */
/** @typedef {z.infer<typeof customRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} CustomRouterSchema */
/** @typedef {z.infer<typeof staticRouterSchema> & { outDir: string; base: string; order: number; internals: Internals }} StaticRouterSchema */
/** @typedef {z.infer<typeof handlerRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} HandlerRouterSchema */
/** @typedef {z.infer<typeof spaRouterSchema> & { outDir: string; base: string; order: number; root: string; internals: Internals }} SPARouterSchema */
/** @typedef {(HandlerRouterSchema | BuildRouterSchema | SPARouterSchema | StaticRouterSchema | CustomRouterSchema )} RouterSchema */
/** @typedef {(v.infer<typeof buildRouterSchema> | v.infer<typeof staticRouterSchema> | v.infer<typeof spaRouterSchema> | v.infer<typeof handlerRouterSchema> | v.infer<typeof customRouterSchema>)} RouterSchemaInput */
/** @typedef {(z.infer<typeof buildRouterSchema> | z.infer<typeof staticRouterSchema> | z.infer<typeof spaRouterSchema> | z.infer<typeof handlerRouterSchema> | z.infer<typeof customRouterSchema>)} RouterSchemaInput */

/**
* @template X
* @template T
* @param {X} schema
* @param {import("./router-mode.js").RouterMode<v.z.infer<X>>} mode
* @returns {import("./router-mode.js").RouterMode<v.z.infer<X>>}
* @param {import("./router-mode.js").RouterMode<z.z.infer<X>>} mode
* @returns {import("./router-mode.js").RouterMode<z.z.infer<X>>}
*/
export function createRouterMode(schema, mode) {
return mode;
Expand Down
1 change: 1 addition & 0 deletions packages/vinxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
},
"devDependencies": {
"@types/node": "^18.17.11",
"@types/resolve": "^1.20.6",
"prettier": "^2.8.8"
}
}
Loading

0 comments on commit d8ef7c9

Please sign in to comment.