Skip to content

Commit

Permalink
docs(changeset): fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Sep 24, 2023
1 parent bc82d8e commit 1d8b542
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .changeset/honest-waves-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@vinxi/solid-start": patch
"vinxi": patch
---

fix types
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ docs/.vitepress/dist
docs/.vitepress/cache
.vitepress

**/types/**/*.d.ts
**/types/**/*.d.ts.map

2 changes: 1 addition & 1 deletion examples/react/rsc/ssr/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import reactRefresh from "@vitejs/plugin-react";
import { readFileSync } from "fs";
import { join } from "path";
import { createApp } from "vinxi";
import { virtual } from "vinxi/lib/plugins/virtual";
import { virtual } from "vinxi/plugins/virtual";

function hash(str) {
let hash = 0;
Expand Down
30 changes: 13 additions & 17 deletions examples/react/ssr/basic-cloudflare/app.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import reactRefresh from "@vitejs/plugin-react";
import { createApp } from "vinxi";
import { config } from "vinxi/lib/plugins/config";
import { virtual } from "vinxi/lib/plugins/virtual";
import { config } from "vinxi/plugins/config";
import { virtual } from "vinxi/plugins/virtual";

function viteServer() {
let router;
Expand Down Expand Up @@ -37,27 +37,23 @@ export default createApp({
name: "client",
mode: "build",
handler: "./app/client.tsx",
compile: {
target: "browser",
plugins: () => [reactRefresh()],
},
target: "browser",
plugins: () => [reactRefresh()],
base: "/_build",
},
{
name: "ssr",
mode: "handler",
handler: "./app/server.tsx",
compile: {
target: "server",
plugins: () => [
viteServer(),
config("kv", {
define: {
"import.meta.env.cloudflare": "globalThis.cloudflare",
},
}),
],
},
target: "server",
plugins: () => [
viteServer(),
config("kv", {
define: {
"import.meta.env.cloudflare": "globalThis.cloudflare",
},
}),
],
},
],
});
4 changes: 2 additions & 2 deletions frameworks/solid-start/root/routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fileRoutes from "vinxi/routes";
import fileRoutes, { RouteModule } from "vinxi/routes";

console.log("fileRoutes", fileRoutes);

const defineRoutes = (fileRoutes) => {
const defineRoutes = (fileRoutes: RouteModule[]) => {
function processRoute(routes, route, id, full) {
const parentRoute = Object.values(routes).find((o) => {
// if (o.id.endsWith("/index")) {
Expand Down
28 changes: 14 additions & 14 deletions packages/vinxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"scripts": {},
"bin": "./bin/cli.mjs",
"types": "./types/lib/index.d.ts",
"types": "./dist/types/lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js"
Expand Down Expand Up @@ -52,43 +52,43 @@
"typesVersions": {
"*": {
".": [
"./types/lib/index.d.ts"
"./dist/types/lib/index.d.ts"
],
"dev-server": [
"./types/lib/dev-server.d.ts"
"./dist/types/lib/dev-server.d.ts"
],
"server": [
"./types/runtime/server.d.ts"
"./dist/types/runtime/server.d.ts"
],
"party": [
"./types/runtime/party.d.ts"
"./dist/types/runtime/party.d.ts"
],
"css": [
"./types/runtime/style.d.ts"
"./dist/types/runtime/style.d.ts"
],
"client": [
"./types/runtime/client.d.ts"
"./dist/types/runtime/client.d.ts"
],
"fs-router": [
"./types/lib/fs-router.d.ts"
"./dist/types/lib/fs-router.d.ts"
],
"types/server": [
"./runtime/types-lib/server.d.ts"
"./types/server.d.ts"
],
"types/client": [
"./runtime/types-lib/client.d.ts"
"./types/client.d.ts"
],
"routes": [
"./runtime/types-lib/routes.d.ts"
"./types/routes.d.ts"
],
"lib/invariant": [
"./types/lib/invariant.d.ts"
"./dist/types/lib/invariant.d.ts"
],
"plugins/config": [
"./types/lib/plugins/config.d.ts"
"./dist/types/lib/plugins/config.d.ts"
],
"plugins/virtual": [
"./types/lib/plugins/virtual.d.ts"
"./dist/types/lib/plugins/virtual.d.ts"
]
}
},
Expand Down
42 changes: 42 additions & 0 deletions packages/vinxi/runtime/party.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,63 @@ import {

class InternalParty {
connections = new Map();
/**
* @param {any} tag
*/
getConnections(tag) {
return this.connections.values();
}
/**
* @param {any} id
*/
getConnection(id) {
return this.connections.get(id);
}
id;
/**
* @param {string} id
*/
constructor(id) {
this.id = id;
}
/**
* @param {{ id: any; }} connection
*/
onConnect(connection) {
this.connections.set(connection.id, connection);
}

/**
* @param {{ id: any; }} connection
*/
onClose(connection) {
this.connections.delete(connection.id);
}

/**
* @type {any}
*/
storage;
/**
* @type {any}
*/
name;
/**
* @type {any}
*/
internalID;
/**
* @type {any}
*/
env;
/**
* @type {any}
*/
context;

/**
* @param {any} msg
*/
broadcast(msg, without = []) {
for (const conn of this.connections.values()) {
if (without && without.includes(conn.id)) {
Expand All @@ -43,15 +76,24 @@ class InternalParty {
}
}

/**
* @type {any}
*/
parties;
}

/**
* @param {WebSocket} webSocket
*/
function createConnection(webSocket) {
// @ts-ignore
webSocket.id ??= Math.random().toString(36).slice(2);
return webSocket;
}

/**
* @param {{ onStart: (arg0: InternalParty) => any; onConnect: (arg0: InternalParty, arg1: any) => void; onMessage: (arg0: InternalParty, arg1: string | ArrayBuffer | Buffer[], arg2: any) => void; onError: (arg0: InternalParty, arg1: any, arg2: Error) => void; onClose: (arg0: InternalParty, arg1: any) => void; onRequest: (arg0: InternalParty, arg1: Request) => any; }} partyServer
*/
export function partyHandler(partyServer) {
return lazyEventHandler(async () => {
const party = new InternalParty("main");
Expand Down
5 changes: 5 additions & 0 deletions packages/vinxi/runtime/style.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
*
* @param {*} styles
* @param {*} data
*/
export function updateStyles(styles, data) {
let styleAsset = styles.find(
(s) => s.attrs["data-vite-dev-id"] === data.file,
Expand Down
2 changes: 1 addition & 1 deletion packages/vinxi/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"declarationMap": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./types"
"outDir": "./dist/types"
},
"include": ["lib", "runtime"]
}
4 changes: 0 additions & 4 deletions packages/vinxi/types.sh

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare type Mod = `$${string}`;

declare const routes: ({
export type RouteModule = {
path: string;
} & Record<
Mod,
Expand All @@ -9,6 +9,8 @@ declare const routes: ({
import: () => Promise<any>;
require: () => any;
}
>)[];
>;

declare const routes: RouteModule[];

export default routes;
File renamed without changes.

0 comments on commit 1d8b542

Please sign in to comment.