Skip to content

Commit 7b4fd8f

Browse files
Merge pull request #220 from gridaco/tree-utils
Hierarchy Hotfix
2 parents a3ac319 + 21fb175 commit 7b4fd8f

File tree

7 files changed

+954
-407
lines changed

7 files changed

+954
-407
lines changed

editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@radix-ui/react-toast": "^1.1.1",
3636
"@radix-ui/react-toolbar": "^1.0.3",
3737
"@reflect-blocks/figma-embed": "^0.0.5",
38-
"@tree-/q": "^0.0.0",
38+
"@tree-/q": "^0.0.1",
3939
"@use-gesture/react": "^10.2.11",
4040
"@visx/gradient": "^1.7.0",
4141
"@visx/group": "^1.7.0",

lib/tree-q/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tree-/q",
3-
"version": "0.0.0",
3+
"version": "0.0.1",
44
"description": "Tree query utility",
55
"homepage": "https://github.com/gridaco/code/tree/main/lib/tree-q",
66
"repository": "https://github.com/gridaco/code",
@@ -10,15 +10,17 @@
1010
"scripts": {
1111
"clean": "rm -rf dist",
1212
"test": "jest",
13-
"build": "tsc",
14-
"prepack": "yarn run clean && yarn run build"
13+
"build": "tsup",
14+
"prepack": "yarn test && yarn clean && yarn build"
1515
},
1616
"dependencies": {},
1717
"devDependencies": {
18-
"@types/node": "^18.11.18",
19-
"jest": "^29.3.1",
20-
"typescript": "^4.9.4",
21-
"ts-jest": "^29.0.3"
18+
"@types/jest": "^29.5.2",
19+
"@types/node": "^20.3.3",
20+
"jest": "^29.5.0",
21+
"ts-jest": "^29.1.1",
22+
"tsup": "^7.1.0",
23+
"typescript": "^5.1.6"
2224
},
2325
"publishConfig": {
2426
"access": "public"
@@ -28,4 +30,4 @@
2830
"LICENSE",
2931
"dist"
3032
]
31-
}
33+
}

lib/tree-q/path/p.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ interface Item {
2020
function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
2121
let path: string[] = [];
2222

23-
function search(node: T, currentPath: string[]): boolean {
23+
function search(node: T | undefined | null, currentPath: string[]): boolean {
24+
if (node == null) {
25+
return false;
26+
}
27+
2428
if (node.id === id) {
2529
path = [...currentPath, node.id];
2630
return true;
@@ -36,6 +40,7 @@ function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
3640
return true;
3741
}
3842
}
43+
3944
return false;
4045
}
4146

lib/tree-q/tsconfig.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "es2020",
44
"module": "commonjs",
55
"lib": ["es2015", "dom"],
66
"declaration": true,
@@ -10,5 +10,12 @@
1010
"baseUrl": ".",
1111
"typeRoots": ["node_modules/@types"]
1212
},
13-
"exclude": ["node_modules", "dist", "test", "**/*.spec.ts", "**/*.test.ts"]
13+
"exclude": [
14+
"node_modules",
15+
"dist",
16+
"test",
17+
"**/*.spec.ts",
18+
"**/*.test.ts",
19+
"tsup.config.ts"
20+
]
1421
}

lib/tree-q/tsup.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["index.ts"],
5+
splitting: false,
6+
sourcemap: true,
7+
clean: true,
8+
});

0 commit comments

Comments
 (0)