use-vibes 0.2.6 → 0.3.0

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/README.md CHANGED
@@ -1,304 +1,51 @@
1
- # useVibes - App Gen Anywhere
1
+ # use-vibes
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/use-vibes.svg)](https://www.npmjs.com/package/use-vibes)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
6
- useVibes is a vanilla browser TypeScript module that transforms any DOM element into an AI-augmented micro-app using an HTML inject-first approach. It leverages the current page's HTML context to create a rich environment for dynamic content generation, powered by the call-ai library.
7
-
8
- ---
9
-
10
- ## Overview
11
-
12
- - **Purpose**: Transform any DOM element into a self-contained, AI-driven micro-app by extracting and utilizing the page's inherent state.
13
- - **Core Features**:
14
- - **Inject-First Approach**: Operates directly on the existing page by capturing document.body.innerHTML, the associated CSS, and a visual snapshot via html2canvas.
15
- - **Context-Aware Transformation**: Uses the page's current state as a germ to generate dynamic content.
16
- - **Promise-Based API**: Returns an app instance once the micro-app is injected.
17
- - **Ongoing Chat Interface**: The app instance provides a chat interface to facilitate live, interactive sessions.
18
-
19
- ---
3
+ A lightweight library that transforms any DOM element into an AI-powered micro-app.
20
4
 
21
5
  ## Installation
22
6
 
23
- ### npm
24
-
25
- ```bash
26
- npm install use-vibes
27
- ```
28
-
29
- ### yarn
30
-
31
- ```bash
32
- yarn add use-vibes
33
- ```
34
-
35
- ### pnpm
36
-
37
7
  ```bash
38
8
  pnpm add use-vibes
39
9
  ```
40
10
 
41
- ## Basic Usage
42
-
43
- ```javascript
44
- import { useVibes } from 'use-vibes';
45
-
46
- // Set the API key for call-ai (required)
47
- window.CALLAI_API_KEY = 'your-api-key-here';
48
-
49
- // Get target element (can be a CSS selector string or DOM element)
50
- const target = document.getElementById('my-app-container');
51
-
52
- // Apply useVibes to the target with a prompt
53
- useVibes(target, {
54
- prompt: 'Create a beautiful hello world message with blue styling'
55
- }).then(app => {
56
- console.log('App created:', app);
57
- }).catch(error => {
58
- console.error('Error creating app:', error);
59
- });
60
- ```
61
-
62
- ### Return Value
63
-
64
- The function returns a Promise that resolves to an app instance with the following properties:
65
-
66
- - **container**: The DOM element into which the micro-app has been injected
67
- - **database**: An optional property for state management (may be undefined)
68
-
69
- ## Browser Usage
70
-
71
- ### IIFE Bundle
72
-
73
- If you want to use useVibes directly in the browser without a build step, you can use the IIFE bundle:
74
-
75
- ```html
76
- <script src="https://unpkg.com/use-vibes@latest/lib/use-vibes.iife.js"></script>
77
- <script>
78
- // Set API key
79
- window.CALLAI_API_KEY = 'your-api-key-here';
80
-
81
- // Now the global useVibes function is available
82
- useVibes(document.getElementById('my-element'), {
83
- prompt: 'Create a beautiful hello world message'
84
- });
85
- </script>
86
- ```
87
-
88
- ### Bookmarklet
89
-
90
- The useVibes package also includes a bookmarklet that allows you to test useVibes on any website:
91
-
92
- 1. After installing the package, you'll find a `bookmarklet.html` file in the `dist` directory
93
- 2. Open this file in your browser
94
- 3. Drag the bookmarklet link to your bookmarks bar
95
- 4. Navigate to any website, click the bookmarklet, then click on any element you want to enhance
96
- 5. Enter your prompt when prompted
97
-
98
- You'll need to edit the bookmarklet to include your API key. See the HTML file for detailed instructions.
99
-
100
- ### Example
101
-
102
- ```javascript
103
- import { useVibes } from 'useVibes';
104
-
105
- useVibes("#app", { prompt: "create a todo list with emojis" })
106
- .then((app) => {
107
- console.log("Micro-app created successfully!");
108
-
109
- // Log the container element
110
- console.log("Injected into:", app.container);
111
-
112
- // If a database is later configured, it can be accessed via app.database
113
- if (app.database) {
114
- console.log("Database configured as:", app.database);
115
- }
116
-
117
- // Use the chat interface to send a message to the AI
118
- app.chat.sendMessage("Hello, vibe!")
119
- .then(() => console.log("Message sent successfully"))
120
- .catch((err) => console.error("Error sending message:", err));
121
- })
122
- .catch((error) => {
123
- console.error("Error during injection:", error);
124
- });
125
- ```
126
-
127
- ---
128
-
129
- ## Quick Start
11
+ ## Components
130
12
 
131
- 1. **Include the Module**: Import or bundle useVibes as an ESM module in your project.
132
- 2. **Prepare Your HTML**: Ensure your page includes a target element (e.g., `<div id="app"></div>`) for the micro-app.
133
- 3. **Initialize useVibes**: Call useVibes with your target and configuration. The module will capture the page's state, transform it based on your prompt, and inject the resulting micro-app into your target element.
13
+ ### ImgGen
134
14
 
135
- ---
15
+ A React component for generating images with AI:
136
16
 
137
- ## Architecture Overview
17
+ ```jsx
18
+ import { ImgGen } from 'use-vibes';
138
19
 
139
- - **Purpose**: Build a lightweight, agentic editor that transforms any div into a dynamic micro-app. The module leverages a minimal core—using Fireproof for local persistence and callAi for AI interactions—while preserving the page's inherent structure and style.
140
- - **Architecture**:
141
- - **HTML Injection-First**: The library is injected into a page and operates on the current DOM state.
142
- - **Vanilla Browser Module**: Written in TypeScript and built as an ESM module suitable for distribution via esm.sh/jsr style.
143
-
144
- ---
145
-
146
- ## Testing
147
-
148
- The useVibes library includes a comprehensive testing suite to ensure functionality across different browsers and use cases.
149
-
150
- ### Browser Testing
151
-
152
- Browser tests are implemented using Playwright and run on Chrome, Firefox, and WebKit (Safari). The test infrastructure uses a custom build process to create a test bundle with mocked dependencies, allowing tests to run without making actual API calls.
153
-
154
- ```bash
155
- # Run browser tests
156
- pnpm test:browser
20
+ function MyComponent() {
21
+ return (
22
+ <div>
23
+ <ImgGen prompt="A sunset over mountains" />
24
+ </div>
25
+ );
26
+ }
157
27
  ```
158
28
 
159
- This command will:
160
- 1. Build a test-specific bundle using the `build-browser-test.js` script
161
- 2. Set up browser mocks for all three browser engines
162
- 3. Run the Playwright tests with proper reporting
29
+ #### Props
163
30
 
164
- ### Unit Testing
31
+ - `prompt`: Text prompt for image generation (required)
32
+ - `options`: Options for image generation (optional)
33
+ - `className`: CSS class name for the image element (optional)
34
+ - `alt`: Alt text for the image (defaults to prompt)
165
35
 
166
- ```bash
167
- # Run unit tests
168
- pnpm test:unit
169
- ```
170
-
171
- ### Linting and TypeScript Validation
36
+ ## Development
172
37
 
173
38
  ```bash
174
- # Check types
175
- pnpm typecheck
39
+ # Install dependencies
40
+ pnpm install
176
41
 
177
- # Run linter
178
- pnpm lint
42
+ # Build the library
43
+ pnpm build
179
44
 
180
- # Run linter with auto-fixes
181
- pnpm lint --fix
45
+ # Run tests
46
+ pnpm test
182
47
  ```
183
48
 
184
- ## Directory Structure
185
-
186
- - **src/**: Contains the source code for the useVibes library.
187
- - **fixtures/**: A collection of HTML challenge files. These fixtures serve as test cases for validating that useVibes can handle a variety of page structures.
188
- - **tests/**: Test suites including browser and unit tests.
189
- - **browser/**: Playwright browser tests with mock implementations.
190
- - **unit/**: Unit tests for core functionality.
191
- - **scripts/**: Build scripts and utilities.
192
- - **docs/**: Documentation directory which includes:
193
- - **llms.txt**: A text file specifying the details and technical context for LLM integrations and other project guidelines.
194
-
195
- ---
196
-
197
- ## Prerequisites
198
-
199
- - Node.js (v14 or higher)
200
- - pnpm package manager
201
- - A modern web browser for testing
202
-
203
- ---
204
-
205
- ## Getting Started
206
-
207
- 1. **Clone the Repository**:
208
- ```
209
- git clone https://github.com/fireproof-storage/use-vibes.git
210
- cd use-vibes
211
- ```
212
-
213
- 2. **Install Dependencies**:
214
- ```
215
- pnpm install
216
- ```
217
-
218
- 3. **Build the Project**:
219
- The project is configured to compile the TypeScript source into an ESM module suitable for browser use.
220
- ```
221
- pnpm run build
222
- ```
223
-
224
- ---
225
-
226
- ## Testing
227
-
228
- ### Fixture Loading Test
229
-
230
- Ensure that HTML fixtures load correctly:
231
- 1. Open a test HTML file from the fixtures/ directory in your browser.
232
- 2. Verify that the page loads as expected without any library interference.
233
-
234
- ### Library Injection Test
235
-
236
- Verify that useVibes loads and executes a basic operation:
237
- 1. Create a simple test page that includes the built useVibes module.
238
- 2. Use the library to inject a "hello world" string into a target element. For example:
239
-
240
- ```html
241
- <!DOCTYPE html>
242
- <html lang="en">
243
- <head>
244
- <meta charset="UTF-8">
245
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
246
- <title>useVibes Test</title>
247
- <!-- Direct ESM import from source during development -->
248
- <script type="module">
249
- // Import directly from source files
250
- import useVibe from './src/index.js';
251
- </script>
252
- </head>
253
- <body>
254
- <div id="vibe-target"></div>
255
- <script type="module">
256
- // Direct import
257
- import useVibe from './src/index.js';
258
-
259
- // Create a new vibe
260
- const vibe = useVibe('HelloWorld');
261
-
262
- // Basic injection test
263
- document.querySelector("#vibe-target").innerHTML = vibe.describe();
264
- </script>
265
- </body>
266
- </html>
267
- ```
268
-
269
- 3. Open this page in your browser and confirm that "hello world" is injected into the target element.
270
-
271
- ---
272
-
273
- ## Build and Deployment
274
-
275
- - **Buildless ESM Approach**: This project uses a modern buildless ESM approach. TypeScript source files are directly imported during development, and TypeScript compiler is only used for type checking and generating type definitions. This avoids complex bundling processes while leveraging the native ESM support in modern browsers and Node.js environments.
276
-
277
- ```json
278
- "scripts": {
279
- "build": "tsc",
280
- "typecheck": "tsc --noEmit"
281
- }
282
- ```
283
-
284
- - **Deployment**: Direct imports from source files are supported during development. For production, TypeScript is compiled to JavaScript while maintaining ESM imports. The package can be published to npm or JSR for easy consumption via ESM imports.
285
-
286
- ---
287
-
288
- ## Next Steps
289
-
290
- 1. **Vibe Check**: After completing the initial tests, review the results and gather feedback.
291
- 2. **Iterate**: Use feedback to refine functionality and integration.
292
- 3. **Expand**: Continue to develop additional features and tests, integrating further capabilities such as Fireproof, callAi, and more advanced micro-app interactions.
293
-
294
- ---
295
-
296
49
  ## License
297
50
 
298
- This project is open source. See the LICENSE file for details.
299
-
300
- ---
301
-
302
- ## Contact
303
-
304
- For questions, feedback, or contributions, please open an issue on the repository or contact the maintainers.
51
+ MIT
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { ImageGenOptions, ImageResponse } from 'call-ai';
3
+ export interface ImgGenProps {
4
+ /** Text prompt for image generation (required) */
5
+ prompt: string;
6
+ /** Options for image generation (optional) */
7
+ options?: ImageGenOptions;
8
+ /** Callback to retrieve cached data before load (optional) */
9
+ beforeLoad?: (key: string) => ImageResponse | null | Promise<ImageResponse | null>;
10
+ /** Callback when image data is loaded (optional) */
11
+ onLoad?: (response: ImageResponse) => void;
12
+ /** CSS class name for the image element (optional) */
13
+ className?: string;
14
+ /** Alt text for the image (defaults to prompt) */
15
+ alt?: string;
16
+ }
17
+ /**
18
+ * React component for generating images with call-ai's imageGen
19
+ * Provides automatic caching, reactive updates, and placeholder handling
20
+ */
21
+ export declare const ImgGen: React.FC<ImgGenProps>;
22
+ export default ImgGen;
@@ -0,0 +1,168 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { imageGen } from 'call-ai';
3
+ /**
4
+ * Hash function to create a key from the prompt string
5
+ * @param prompt The prompt string to hash
6
+ * @returns A string hash of the prompt
7
+ */
8
+ function hashPrompt(prompt) {
9
+ let hash = 0;
10
+ for (let i = 0; i < prompt.length; i++) {
11
+ const char = prompt.charCodeAt(i);
12
+ hash = (hash << 5) - hash + char;
13
+ hash = hash & hash; // Convert to 32bit integer
14
+ }
15
+ return hash.toString(16);
16
+ }
17
+ // Default cache implementation using localStorage
18
+ const defaultCacheImpl = {
19
+ get: (key) => {
20
+ try {
21
+ const data = localStorage.getItem(`imggen-${key}`);
22
+ return data ? JSON.parse(data) : null;
23
+ }
24
+ catch (e) {
25
+ console.error('Error retrieving from ImgGen cache', e);
26
+ return null;
27
+ }
28
+ },
29
+ set: (key, value) => {
30
+ try {
31
+ localStorage.setItem(`imggen-${key}`, JSON.stringify(value));
32
+ }
33
+ catch (e) {
34
+ console.error('Error storing in ImgGen cache', e);
35
+ }
36
+ },
37
+ };
38
+ /**
39
+ * React component for generating images with call-ai's imageGen
40
+ * Provides automatic caching, reactive updates, and placeholder handling
41
+ */
42
+ export const ImgGen = ({ prompt, options = {}, beforeLoad, onLoad, className = '', alt, }) => {
43
+ const [imageData, setImageData] = useState(null);
44
+ const [loading, setLoading] = useState(false);
45
+ const [progress, setProgress] = useState(0);
46
+ const [error, setError] = useState(null);
47
+ const progressTimerRef = useRef(null);
48
+ const promptKey = hashPrompt(prompt);
49
+ const size = options?.size || '1024x1024';
50
+ const [width, height] = size.split('x').map(Number);
51
+ // Reset state when prompt or options change
52
+ useEffect(() => {
53
+ setImageData(null);
54
+ setError(null);
55
+ setProgress(0);
56
+ // Clear any existing progress timer
57
+ if (progressTimerRef.current) {
58
+ clearInterval(progressTimerRef.current);
59
+ progressTimerRef.current = null;
60
+ }
61
+ // Set up progress timer simulation (45 seconds to completion)
62
+ // This is just for visual feedback and doesn't reflect actual progress
63
+ const timer = setInterval(() => {
64
+ setProgress((prev) => {
65
+ const next = prev + (100 - prev) * 0.05;
66
+ return next > 99 ? 99 : next;
67
+ });
68
+ }, 1000);
69
+ progressTimerRef.current = timer;
70
+ // Cleanup on unmount or when dependencies change
71
+ return () => {
72
+ if (progressTimerRef.current) {
73
+ clearInterval(progressTimerRef.current);
74
+ }
75
+ };
76
+ }, [prompt, JSON.stringify(options)]);
77
+ // Generate the image when prompt or options change
78
+ useEffect(() => {
79
+ let isMounted = true;
80
+ // Don't generate image if prompt is falsy
81
+ if (!prompt) {
82
+ setLoading(false);
83
+ return;
84
+ }
85
+ const generateImage = async () => {
86
+ try {
87
+ setLoading(true);
88
+ // Try to get from cache via the beforeLoad callback if provided
89
+ let data = null;
90
+ if (beforeLoad) {
91
+ data = await beforeLoad(promptKey);
92
+ }
93
+ else {
94
+ // Use default cache implementation
95
+ data = defaultCacheImpl.get(promptKey);
96
+ }
97
+ // If no data in cache, generate new image
98
+ if (!data) {
99
+ // Use the actual imageGen function from call-ai
100
+ data = await imageGen(prompt, options);
101
+ // Cache the result using default implementation
102
+ // if beforeLoad wasn't provided
103
+ if (!beforeLoad) {
104
+ defaultCacheImpl.set(promptKey, data);
105
+ }
106
+ }
107
+ // Update state with the image data
108
+ if (isMounted && data) {
109
+ setImageData(data.data[0].b64_json);
110
+ setProgress(100);
111
+ // Clear progress timer
112
+ if (progressTimerRef.current) {
113
+ clearInterval(progressTimerRef.current);
114
+ progressTimerRef.current = null;
115
+ }
116
+ // Call onLoad callback if provided
117
+ if (onLoad) {
118
+ onLoad(data);
119
+ }
120
+ }
121
+ }
122
+ catch (err) {
123
+ if (isMounted) {
124
+ setError(err instanceof Error ? err : new Error(String(err)));
125
+ }
126
+ }
127
+ finally {
128
+ if (isMounted) {
129
+ setLoading(false);
130
+ }
131
+ }
132
+ };
133
+ generateImage();
134
+ return () => {
135
+ isMounted = false;
136
+ };
137
+ }, [prompt, JSON.stringify(options), promptKey, beforeLoad, onLoad]);
138
+ // Render placeholder while loading
139
+ if (loading || !imageData) {
140
+ return (React.createElement("div", { className: `img-gen-placeholder ${className}`, style: {
141
+ width: `${width}px`,
142
+ height: `${height}px`,
143
+ backgroundColor: '#f0f0f0',
144
+ position: 'relative',
145
+ overflow: 'hidden',
146
+ display: 'flex',
147
+ alignItems: 'center',
148
+ justifyContent: 'center',
149
+ } },
150
+ React.createElement("div", { style: {
151
+ position: 'absolute',
152
+ bottom: 0,
153
+ left: 0,
154
+ height: '4px',
155
+ width: `${progress}%`,
156
+ backgroundColor: '#0066cc',
157
+ transition: 'width 0.3s ease-in-out',
158
+ } }),
159
+ React.createElement("div", { style: { textAlign: 'center', padding: '10px' } }, error ? (React.createElement("div", { className: "img-gen-error" },
160
+ React.createElement("p", null,
161
+ "Error: ",
162
+ error.message))) : !prompt ? (React.createElement("div", null, "Waiting for prompt")) : (React.createElement("div", null, "Generating image...")))));
163
+ }
164
+ // Render the generated image
165
+ return (React.createElement("img", { src: `data:image/png;base64,${imageData}`, className: `img-gen ${className}`, alt: alt || prompt, width: width, height: height, style: { maxWidth: '100%' } }));
166
+ };
167
+ export default ImgGen;
168
+ //# sourceMappingURL=ImgGen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImgGen.js","sourceRoot":"","sources":["../../src/components/ImgGen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,O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 import { imageGen, type ImageGenOptions, type ImageResponse } from 'call-ai';
2
+ export { imageGen, type ImageGenOptions, type ImageResponse };
3
+ export { default as ImgGen } from './components/ImgGen';
4
+ export type { ImgGenProps } from './components/ImgGen';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // Re-export specific functions and types from call-ai
2
+ import { imageGen } from 'call-ai';
3
+ export { imageGen };
4
+ // Export ImgGen component
5
+ export { default as ImgGen } from './components/ImgGen';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAA4C,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAA4C,CAAC;AAE9D,0BAA0B;AAC1B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,21 @@
1
1
  {
2
2
  "name": "use-vibes",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Transform any DOM element into an AI-powered micro-app",
6
6
  "main": "dist/index.js",
7
- "browser": "dist/index.js",
8
7
  "module": "dist/index.js",
9
8
  "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
10
19
  "keywords": [
11
20
  "ai",
12
21
  "dom",
@@ -18,61 +27,29 @@
18
27
  ],
19
28
  "author": "",
20
29
  "license": "MIT",
21
- "files": [
22
- "dist"
23
- ],
30
+ "dependencies": {
31
+ "call-ai": "^0.10.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
35
+ },
24
36
  "devDependencies": {
25
- "@playwright/test": "^1.41.2",
26
- "@rollup/plugin-commonjs": "^28.0.3",
27
- "@rollup/plugin-node-resolve": "^16.0.1",
28
- "@rollup/plugin-typescript": "^12.1.2",
29
37
  "@testing-library/jest-dom": "^6.6.3",
30
38
  "@testing-library/react": "^16.3.0",
31
- "@types/jsdom": "^21.1.7",
32
- "@types/node": "^20.11.19",
33
- "@types/react": "^18.2.0",
34
- "@typescript-eslint/eslint-plugin": "^7.0.1",
35
- "@typescript-eslint/parser": "^7.0.1",
36
- "esbuild": "^0.25.1",
39
+ "@types/react": "^19.1.0",
40
+ "@vitejs/plugin-react": "^4.4.1",
37
41
  "eslint": "^8.56.0",
38
- "eslint-config-prettier": "^10.1.1",
39
- "eslint-plugin-prettier": "^5.2.5",
40
- "jsdom": "^26.0.0",
41
- "playwright": "^1.41.2",
42
- "prettier": "^3.5.3",
43
- "react": "^19.1.0",
44
- "rollup": "^4.38.0",
45
- "rollup-plugin-terser": "^7.0.2",
46
- "terser": "^5.39.0",
42
+ "jsdom": "^26.1.0",
43
+ "rimraf": "^5.0.5",
47
44
  "typescript": "^5.3.3",
48
- "vite": "^5.1.4",
49
45
  "vitest": "^1.2.2"
50
46
  },
51
- "dependencies": {
52
- "call-ai": "^0.10.0"
53
- },
54
- "peerDependencies": {
55
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
56
- },
57
47
  "scripts": {
58
48
  "build": "tsc",
59
- "build:browser": "node scripts/build-browser.js",
60
- "build:browser:test": "node scripts/build-browser-test.js",
61
- "build:bookmarklet": "node scripts/generate-bookmarklet.js",
62
- "build:all": "npm run build && npm run build:browser && npm run build:bookmarklet",
49
+ "lint": "eslint src --ext .ts,.tsx",
63
50
  "test": "vitest run",
64
51
  "test:watch": "vitest",
65
- "test:browser": "npm run build:browser:test && playwright test --reporter=line",
66
- "test:browser:headed": "npm run build:browser:test && playwright test --headed --reporter=line",
67
- "test:browser:debug": "npm run build:browser:test && playwright test --debug --reporter=line",
68
- "lint": "eslint --ext .js,.ts,.tsx src/ tests/ scripts/",
69
- "lint:fix": "eslint --ext .js,.ts,.tsx --fix src/ tests/ scripts/",
70
- "format": "prettier --write 'src/**/*.{js,ts,tsx}' 'tests/**/*.{js,ts,tsx}' 'scripts/**/*.js'",
71
- "typecheck": "tsc --noEmit",
72
- "validate": "npm run typecheck && npm run test && npm run test:browser && npm run lint",
73
- "fix": "npm run lint:fix && npm run format",
74
- "check": "npm run validate && npm run fix",
75
- "prerelease": "npm run validate",
76
- "serve": "vite fixtures --port 3000"
52
+ "clean": "rimraf dist",
53
+ "typecheck": "tsc --noEmit"
77
54
  }
78
55
  }