power-compass 0.0.1-alpha.1 → 0.0.1-alpha.2
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/dist/power-compass.cjs.js +1 -0
- package/dist/power-compass.es.d.ts +1 -0
- package/dist/power-compass.es.js +2299 -0
- package/package.json +5 -5
- package/.eslintrc.json +0 -6
- package/index.html +0 -13
- package/jest.config.js +0 -11
- package/src/components/context.ts +0 -9
- package/src/components/hooks/useCursor.ts +0 -38
- package/src/components/hooks/useDebounce.ts +0 -14
- package/src/components/hooks/useShortcut.ts +0 -18
- package/src/http/fetch.ts +0 -30
- package/src/http/index.ts +0 -1
- package/src/index.ts +0 -5
- package/src/menu/clientMenu.ts +0 -56
- package/src/menu/fetchMenu.spec.ts +0 -183
- package/src/menu/fetchMenu.ts +0 -42
- package/src/menu/index.ts +0 -2
- package/src/menu/transformations.ts +0 -48
- package/src/menu/types.ts +0 -19
- package/src/menu/useCompassMenu.spec.tsx +0 -173
- package/src/menu/useCompassMenu.ts +0 -67
- package/src/search/engine.ts +0 -109
- package/src/search/index.ts +0 -1
- package/src/search/sources.ts +0 -232
- package/src/search/types.ts +0 -39
- package/src/search/useSearch.ts +0 -84
- package/src/tasks/index.ts +0 -1
- package/src/tasks/types.ts +0 -7
- package/src/tasks/useLocalStorage.ts +0 -31
- package/src/tasks/useNotificationCenter.ts +0 -69
- package/tsconfig.app.json +0 -28
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -34
- package/vitest.config.ts +0 -8
- package/vitest.fetch-mock.ts +0 -7
package/src/tasks/types.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState } from "react"
|
|
2
|
-
|
|
3
|
-
const loadFromStorage = <T>(key: string, initialValue: T) => {
|
|
4
|
-
try {
|
|
5
|
-
const item = window.localStorage.getItem(key)
|
|
6
|
-
return item ? JSON.parse(item) : initialValue
|
|
7
|
-
} catch (error) {
|
|
8
|
-
return initialValue
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const updateStorage = <T>(key: string, value: T) => {
|
|
13
|
-
try {
|
|
14
|
-
window.localStorage.setItem(key, JSON.stringify(value))
|
|
15
|
-
} catch (error) {
|
|
16
|
-
console.debug(error) // eslint-disable-line no-console
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const useLocalStorage = <T>(key: string, initialValue: T) => {
|
|
21
|
-
const [stateValue, updateStateValue] = useState(() =>
|
|
22
|
-
loadFromStorage(key, initialValue),
|
|
23
|
-
)
|
|
24
|
-
const setValue = (value: T) => {
|
|
25
|
-
updateStateValue(value)
|
|
26
|
-
updateStorage(key, value)
|
|
27
|
-
}
|
|
28
|
-
const reset = () => setValue(initialValue)
|
|
29
|
-
|
|
30
|
-
return [stateValue, setValue, reset]
|
|
31
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react"
|
|
2
|
-
|
|
3
|
-
import { fetchBackend } from "../http/fetch"
|
|
4
|
-
|
|
5
|
-
import { type Notification } from "./types"
|
|
6
|
-
import { useLocalStorage } from "./useLocalStorage"
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
contextId?: string | number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface NotificationProvider {
|
|
13
|
-
label: string
|
|
14
|
-
notifications: Notification[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface UseNotificationCenterReturn {
|
|
18
|
-
notifications: Notification[]
|
|
19
|
-
loading: boolean
|
|
20
|
-
error: Error | null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useNotificationCenter({
|
|
24
|
-
contextId,
|
|
25
|
-
}: Props): UseNotificationCenterReturn {
|
|
26
|
-
const [notifications, updateNotifications] = useLocalStorage(
|
|
27
|
-
"notification_center.notifications",
|
|
28
|
-
[],
|
|
29
|
-
)
|
|
30
|
-
const [loading, setLoading] = useState(true)
|
|
31
|
-
const [error, setError] = useState<Error | null>(null)
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!contextId) {
|
|
35
|
-
setLoading(false)
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const fetchNotifications = async (): Promise<void> => {
|
|
40
|
-
try {
|
|
41
|
-
setLoading(true)
|
|
42
|
-
setError(null)
|
|
43
|
-
|
|
44
|
-
const data = await fetchBackend<NotificationProvider[]>(
|
|
45
|
-
"compass",
|
|
46
|
-
String(contextId),
|
|
47
|
-
"notifications",
|
|
48
|
-
{},
|
|
49
|
-
)
|
|
50
|
-
const fetchedNotifications: Notification[] = data
|
|
51
|
-
.map((provider: NotificationProvider) => provider.notifications)
|
|
52
|
-
.flat()
|
|
53
|
-
.map((notification: any) => ({
|
|
54
|
-
...notification,
|
|
55
|
-
createdAt: notification.date || notification.createdAt,
|
|
56
|
-
}))
|
|
57
|
-
updateNotifications(fetchedNotifications)
|
|
58
|
-
} catch (err) {
|
|
59
|
-
setError(err instanceof Error ? err : new Error("Unknown error"))
|
|
60
|
-
} finally {
|
|
61
|
-
setLoading(false)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
fetchNotifications()
|
|
66
|
-
}, [contextId, updateNotifications])
|
|
67
|
-
|
|
68
|
-
return { notifications, loading, error }
|
|
69
|
-
}
|
package/tsconfig.app.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"useDefineForClassFields": true,
|
|
6
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
-
"module": "ESNext",
|
|
8
|
-
"types": ["vite/client"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
"moduleDetection": "force",
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx",
|
|
18
|
-
|
|
19
|
-
/* Linting */
|
|
20
|
-
"strict": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"erasableSyntaxOnly": true,
|
|
24
|
-
"noFallthroughCasesInSwitch": true,
|
|
25
|
-
"noUncheckedSideEffectImports": true
|
|
26
|
-
},
|
|
27
|
-
"include": ["src"]
|
|
28
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.node.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "ES2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
|
|
10
|
-
/* Bundler mode */
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"moduleDetection": "force",
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedSideEffectImports": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["vite.config.ts"]
|
|
26
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import path from "path"
|
|
2
|
-
import { defineConfig } from "vite"
|
|
3
|
-
import react from "@vitejs/plugin-react"
|
|
4
|
-
import dts from "vite-plugin-dts"
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [react(), dts({ insertTypesEntry: true })],
|
|
8
|
-
resolve: {
|
|
9
|
-
dedupe: ["trix", "trix-toolbar"],
|
|
10
|
-
},
|
|
11
|
-
build: {
|
|
12
|
-
target: ["es2018"],
|
|
13
|
-
lib: {
|
|
14
|
-
entry: path.resolve(__dirname, "src/index.ts"),
|
|
15
|
-
name: "compass",
|
|
16
|
-
formats: ["es", "cjs"],
|
|
17
|
-
fileName: (format) => `compass.${format}.js`,
|
|
18
|
-
},
|
|
19
|
-
outDir: path.resolve(__dirname, "dist"),
|
|
20
|
-
emptyOutDir: true,
|
|
21
|
-
rollupOptions: {
|
|
22
|
-
external: [
|
|
23
|
-
"react",
|
|
24
|
-
"react-dom",
|
|
25
|
-
"playbook-ui",
|
|
26
|
-
"react-trix",
|
|
27
|
-
"react/jsx-runtime",
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
define: {
|
|
32
|
-
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
33
|
-
},
|
|
34
|
-
})
|
package/vitest.config.ts
DELETED