@websimai/client-api-types 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Roman A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @websimai/client-api-types
2
+
3
+ Type declarations for `window.websim` object
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@websimai/client-api-types",
3
+ "version": "0.0.1",
4
+ "description": "Type declarations for `window.websim` object",
5
+ "author": "GameRoMan",
6
+ "license": "MIT",
7
+ "types": "./src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts"
11
+ },
12
+ "./client": {
13
+ "types": "./src/client.d.ts"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "publish": "bun publish --access public"
18
+ },
19
+ "keywords": [
20
+ "websim",
21
+ "client",
22
+ "api",
23
+ "types",
24
+ "typescript"
25
+ ],
26
+ "peerDependencies": {
27
+ "typescript": "^5.9.2"
28
+ }
29
+ }
@@ -0,0 +1,106 @@
1
+ export type ChatCompletionsMessageContent =
2
+ | { type: "text"; text: string }
3
+ | { type: "image_url"; image_url: { url: string } };
4
+
5
+ export type ChatCompletionsMessage = {
6
+ role: "assistant" | "user" | "system";
7
+ content: string | ChatCompletionsMessageContent[];
8
+ };
9
+
10
+ export type AnonymousWebsimUser = {
11
+ id: "1";
12
+ username: "anonymous";
13
+ avatar_url: null;
14
+ };
15
+
16
+ export type WebsimUser = {
17
+ id: string;
18
+ username: string;
19
+ avatar_url: `https://${string}/${string}` | null;
20
+ };
21
+
22
+ export type WebsimUserOrAnonymous = WebsimUser | AnonymousWebsimUser;
23
+
24
+ export interface WebsimClientAPI {
25
+ getUser(): Promise<WebsimUserOrAnonymous>;
26
+ /** Alias for getUser */
27
+ getCurrentUser(): Promise<WebsimUserOrAnonymous>;
28
+ /** @deprecated Use getBootstrap instead */
29
+ getDistinctId(): Promise<string>;
30
+ getBootstrap(): Promise<{
31
+ distinct_id: string;
32
+ session_id: string;
33
+ }>;
34
+ getCreatedBy(): Promise<WebsimUser>;
35
+ getCreator(): Promise<WebsimUser>;
36
+ getCurrentProject(): Promise<{
37
+ id: string;
38
+ title: string;
39
+ description: string;
40
+ }>;
41
+ getColorScheme(): Promise<"light" | "dark">;
42
+
43
+ postComment({
44
+ content,
45
+ credits,
46
+ }: {
47
+ content: string;
48
+ credits: number;
49
+ }): Promise<{} | { error: "User has not interacted with the page" }>;
50
+
51
+ addEventListener(
52
+ eventType: "comment:created",
53
+ callback: (data: any) => void
54
+ ): () => void;
55
+
56
+ upload: (file: File) => Promise<string>;
57
+
58
+ chat: {
59
+ completions: {
60
+ create: ({
61
+ messages,
62
+ json,
63
+ }: {
64
+ messages: ChatCompletionsMessage[];
65
+ json?: boolean;
66
+ }) => Promise<{ role: "assistant"; content: string }>;
67
+ };
68
+ };
69
+
70
+ imageGen: (args: {
71
+ prompt: string;
72
+ aspect_ratio?: string;
73
+ width?: number;
74
+ height?: number;
75
+ seed?: number;
76
+ transparent?: boolean;
77
+ }) => Promise<{ url: string }>;
78
+
79
+ textToSpeech: (args: {
80
+ text: string;
81
+ voice?: string;
82
+ voice_sample?: string;
83
+ }) => Promise<{ url: string }>;
84
+
85
+ experimental: {
86
+ v0: {
87
+ login: () => Promise<void>;
88
+
89
+ /**
90
+ * Saves the given htmlContent to a new websim site.
91
+ * @param htmlContent html content to save
92
+ * @returns object with id of the saved site
93
+ */
94
+ save(htmlContent: string): Promise<{ id: string }>;
95
+
96
+ /**
97
+ * Returns the HTML for the given siteId. Defaults to the current websimsite.
98
+ * @param siteId
99
+ * @returns HTML for the given siteId.
100
+ */
101
+ getHTML(siteId?: string): Promise<string>;
102
+ };
103
+ };
104
+
105
+ internal_only_experimental: {};
106
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { WebsimClientAPI } from "./client";
2
+
3
+ declare global {
4
+ interface Window {
5
+ readonly websim: WebsimClientAPI;
6
+ }
7
+
8
+ declare const websim: WebsimClientAPI;
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "esnext",
6
+ "module": "preserve",
7
+ "moduleDetection": "force",
8
+
9
+ // Bundler mode
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "noEmit": true,
13
+
14
+ // Max strictness
15
+ "strict": true,
16
+ "skipLibCheck": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noUncheckedIndexedAccess": true,
19
+ "noImplicitOverride": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noPropertyAccessFromIndexSignature": true,
23
+ "noImplicitAny": true,
24
+ "strictNullChecks": true,
25
+ "forceConsistentCasingInFileNames": true,
26
+ "verbatimModuleSyntax": true
27
+ }
28
+ }