Skip to content

Commit cf043b0

Browse files
committed
fix: copy not working
1 parent 20813f9 commit cf043b0

File tree

8 files changed

+11
-935
lines changed

8 files changed

+11
-935
lines changed

eslint.config.js

Lines changed: 0 additions & 75 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,11 @@
99
"build:preview": "pnpm build:packages && pnpm -F preview build",
1010
"check": "pnpm --parallel check",
1111
"format": "pnpm --parallel format",
12-
"lint": "pnpm --parallel format:check && eslint ."
12+
"format:check": "pnpm --parallel format:check"
1313
},
1414
"devDependencies": {
1515
"@changesets/cli": "^2.28.1",
16-
"@eslint/js": "^9.21.0",
17-
"eslint": "^9.21.0",
18-
"eslint-plugin-svelte": "^3.0.2",
19-
"globals": "^16.0.0",
20-
"playwright": "^1.50.1",
21-
"typescript": "^5.8.2",
22-
"typescript-eslint": "^8.26.0"
16+
"playwright": "^1.50.1"
2317
},
2418
"pnpm": {
2519
"onlyBuiltDependencies": [
@@ -28,4 +22,4 @@
2822
]
2923
},
3024
"packageManager": "[email protected]+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af"
31-
}
25+
}

packages/svelte-file-tree/src/lib/components/Tree/state.svelte.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,23 @@ export function createTreeState<TData extends FileTreeNodeData>({
487487
}
488488

489489
function copyNode(node: FileTreeNode<TData>): FileTreeNode<TData> {
490+
if (DEV && Object.getPrototypeOf(node.data) !== Object.prototype) {
491+
throw new Error(`Expected the data property to be a POJO`);
492+
}
493+
490494
const id = generateCopyId();
495+
const data = $state.snapshot(node.data) as TData;
491496
switch (node.type) {
492497
case "file": {
493498
return new FileNode({
494499
id,
495-
data: structuredClone(node.data),
500+
data,
496501
});
497502
}
498503
case "folder": {
499504
return new FolderNode({
500505
id,
501-
data: structuredClone(node.data),
506+
data,
502507
children: node.children.map(copyNode),
503508
});
504509
}

packages/svelte-file-tree/src/lib/components/TreeItem/TreeItem.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
const navigate = down ? treeState.getNextItem : treeState.getPreviousItem;
130130
const shouldSelectMultiple = event.shiftKey && isControlOrMeta(event);
131131
const maxScrollDistance = Math.min(
132-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
133132
document.getElementById(treeState.id())!.clientHeight,
134133
document.documentElement.clientHeight,
135134
);
@@ -201,14 +200,12 @@
201200
break;
202201
}
203202
case "End": {
204-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
205203
let last = treeState.tree().children.at(-1)!;
206204
while (
207205
last.type === "folder" &&
208206
treeState.expandedIds().has(last.id) &&
209207
last.children.length !== 0
210208
) {
211-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
212209
last = last.children.at(-1)!;
213210
}
214211

packages/svelte-file-tree/src/lib/internal/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { EventHandler } from "svelte/elements";
22

33
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform#examples
44
export function isControlOrMeta(event: KeyboardEvent | MouseEvent): boolean {
5-
// eslint-disable-next-line @typescript-eslint/no-deprecated
65
if (navigator.platform.startsWith("Mac") || navigator.platform === "iPhone") {
76
return event.metaKey;
87
}

packages/svelte-file-tree/svelte.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ export default {
88
config(config) {
99
return {
1010
...config,
11-
include: [
12-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
13-
...config.include,
14-
"../vitest.workspace.ts",
15-
],
11+
include: [...config.include, "../vitest.workspace.ts"],
1612
};
1713
},
1814
},

0 commit comments

Comments
 (0)