Skip to content

Commit 08368ed

Browse files
committed
chore: fix svelte types
1 parent d13c589 commit 08368ed

8 files changed

Lines changed: 21 additions & 27 deletions

File tree

packages/next/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Auto-generated - do not edit manually
2-
export const VERSION = "0.8.8";
2+
export const VERSION = "0.8.9";
33
export const DEFAULT_AGENT = `replane-next/${VERSION}`;

packages/react/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Auto-generated - do not edit manually
2-
export const VERSION = "0.8.8";
2+
export const VERSION = "0.8.9";
33
export const DEFAULT_AGENT = `replane-react/${VERSION}`;

packages/sdk/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Auto-generated - do not edit manually
2-
export const VERSION = "0.8.8";
2+
export const VERSION = "0.8.9";
33
export const DEFAULT_AGENT = `replane-js/${VERSION}`;

packages/svelte/src/ReplaneContext.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
};
1515
</script>
1616

17-
<script lang="ts">
17+
<script lang="ts" generics="T extends object">
1818
import { createReplaneClient, restoreReplaneClient } from "@replanejs/sdk";
1919
import { setReplaneContext } from "./context";
2020
import { hasClient } from "./types";
2121
22-
let props: ReplaneContextProps = $props();
22+
let props: ReplaneContextProps<T> = $props();
2323
2424
type ClientState =
2525
| { status: "loading"; client: null; error: null }
26-
| { status: "ready"; client: ReplaneClient<any>; error: null }
26+
| { status: "ready"; client: ReplaneClient<T>; error: null }
2727
| { status: "error"; client: null; error: Error };
2828
2929
let state = $state<ClientState>({ status: "loading", client: null, error: null });
30-
let clientRef: ReplaneClient<any> | null = null;
30+
let clientRef: ReplaneClient<T> | null = null;
3131
let cancelled = false;
3232
3333
// Handle client initialization based on props
@@ -46,7 +46,7 @@
4646
if (snapshot) {
4747
// Restore from snapshot synchronously
4848
try {
49-
const client = restoreReplaneClient({
49+
const client = restoreReplaneClient<T>({
5050
snapshot,
5151
connection: {
5252
baseUrl: options.baseUrl,
@@ -72,7 +72,7 @@
7272
// Async client creation
7373
state = { status: "loading", client: null, error: null };
7474
75-
createReplaneClient({
75+
createReplaneClient<T>({
7676
...options,
7777
agent: options.agent ?? DEFAULT_AGENT,
7878
})
@@ -103,7 +103,7 @@
103103
// Set context when client is ready
104104
$effect(() => {
105105
if (state.status === "ready" && state.client) {
106-
setReplaneContext(state.client);
106+
setReplaneContext<T>(state.client);
107107
}
108108
});
109109

packages/svelte/src/context.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const REPLANE_CONTEXT_KEY = Symbol("replane");
88
* Set the Replane client in Svelte context.
99
* @internal
1010
*/
11-
export function setReplaneContext<T extends Record<string, unknown>>(
12-
client: ReplaneClient<T>
13-
): void {
11+
export function setReplaneContext<T extends object>(client: ReplaneClient<T>): void {
1412
const value: ReplaneContextValue<T> = { client };
1513
setContext(REPLANE_CONTEXT_KEY, value);
1614
}
@@ -20,8 +18,7 @@ export function setReplaneContext<T extends Record<string, unknown>>(
2018
* @internal
2119
*/
2220
export function getReplaneContext<
23-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
24-
T extends Record<string, unknown> = any,
21+
T extends object = Record<string, unknown>,
2522
>(): ReplaneContextValue<T> {
2623
const context = getContext<ReplaneContextValue<T> | undefined>(REPLANE_CONTEXT_KEY);
2724
if (!context) {

packages/svelte/src/types.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ import type { Snippet } from "svelte";
44
/**
55
* Context value containing the Replane client
66
*/
7-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
export interface ReplaneContextValue<T extends Record<string, unknown> = any> {
7+
export interface ReplaneContextValue<T extends object = Record<string, unknown>> {
98
client: ReplaneClient<T>;
109
}
1110

1211
/**
1312
* Props for ReplaneContext when using a pre-created client.
1413
*/
15-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16-
export interface ReplaneContextWithClientProps<T extends Record<string, unknown> = any> {
14+
export interface ReplaneContextWithClientProps<T extends object = Record<string, unknown>> {
1715
/** Pre-created ReplaneClient instance */
1816
client: ReplaneClient<T>;
1917
/** Children snippet */
@@ -23,8 +21,7 @@ export interface ReplaneContextWithClientProps<T extends Record<string, unknown>
2321
/**
2422
* Props for ReplaneContext when letting it manage the client internally.
2523
*/
26-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27-
export interface ReplaneContextWithOptionsProps<T extends Record<string, unknown> = any> {
24+
export interface ReplaneContextWithOptionsProps<T extends object = Record<string, unknown>> {
2825
/** Options to create or restore the ReplaneClient */
2926
options: ReplaneClientOptions<T>;
3027
/** Children snippet */
@@ -44,15 +41,14 @@ export interface ReplaneContextWithOptionsProps<T extends Record<string, unknown
4441
loader?: Snippet;
4542
}
4643

47-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48-
export type ReplaneContextProps<T extends Record<string, unknown> = any> =
44+
export type ReplaneContextProps<T extends object = Record<string, unknown>> =
4945
| ReplaneContextWithClientProps<T>
5046
| ReplaneContextWithOptionsProps<T>;
5147

5248
/**
5349
* Type guard to check if props contain a pre-created client.
5450
*/
55-
export function hasClient<T extends Record<string, unknown>>(
51+
export function hasClient<T extends object>(
5652
props: ReplaneContextProps<T>
5753
): props is ReplaneContextWithClientProps<T> {
5854
return "client" in props && props.client !== undefined;
@@ -61,7 +57,7 @@ export function hasClient<T extends Record<string, unknown>>(
6157
/**
6258
* Type guard to check if props contain options (with or without snapshot).
6359
*/
64-
export function hasOptions<T extends Record<string, unknown>>(
60+
export function hasOptions<T extends object>(
6561
props: ReplaneContextProps<T>
6662
): props is ReplaneContextWithOptionsProps<T> {
6763
return "options" in props && props.options !== undefined;

packages/svelte/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Auto-generated - do not edit manually
2-
export const VERSION = "0.8.8";
2+
export const VERSION = "0.8.9";
33
export const DEFAULT_AGENT = `replane-svelte/${VERSION}`;

scripts/update-version.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/* eslint-disable no-undef */
12
import { readFileSync, writeFileSync } from "node:fs";
2-
import { dirname, join } from "node:path";
3+
import { join } from "node:path";
34

45
// Get the package directory from command line argument or current working directory
56
const packageDir = process.argv[2] || process.cwd();

0 commit comments

Comments
 (0)