Skip to content

Hierarchy Hotfix #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@radix-ui/react-toast": "^1.1.1",
"@radix-ui/react-toolbar": "^1.0.3",
"@reflect-blocks/figma-embed": "^0.0.5",
"@tree-/q": "^0.0.0",
"@tree-/q": "^0.0.1",
"@use-gesture/react": "^10.2.11",
"@visx/gradient": "^1.7.0",
"@visx/group": "^1.7.0",
Expand Down
18 changes: 10 additions & 8 deletions lib/tree-q/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tree-/q",
"version": "0.0.0",
"version": "0.0.1",
"description": "Tree query utility",
"homepage": "https://github.com/gridaco/code/tree/main/lib/tree-q",
"repository": "https://github.com/gridaco/code",
Expand All @@ -10,15 +10,17 @@
"scripts": {
"clean": "rm -rf dist",
"test": "jest",
"build": "tsc",
"prepack": "yarn run clean && yarn run build"
"build": "tsup",
"prepack": "yarn test && yarn clean && yarn build"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^18.11.18",
"jest": "^29.3.1",
"typescript": "^4.9.4",
"ts-jest": "^29.0.3"
"@types/jest": "^29.5.2",
"@types/node": "^20.3.3",
"jest": "^29.5.0",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6"
},
"publishConfig": {
"access": "public"
Expand All @@ -28,4 +30,4 @@
"LICENSE",
"dist"
]
}
}
7 changes: 6 additions & 1 deletion lib/tree-q/path/p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ interface Item {
function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
let path: string[] = [];

function search(node: T, currentPath: string[]): boolean {
function search(node: T | undefined | null, currentPath: string[]): boolean {
if (node == null) {
return false;
}

if (node.id === id) {
path = [...currentPath, node.id];
return true;
Expand All @@ -36,6 +40,7 @@ function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
return true;
}
}

return false;
}

Expand Down
11 changes: 9 additions & 2 deletions lib/tree-q/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2020",
"module": "commonjs",
"lib": ["es2015", "dom"],
"declaration": true,
Expand All @@ -10,5 +10,12 @@
"baseUrl": ".",
"typeRoots": ["node_modules/@types"]
},
"exclude": ["node_modules", "dist", "test", "**/*.spec.ts", "**/*.test.ts"]
"exclude": [
"node_modules",
"dist",
"test",
"**/*.spec.ts",
"**/*.test.ts",
"tsup.config.ts"
]
}
8 changes: 8 additions & 0 deletions lib/tree-q/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["index.ts"],
splitting: false,
sourcemap: true,
clean: true,
});
Loading