vite-plugin-server-actions 0.1.1 → 1.0.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.
@@ -1,57 +0,0 @@
1
- import fs from "fs/promises";
2
- import path from "path";
3
-
4
- const TODO_FILE = path.join(process.cwd(), "todos.json");
5
-
6
- async function readTodos() {
7
- try {
8
- const data = await fs.readFile(TODO_FILE, "utf8");
9
- return JSON.parse(data);
10
- } catch (error) {
11
- console.log(error);
12
- if (error.code === "ENOENT") {
13
- // File doesn't exist, return an empty array
14
- return [];
15
- }
16
- console.error("Error reading todos:", error);
17
- throw error;
18
- }
19
- }
20
-
21
- async function writeTodos(todos) {
22
- try {
23
- await fs.writeFile(TODO_FILE, JSON.stringify(todos, null, 2), "utf8");
24
- } catch (error) {
25
- console.error("Error writing todos:", error);
26
- throw error;
27
- }
28
- }
29
-
30
- export async function getTodos() {
31
- return await readTodos();
32
- }
33
-
34
- export async function addTodo(todo) {
35
- const todos = await readTodos();
36
- const newTodo = { id: Date.now(), text: todo.text, completed: false };
37
- todos.push(newTodo);
38
- await writeTodos(todos);
39
- return newTodo;
40
- }
41
-
42
- export async function updateTodo(id, updates) {
43
- const todos = await readTodos();
44
- const index = todos.findIndex((todo) => todo.id === id);
45
- if (index !== -1) {
46
- todos[index] = { ...todos[index], ...updates };
47
- await writeTodos(todos);
48
- return todos[index];
49
- }
50
- throw new Error("Todo not found");
51
- }
52
-
53
- export async function deleteTodo(id) {
54
- const todos = await readTodos();
55
- const newTodos = todos.filter((todo) => todo.id != id);
56
- await writeTodos(newTodos);
57
- }
File without changes
@@ -1,8 +0,0 @@
1
- import "./app.css";
2
- import App from "./App.svelte";
3
-
4
- const app = new App({
5
- target: document.getElementById("app"),
6
- });
7
-
8
- export default app;
@@ -1,7 +0,0 @@
1
- import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
2
-
3
- export default {
4
- // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
5
- // for more information about preprocessors
6
- preprocess: vitePreprocess(),
7
- };
@@ -1,27 +0,0 @@
1
- [
2
- {
3
- "id": 1,
4
- "text": "Finish writing documentation",
5
- "completed": false
6
- },
7
- {
8
- "id": 2,
9
- "text": "Implement authentication logic",
10
- "completed": true
11
- },
12
- {
13
- "id": 3,
14
- "text": "Design user interface",
15
- "completed": false
16
- },
17
- {
18
- "id": 4,
19
- "text": "Test server actions",
20
- "completed": true
21
- },
22
- {
23
- "id": 5,
24
- "text": "Deploy application",
25
- "completed": false
26
- }
27
- ]
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import { svelte } from "@sveltejs/vite-plugin-svelte";
3
- import serverActions from "../../src/index.js";
4
-
5
- // https://vitejs.dev/config/
6
- export default defineConfig({
7
- plugins: [
8
- svelte(),
9
- serverActions(),
10
- // ...
11
- ],
12
- });