@geenius/tools 0.1.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.
- package/.changeset/config.json +11 -0
- package/.env.example +2 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +23 -0
- package/.github/workflows/release.yml +29 -0
- package/.node-version +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc +7 -0
- package/.project/ACCOUNT.yaml +4 -0
- package/.project/IDEAS.yaml +7 -0
- package/.project/PROJECT.yaml +11 -0
- package/.project/ROADMAP.yaml +15 -0
- package/CHANGELOG.md +16 -0
- package/CODE_OF_CONDUCT.md +26 -0
- package/CONTRIBUTING.md +69 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/SECURITY.md +18 -0
- package/SUPPORT.md +14 -0
- package/package.json +75 -0
- package/packages/convex/shared/README.md +1 -0
- package/packages/convex/shared/package.json +42 -0
- package/packages/convex/shared/src/audit/index.ts +5 -0
- package/packages/convex/shared/src/audit/presets.ts +165 -0
- package/packages/convex/shared/src/audit/schema.ts +85 -0
- package/packages/convex/shared/src/audit/write.ts +102 -0
- package/packages/convex/shared/src/extract.ts +75 -0
- package/packages/convex/shared/src/index.ts +41 -0
- package/packages/convex/shared/src/messages.ts +45 -0
- package/packages/convex/shared/src/security.ts +112 -0
- package/packages/convex/shared/src/throw.ts +184 -0
- package/packages/convex/shared/src/types.ts +57 -0
- package/packages/convex/shared/src/utils.ts +58 -0
- package/packages/convex/shared/tsconfig.json +28 -0
- package/packages/convex/shared/tsup.config.ts +12 -0
- package/packages/devtools/package.json +27 -0
- package/packages/devtools/react/README.md +1 -0
- package/packages/devtools/react/package.json +53 -0
- package/packages/devtools/react/src/components/DesignPreview.tsx +59 -0
- package/packages/devtools/react/src/components/DesignSwitcherDropdown.tsx +99 -0
- package/packages/devtools/react/src/components/DevSidebar.tsx +247 -0
- package/packages/devtools/react/src/components/DevToolbar.tsx +242 -0
- package/packages/devtools/react/src/components/GitHubIssueDialog.tsx +402 -0
- package/packages/devtools/react/src/components/InspectorOverlay.tsx +312 -0
- package/packages/devtools/react/src/components/PageLoadWaterfall.tsx +144 -0
- package/packages/devtools/react/src/components/PerformancePanel.tsx +330 -0
- package/packages/devtools/react/src/context/DevModeContext.tsx +226 -0
- package/packages/devtools/react/src/context/PerformanceContext.tsx +143 -0
- package/packages/devtools/react/src/data/designs.ts +13 -0
- package/packages/devtools/react/src/hooks/useGitHubLabels.ts +47 -0
- package/packages/devtools/react/src/hooks/useVirtualList.ts +124 -0
- package/packages/devtools/react/src/index.ts +77 -0
- package/packages/devtools/react/src/panels/ConvexSpy.tsx +130 -0
- package/packages/devtools/react/src/panels/DatabaseSeeder.tsx +116 -0
- package/packages/devtools/react/src/panels/DevModePhase2.tsx +191 -0
- package/packages/devtools/react/src/panels/DevModePhase3.tsx +234 -0
- package/packages/devtools/react/src/panels/FeatureFlagsToggle.tsx +104 -0
- package/packages/devtools/react/src/panels/QuickRouteJump.tsx +152 -0
- package/packages/devtools/react/src/services/github-service.ts +247 -0
- package/packages/devtools/react/tsconfig.json +31 -0
- package/packages/devtools/react/tsup.config.ts +18 -0
- package/packages/devtools/solidjs/README.md +1 -0
- package/packages/devtools/solidjs/package.json +49 -0
- package/packages/devtools/solidjs/src/components/DesignPreview.tsx +51 -0
- package/packages/devtools/solidjs/src/components/DesignSwitcherDropdown.tsx +95 -0
- package/packages/devtools/solidjs/src/components/DevSidebar.tsx +247 -0
- package/packages/devtools/solidjs/src/components/DevToolbar.tsx +242 -0
- package/packages/devtools/solidjs/src/components/GitHubIssueDialog.tsx +400 -0
- package/packages/devtools/solidjs/src/components/InspectorOverlay.tsx +311 -0
- package/packages/devtools/solidjs/src/components/PageLoadWaterfall.tsx +144 -0
- package/packages/devtools/solidjs/src/components/PerformancePanel.tsx +330 -0
- package/packages/devtools/solidjs/src/context/DevModeContext.tsx +216 -0
- package/packages/devtools/solidjs/src/context/PerformanceContext.tsx +135 -0
- package/packages/devtools/solidjs/src/data/designs.ts +13 -0
- package/packages/devtools/solidjs/src/hooks/createGitHubLabels.ts +47 -0
- package/packages/devtools/solidjs/src/index.ts +64 -0
- package/packages/devtools/solidjs/src/services/github-service.ts +247 -0
- package/packages/devtools/solidjs/tsconfig.json +21 -0
- package/packages/devtools/src/index.ts +377 -0
- package/packages/devtools/tsup.config.ts +12 -0
- package/packages/env/package.json +30 -0
- package/packages/env/src/index.ts +264 -0
- package/packages/env/tsup.config.ts +12 -0
- package/packages/errors/package.json +27 -0
- package/packages/errors/react/README.md +1 -0
- package/packages/errors/react/package.json +72 -0
- package/packages/errors/react/src/analytics.ts +16 -0
- package/packages/errors/react/src/components/ErrorBoundary.tsx +248 -0
- package/packages/errors/react/src/components/ErrorDisplay.tsx +328 -0
- package/packages/errors/react/src/components/ValidationErrors.tsx +102 -0
- package/packages/errors/react/src/config.ts +199 -0
- package/packages/errors/react/src/constants.ts +74 -0
- package/packages/errors/react/src/hooks/useErrorBoundary.ts +92 -0
- package/packages/errors/react/src/hooks/useErrorHandler.ts +87 -0
- package/packages/errors/react/src/index.ts +96 -0
- package/packages/errors/react/src/types.ts +102 -0
- package/packages/errors/react/src/utils/errorMessages.ts +35 -0
- package/packages/errors/react/src/utils/errorPolicy.ts +139 -0
- package/packages/errors/react/src/utils/extractAppError.ts +174 -0
- package/packages/errors/react/src/utils/formatError.ts +112 -0
- package/packages/errors/react/tsconfig.json +25 -0
- package/packages/errors/react/tsup.config.ts +24 -0
- package/packages/errors/solidjs/README.md +1 -0
- package/packages/errors/solidjs/package.json +46 -0
- package/packages/errors/solidjs/src/components/ErrorDisplay.tsx +179 -0
- package/packages/errors/solidjs/src/config.ts +98 -0
- package/packages/errors/solidjs/src/hooks/createErrorHandler.ts +107 -0
- package/packages/errors/solidjs/src/index.ts +61 -0
- package/packages/errors/solidjs/src/types.ts +34 -0
- package/packages/errors/solidjs/src/utils/errorPolicy.ts +56 -0
- package/packages/errors/solidjs/src/utils/extractAppError.ts +94 -0
- package/packages/errors/solidjs/src/utils/formatError.ts +33 -0
- package/packages/errors/solidjs/tsconfig.json +26 -0
- package/packages/errors/solidjs/tsup.config.ts +21 -0
- package/packages/errors/src/index.ts +320 -0
- package/packages/errors/tsup.config.ts +12 -0
- package/packages/logger/package.json +27 -0
- package/packages/logger/react/README.md +1 -0
- package/packages/logger/react/package.json +46 -0
- package/packages/logger/react/src/index.ts +4 -0
- package/packages/logger/react/src/useMetrics.ts +42 -0
- package/packages/logger/react/src/usePerformanceLog.ts +61 -0
- package/packages/logger/react/tsconfig.json +31 -0
- package/packages/logger/react/tsup.config.ts +12 -0
- package/packages/logger/solidjs/README.md +1 -0
- package/packages/logger/solidjs/package.json +45 -0
- package/packages/logger/solidjs/src/createMetrics.ts +37 -0
- package/packages/logger/solidjs/src/createPerformanceLog.ts +58 -0
- package/packages/logger/solidjs/src/index.ts +4 -0
- package/packages/logger/solidjs/tsconfig.json +32 -0
- package/packages/logger/solidjs/tsup.config.ts +12 -0
- package/packages/logger/src/index.ts +363 -0
- package/packages/logger/tsup.config.ts +12 -0
- package/packages/perf/package.json +27 -0
- package/packages/perf/react/README.md +1 -0
- package/packages/perf/react/package.json +59 -0
- package/packages/perf/react/src/components/PerformanceDashboard.tsx +257 -0
- package/packages/perf/react/src/hooks/useMonitoredQuery.ts +89 -0
- package/packages/perf/react/src/hooks/usePerformanceMetrics.ts +78 -0
- package/packages/perf/react/src/index.ts +33 -0
- package/packages/perf/react/src/services/PerformanceMonitor.ts +313 -0
- package/packages/perf/react/src/types.ts +77 -0
- package/packages/perf/react/tsconfig.json +25 -0
- package/packages/perf/react/tsup.config.ts +19 -0
- package/packages/perf/solidjs/README.md +1 -0
- package/packages/perf/solidjs/package.json +41 -0
- package/packages/perf/solidjs/src/components/PerformanceDashboard.tsx +207 -0
- package/packages/perf/solidjs/src/hooks/createPerformanceMetrics.ts +73 -0
- package/packages/perf/solidjs/src/index.ts +31 -0
- package/packages/perf/solidjs/src/services/PerformanceMonitor.ts +134 -0
- package/packages/perf/solidjs/src/types.ts +78 -0
- package/packages/perf/solidjs/tsconfig.json +26 -0
- package/packages/perf/solidjs/tsup.config.ts +14 -0
- package/packages/perf/src/index.ts +410 -0
- package/packages/perf/tsup.config.ts +12 -0
- package/pnpm-workspace.yaml +2 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @geenius-tools/devtools-solidjs — src/hooks/createGitHubLabels.ts
|
|
2
|
+
|
|
3
|
+
import { createSignal, createEffect } from 'solid-js'
|
|
4
|
+
import {
|
|
5
|
+
getRepositoryLabels,
|
|
6
|
+
isGitHubConfigured,
|
|
7
|
+
type GitHubLabel,
|
|
8
|
+
} from '../services/github-service'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook to fetch GitHub repository labels.
|
|
12
|
+
* Fetches once on mount if GitHub is configured.
|
|
13
|
+
* No external dependencies (no react-query).
|
|
14
|
+
*/
|
|
15
|
+
export function createGitHubLabels() {
|
|
16
|
+
const [data, setData] = createSignal<GitHubLabel[] | undefined>(undefined)
|
|
17
|
+
const [isLoading, setIsLoading] = createSignal(false)
|
|
18
|
+
const [error, setError] = createSignal<Error | null>(null)
|
|
19
|
+
const isConfigured = isGitHubConfigured()
|
|
20
|
+
|
|
21
|
+
createEffect(() => {
|
|
22
|
+
if (!isConfigured) return
|
|
23
|
+
|
|
24
|
+
let cancelled = false
|
|
25
|
+
setIsLoading(true)
|
|
26
|
+
|
|
27
|
+
getRepositoryLabels()
|
|
28
|
+
.then((labels) => {
|
|
29
|
+
if (!cancelled) {
|
|
30
|
+
setData(labels)
|
|
31
|
+
setIsLoading(false)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
if (!cancelled) {
|
|
36
|
+
setError(err)
|
|
37
|
+
setIsLoading(false)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
cancelled = true
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return { data, isLoading, error, isConfigured }
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @geenius-tools/devtools-solidjs — src/index.ts
|
|
2
|
+
|
|
3
|
+
// Components
|
|
4
|
+
export { DevToolbar } from './components/DevToolbar'
|
|
5
|
+
export type { DevToolbarProps } from './components/DevToolbar'
|
|
6
|
+
export { DevSidebar } from './components/DevSidebar'
|
|
7
|
+
export { PerformancePanel } from './components/PerformancePanel'
|
|
8
|
+
export { InspectorOverlay } from './components/InspectorOverlay'
|
|
9
|
+
export { GitHubIssueDialog } from './components/GitHubIssueDialog'
|
|
10
|
+
export type { GitHubIssueDialogProps } from './components/GitHubIssueDialog'
|
|
11
|
+
export { DesignPreview } from './components/DesignPreview'
|
|
12
|
+
export type { DesignPreviewProps } from './components/DesignPreview'
|
|
13
|
+
export { DesignSwitcherDropdown } from './components/DesignSwitcherDropdown'
|
|
14
|
+
export type { DesignSwitcherDropdownProps } from './components/DesignSwitcherDropdown'
|
|
15
|
+
export { PageLoadWaterfall, logWaterfall } from './components/PageLoadWaterfall'
|
|
16
|
+
export type { SsrTiming } from './components/PageLoadWaterfall'
|
|
17
|
+
|
|
18
|
+
// Data
|
|
19
|
+
export { designs } from './data/designs'
|
|
20
|
+
export type { Design } from './data/designs'
|
|
21
|
+
|
|
22
|
+
// Context
|
|
23
|
+
export {
|
|
24
|
+
DevModeProvider,
|
|
25
|
+
createDevMode,
|
|
26
|
+
createDevModeOptional,
|
|
27
|
+
createIsDevToolsVisible,
|
|
28
|
+
createIsDevAllowed,
|
|
29
|
+
} from './context/DevModeContext'
|
|
30
|
+
export type {
|
|
31
|
+
DevModeProviderProps,
|
|
32
|
+
DevModeContextValue,
|
|
33
|
+
ComponentDetails,
|
|
34
|
+
} from './context/DevModeContext'
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
PerformanceProvider,
|
|
38
|
+
createPerformanceContext,
|
|
39
|
+
createPerformanceContextOptional,
|
|
40
|
+
} from './context/PerformanceContext'
|
|
41
|
+
|
|
42
|
+
// Services
|
|
43
|
+
export {
|
|
44
|
+
configureGitHub,
|
|
45
|
+
isGitHubConfigured,
|
|
46
|
+
getGitHubConfig,
|
|
47
|
+
createGitHubIssue,
|
|
48
|
+
getRepositoryLabels,
|
|
49
|
+
getGitHubIssues,
|
|
50
|
+
generateContextInfo,
|
|
51
|
+
getIssueType,
|
|
52
|
+
formatRelativeTime,
|
|
53
|
+
} from './services/github-service'
|
|
54
|
+
export type {
|
|
55
|
+
GitHubConfig,
|
|
56
|
+
GitHubIssue,
|
|
57
|
+
GitHubLabel,
|
|
58
|
+
GitHubIssueListItem,
|
|
59
|
+
CreateIssueResponse,
|
|
60
|
+
IssueFilter,
|
|
61
|
+
} from './services/github-service'
|
|
62
|
+
|
|
63
|
+
// Hooks
|
|
64
|
+
export { createGitHubLabels } from './hooks/createGitHubLabels'
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// @geenius-tools/devtools-react — src/services/github-service.ts
|
|
2
|
+
// GitHub API service for creating issues — adapted from geenius-react
|
|
3
|
+
|
|
4
|
+
export interface GitHubIssue {
|
|
5
|
+
title: string
|
|
6
|
+
body: string
|
|
7
|
+
labels?: string[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface GitHubLabel {
|
|
11
|
+
id: number
|
|
12
|
+
name: string
|
|
13
|
+
color: string
|
|
14
|
+
description: string | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CreateIssueResponse {
|
|
18
|
+
id: number
|
|
19
|
+
number: number
|
|
20
|
+
html_url: string
|
|
21
|
+
title: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GitHubIssueListItem {
|
|
25
|
+
id: number
|
|
26
|
+
number: number
|
|
27
|
+
title: string
|
|
28
|
+
body: string | null
|
|
29
|
+
html_url: string
|
|
30
|
+
state: 'open' | 'closed'
|
|
31
|
+
created_at: string
|
|
32
|
+
updated_at: string
|
|
33
|
+
labels: GitHubLabel[]
|
|
34
|
+
user: {
|
|
35
|
+
login: string
|
|
36
|
+
avatar_url: string
|
|
37
|
+
} | null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type IssueFilter = 'all' | 'bug' | 'enhancement'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* GitHub configuration. Provide via `configureGitHub()` or env vars.
|
|
44
|
+
*/
|
|
45
|
+
export interface GitHubConfig {
|
|
46
|
+
owner: string
|
|
47
|
+
repo: string
|
|
48
|
+
branch?: string
|
|
49
|
+
token: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let _config: GitHubConfig | null = null
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Configure GitHub integration.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* configureGitHub({
|
|
60
|
+
* owner: 'my-org',
|
|
61
|
+
* repo: 'my-app',
|
|
62
|
+
* token: import.meta.env.VITE_GITHUB_TOKEN,
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function configureGitHub(config: GitHubConfig): void {
|
|
67
|
+
_config = config
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getGitHubConfig(): GitHubConfig {
|
|
71
|
+
if (_config) return _config
|
|
72
|
+
|
|
73
|
+
// Fallback: try env vars (Vite convention)
|
|
74
|
+
let owner = ''
|
|
75
|
+
let repo = ''
|
|
76
|
+
let branch = 'main'
|
|
77
|
+
let token = ''
|
|
78
|
+
try {
|
|
79
|
+
// @ts-expect-error — Vite env
|
|
80
|
+
owner = import.meta?.env?.VITE_GITHUB_OWNER ?? ''
|
|
81
|
+
// @ts-expect-error — Vite env
|
|
82
|
+
repo = import.meta?.env?.VITE_GITHUB_REPO ?? ''
|
|
83
|
+
// @ts-expect-error — Vite env
|
|
84
|
+
branch = import.meta?.env?.VITE_GITHUB_BRANCH ?? 'main'
|
|
85
|
+
// @ts-expect-error — Vite env
|
|
86
|
+
token = import.meta?.env?.VITE_GITHUB_TOKEN ?? ''
|
|
87
|
+
} catch {
|
|
88
|
+
// Not in Vite
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { owner, repo, branch, token }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function isGitHubConfigured(): boolean {
|
|
95
|
+
const { owner, repo, token } = getGitHubConfig()
|
|
96
|
+
const isPlaceholder =
|
|
97
|
+
!token || token === 'ghp_your_personal_access_token_here'
|
|
98
|
+
return Boolean(owner && repo && token && !isPlaceholder)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function createGitHubIssue(
|
|
102
|
+
issue: GitHubIssue,
|
|
103
|
+
): Promise<CreateIssueResponse> {
|
|
104
|
+
const { owner, repo, token } = getGitHubConfig()
|
|
105
|
+
|
|
106
|
+
if (!owner || !repo || !token) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
'GitHub configuration is incomplete. Call configureGitHub() or set VITE_GITHUB_* env vars.',
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const response = await fetch(
|
|
113
|
+
`https://api.github.com/repos/${owner}/${repo}/issues`,
|
|
114
|
+
{
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers: {
|
|
117
|
+
Accept: 'application/vnd.github+json',
|
|
118
|
+
Authorization: `Bearer ${token}`,
|
|
119
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
},
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
title: issue.title,
|
|
124
|
+
body: issue.body,
|
|
125
|
+
labels: issue.labels || [],
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if (!response.ok) {
|
|
131
|
+
const error = await response
|
|
132
|
+
.json()
|
|
133
|
+
.catch(() => ({ message: 'Unknown error' }))
|
|
134
|
+
throw new Error(
|
|
135
|
+
`Failed to create issue: ${error.message || response.statusText}`,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return response.json()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export async function getRepositoryLabels(): Promise<GitHubLabel[]> {
|
|
143
|
+
const { owner, repo, token } = getGitHubConfig()
|
|
144
|
+
|
|
145
|
+
if (!owner || !repo || !token) return []
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const response = await fetch(
|
|
149
|
+
`https://api.github.com/repos/${owner}/${repo}/labels`,
|
|
150
|
+
{
|
|
151
|
+
headers: {
|
|
152
|
+
Accept: 'application/vnd.github+json',
|
|
153
|
+
Authorization: `Bearer ${token}`,
|
|
154
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
if (!response.ok) return []
|
|
160
|
+
return response.json()
|
|
161
|
+
} catch {
|
|
162
|
+
return []
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function getGitHubIssues(
|
|
167
|
+
filter: IssueFilter = 'all',
|
|
168
|
+
state: 'open' | 'closed' | 'all' = 'open',
|
|
169
|
+
): Promise<GitHubIssueListItem[]> {
|
|
170
|
+
const { owner, repo, token } = getGitHubConfig()
|
|
171
|
+
|
|
172
|
+
if (!owner || !repo || !token) return []
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const params = new URLSearchParams({
|
|
176
|
+
state,
|
|
177
|
+
per_page: '50',
|
|
178
|
+
sort: 'updated',
|
|
179
|
+
direction: 'desc',
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
if (filter !== 'all') {
|
|
183
|
+
params.set('labels', filter)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const response = await fetch(
|
|
187
|
+
`https://api.github.com/repos/${owner}/${repo}/issues?${params.toString()}`,
|
|
188
|
+
{
|
|
189
|
+
headers: {
|
|
190
|
+
Accept: 'application/vnd.github+json',
|
|
191
|
+
Authorization: `Bearer ${token}`,
|
|
192
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if (!response.ok) return []
|
|
198
|
+
|
|
199
|
+
const issues: GitHubIssueListItem[] = await response.json()
|
|
200
|
+
return issues.filter((issue) => !('pull_request' in issue))
|
|
201
|
+
} catch {
|
|
202
|
+
return []
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function generateContextInfo(): string {
|
|
207
|
+
const lines: string[] = [
|
|
208
|
+
'---',
|
|
209
|
+
'### Context',
|
|
210
|
+
'',
|
|
211
|
+
`**Page URL:** ${window.location.href}`,
|
|
212
|
+
`**Timestamp:** ${new Date().toISOString()}`,
|
|
213
|
+
`**User Agent:** ${navigator.userAgent}`,
|
|
214
|
+
`**Branch:** ${getGitHubConfig().branch ?? 'main'}`,
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
if (typeof window !== 'undefined') {
|
|
218
|
+
lines.push(`**Screen:** ${window.innerWidth}x${window.innerHeight}`)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return lines.join('\n')
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function getIssueType(
|
|
225
|
+
issue: GitHubIssueListItem,
|
|
226
|
+
): 'bug' | 'feature' | 'other' {
|
|
227
|
+
const labelNames = issue.labels.map((l) => l.name.toLowerCase())
|
|
228
|
+
if (labelNames.includes('bug')) return 'bug'
|
|
229
|
+
if (labelNames.includes('enhancement') || labelNames.includes('feature'))
|
|
230
|
+
return 'feature'
|
|
231
|
+
return 'other'
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function formatRelativeTime(dateString: string): string {
|
|
235
|
+
const date = new Date(dateString)
|
|
236
|
+
const now = new Date()
|
|
237
|
+
const diffMs = now.getTime() - date.getTime()
|
|
238
|
+
const diffMins = Math.floor(diffMs / 60000)
|
|
239
|
+
const diffHours = Math.floor(diffMs / 3600000)
|
|
240
|
+
const diffDays = Math.floor(diffMs / 86400000)
|
|
241
|
+
|
|
242
|
+
if (diffMins < 1) return 'just now'
|
|
243
|
+
if (diffMins < 60) return `${diffMins}m ago`
|
|
244
|
+
if (diffHours < 24) return `${diffHours}h ago`
|
|
245
|
+
if (diffDays < 7) return `${diffDays}d ago`
|
|
246
|
+
return date.toLocaleDateString()
|
|
247
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"jsx": "preserve",
|
|
7
|
+
"jsxImportSource": "solid-js",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"isolatedModules": true
|
|
17
|
+
},
|
|
18
|
+
"include": [
|
|
19
|
+
"src/**/*"
|
|
20
|
+
]
|
|
21
|
+
}
|