@allbluecn/shared 0.2.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.
Files changed (95) hide show
  1. package/package.json +117 -0
  2. package/src/constants/perf.ts +21 -0
  3. package/src/i18n/client.ts +32 -0
  4. package/src/i18n/config.ts +104 -0
  5. package/src/i18n/detect.ts +43 -0
  6. package/src/i18n/locales/en/agents.json +134 -0
  7. package/src/i18n/locales/en/apps.json +6 -0
  8. package/src/i18n/locales/en/auth.json +88 -0
  9. package/src/i18n/locales/en/billing.json +78 -0
  10. package/src/i18n/locales/en/chat.json +194 -0
  11. package/src/i18n/locales/en/common.json +203 -0
  12. package/src/i18n/locales/en/dashboard.json +38 -0
  13. package/src/i18n/locales/en/design.json +70 -0
  14. package/src/i18n/locales/en/desktop.json +35 -0
  15. package/src/i18n/locales/en/display.json +37 -0
  16. package/src/i18n/locales/en/editor.json +304 -0
  17. package/src/i18n/locales/en/enterprise.json +1 -0
  18. package/src/i18n/locales/en/invite.json +11 -0
  19. package/src/i18n/locales/en/knowledge.json +451 -0
  20. package/src/i18n/locales/en/mindmap.json +28 -0
  21. package/src/i18n/locales/en/prd.json +43 -0
  22. package/src/i18n/locales/en/projects.json +133 -0
  23. package/src/i18n/locales/en/settings.json +375 -0
  24. package/src/i18n/locales/en/share.json +20 -0
  25. package/src/i18n/locales/en/story.json +785 -0
  26. package/src/i18n/locales/en/tags.json +42 -0
  27. package/src/i18n/locales/en/workspace.json +90 -0
  28. package/src/i18n/locales/zh/agents.json +134 -0
  29. package/src/i18n/locales/zh/apps.json +6 -0
  30. package/src/i18n/locales/zh/auth.json +88 -0
  31. package/src/i18n/locales/zh/billing.json +78 -0
  32. package/src/i18n/locales/zh/chat.json +194 -0
  33. package/src/i18n/locales/zh/common.json +203 -0
  34. package/src/i18n/locales/zh/dashboard.json +38 -0
  35. package/src/i18n/locales/zh/design.json +70 -0
  36. package/src/i18n/locales/zh/desktop.json +35 -0
  37. package/src/i18n/locales/zh/display.json +37 -0
  38. package/src/i18n/locales/zh/editor.json +304 -0
  39. package/src/i18n/locales/zh/enterprise.json +1 -0
  40. package/src/i18n/locales/zh/invite.json +11 -0
  41. package/src/i18n/locales/zh/knowledge.json +451 -0
  42. package/src/i18n/locales/zh/mindmap.json +28 -0
  43. package/src/i18n/locales/zh/prd.json +43 -0
  44. package/src/i18n/locales/zh/projects.json +133 -0
  45. package/src/i18n/locales/zh/settings.json +375 -0
  46. package/src/i18n/locales/zh/share.json +20 -0
  47. package/src/i18n/locales/zh/story.json +785 -0
  48. package/src/i18n/locales/zh/tags.json +42 -0
  49. package/src/i18n/locales/zh/workspace.json +90 -0
  50. package/src/i18n/server.ts +18 -0
  51. package/src/i18n/types.ts +5 -0
  52. package/src/index.ts +90 -0
  53. package/src/infrastructure/ai/adapter.ts +59 -0
  54. package/src/infrastructure/ai/cli-detector.ts +64 -0
  55. package/src/infrastructure/ip-location.ts +76 -0
  56. package/src/infrastructure/references/engine.ts +104 -0
  57. package/src/infrastructure/ua-parser.ts +107 -0
  58. package/src/interfaces/ai.ts +38 -0
  59. package/src/interfaces/avatar.ts +22 -0
  60. package/src/interfaces/module.ts +60 -0
  61. package/src/interfaces/references.ts +44 -0
  62. package/src/interfaces/transport.ts +26 -0
  63. package/src/lib/annotation-template.ts +33 -0
  64. package/src/lib/comment-utils.ts +47 -0
  65. package/src/lib/datetime.ts +115 -0
  66. package/src/lib/desktop-detect.ts +27 -0
  67. package/src/lib/outline-utils.ts +57 -0
  68. package/src/lib/pacer.ts +96 -0
  69. package/src/lib/prd/stack-layout.ts +53 -0
  70. package/src/lib/prd-tree-utils.ts +94 -0
  71. package/src/lib/prototype-registry.ts +24 -0
  72. package/src/lib/query-client-seam.ts +14 -0
  73. package/src/lib/share-events.ts +78 -0
  74. package/src/lib/sidebar-utils.ts +21 -0
  75. package/src/lib/stores/prd-canvas-store.ts +69 -0
  76. package/src/lib/tag-colors.ts +35 -0
  77. package/src/lib/time-format.ts +50 -0
  78. package/src/modules/ai-providers/constants.ts +79 -0
  79. package/src/modules/ai-providers/index.ts +21 -0
  80. package/src/modules/ai-providers/seed-data.ts +222 -0
  81. package/src/modules/ai-providers/types.ts +95 -0
  82. package/src/modules/billing/feature-registry.ts +63 -0
  83. package/src/modules/billing/plan-features-schema.ts +11 -0
  84. package/src/modules/billing/resource-registry.ts +80 -0
  85. package/src/modules/definitions/plugin.module.ts +38 -0
  86. package/src/modules/definitions/prd.module.ts +45 -0
  87. package/src/modules/definitions/prototype.module.ts +38 -0
  88. package/src/modules/dependencies/index.ts +186 -0
  89. package/src/modules/register-defaults.ts +27 -0
  90. package/src/modules/registry.ts +53 -0
  91. package/src/server-seam.ts +51 -0
  92. package/src/types/outline.ts +26 -0
  93. package/src/types/prd.ts +90 -0
  94. package/src/types/prototype.ts +12 -0
  95. package/src/virtual.d.ts +4 -0
@@ -0,0 +1,186 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // packages/shared/src/modules/dependencies/index.ts
19
+ // 第三方依赖版本管理:类型 + 常量 + 预设关注列表
20
+
21
+ /** 依赖分类 */
22
+ export type DependencyCategory =
23
+ | 'framework' // 框架核心(TanStack Start / React / Vite / Prisma)
24
+ | 'ui' // UI 组件库(radix / motion / lucide / tailwind)
25
+ | 'editor' // 编辑器(TipTap / mind-elixir / lowlight)
26
+ | 'ai' // AI 相关(@tanstack/ai / openai)
27
+ | 'state' // 状态管理(react-query / react-form)
28
+ | 'auth' // 认证(start-authjs / @auth/core / bcryptjs)
29
+ | 'tool' // 工具库(zod / nanoid / i18next / sonner)
30
+ | 'other'
31
+
32
+ /** 优先级 */
33
+ export type DependencyPriority = 'high' | 'normal' | 'low'
34
+
35
+ /** 版本状态(前端展示用,由 serverFn 计算) */
36
+ export type VersionStatus = 'latest' | 'patch' | 'minor' | 'major' | 'unknown'
37
+
38
+ /** 依赖分类元信息 */
39
+ export const DEPENDENCY_CATEGORIES: Array<{
40
+ value: DependencyCategory
41
+ label: string
42
+ description: string
43
+ }> = [
44
+ { value: 'framework', label: '框架核心', description: 'TanStack Start / React / Vite / Prisma 等基础设施' },
45
+ { value: 'ui', label: 'UI 组件', description: 'radix / motion / lucide / tailwind 等界面库' },
46
+ { value: 'editor', label: '编辑器', description: 'TipTap / mind-elixir / lowlight 等富文本/思维导图' },
47
+ { value: 'ai', label: 'AI 能力', description: '@tanstack/ai / openai 等 LLM 集成' },
48
+ { value: 'state', label: '状态管理', description: 'react-query / react-form 等状态/数据层' },
49
+ { value: 'auth', label: '认证', description: 'start-authjs / @auth/core / bcryptjs' },
50
+ { value: 'tool', label: '工具库', description: 'zod / nanoid / i18next 等通用工具' },
51
+ { value: 'other', label: '其他', description: '未分类依赖' },
52
+ ]
53
+
54
+ export const DEPENDENCY_PRIORITIES: Array<{
55
+ value: DependencyPriority
56
+ label: string
57
+ }> = [
58
+ { value: 'high', label: '高' },
59
+ { value: 'normal', label: '中' },
60
+ { value: 'low', label: '低' },
61
+ ]
62
+
63
+ /** monorepo 中某个 app 的使用情况 */
64
+ export interface DependencyUsage {
65
+ /** 相对路径,如 "apps/web" */
66
+ app: string
67
+ /** 该 app 的 package.json 中声明的版本(semver range,如 "^3.23.6") */
68
+ declaredRange: string
69
+ }
70
+
71
+ /** DB 行 + 实时聚合数据(列表页主结构) */
72
+ export interface ThirdPartyDependencyRow {
73
+ id: string
74
+ /** npm 包名 */
75
+ name: string
76
+ /** 展示名(默认取 name) */
77
+ displayName: string
78
+ /** 依赖用途说明 */
79
+ description: string | null
80
+ /** 官网 / 仓库地址 */
81
+ homepage: string | null
82
+ /** npm 包页面地址 */
83
+ npmUrl: string
84
+ category: DependencyCategory
85
+ isWatched: boolean
86
+ priority: DependencyPriority
87
+ /** 项目中实际使用的版本信息(聚合 monorepo,来自 package.json,不缓存) */
88
+ usages: DependencyUsage[]
89
+ /** 当前使用版本(取 usages 中第一个 semver clean 值,便于表格直接展示) */
90
+ currentVersion: string | null
91
+ /** 缓存的 npm registry latest 版本 */
92
+ latestVersion: string | null
93
+ /** 最新版本的更新日志(GitHub Releases,markdown 原文) */
94
+ latestChangelog: string | null
95
+ /** 最后同步时间(ISO) */
96
+ lastSyncAt: string | null
97
+ /** 版本状态(由 currentVersion / latestVersion 比较得出) */
98
+ versionStatus: VersionStatus
99
+ notes: string | null
100
+ sortOrder: number
101
+ updatedAt: string
102
+ }
103
+
104
+ /** 编辑表单 payload */
105
+ export interface UpdateDependencyInput {
106
+ displayName?: string
107
+ description?: string | null
108
+ homepage?: string | null
109
+ category?: DependencyCategory
110
+ isWatched?: boolean
111
+ priority?: DependencyPriority
112
+ notes?: string | null
113
+ sortOrder?: number
114
+ }
115
+
116
+ /** 单个包同步结果 */
117
+ export interface SyncDependencyResult {
118
+ name: string
119
+ success: boolean
120
+ latestVersion?: string
121
+ homepage?: string | null
122
+ changelog?: string | null
123
+ error?: string
124
+ }
125
+
126
+ /**
127
+ * 预设关注列表(首次启动 seed 用)。
128
+ * 只放核心关注包;其余 monorepo 依赖在 list 时动态归入「全部依赖」分组。
129
+ * homepage 取官网或 GitHub 仓库,npmUrl 由 name 推导(不存表)。
130
+ */
131
+ export interface DependencySeed {
132
+ name: string
133
+ displayName: string
134
+ description: string
135
+ homepage: string
136
+ category: DependencyCategory
137
+ priority: DependencyPriority
138
+ }
139
+
140
+ export const DEFAULT_WATCHED_DEPENDENCIES: DependencySeed[] = [
141
+ // framework
142
+ { name: '@tanstack/react-start', displayName: 'TanStack Start', description: '全栈 React 框架,文件路由 + SSR/SSG', homepage: 'https://tanstack.com/start', category: 'framework', priority: 'high' },
143
+ { name: '@tanstack/react-router', displayName: 'TanStack Router', description: '类型安全的路由库,支持文件路由与代码拆分', homepage: 'https://tanstack.com/router', category: 'framework', priority: 'high' },
144
+ { name: 'vite', displayName: 'Vite', description: '下一代前端构建工具,ESM 原生 + 极速 HMR', homepage: 'https://vite.dev', category: 'framework', priority: 'high' },
145
+ { name: 'react', displayName: 'React', description: '声明式 UI 库,组件化开发基础', homepage: 'https://react.dev', category: 'framework', priority: 'high' },
146
+ { name: 'react-dom', displayName: 'React DOM', description: 'React 的 DOM 渲染器', homepage: 'https://react.dev', category: 'framework', priority: 'high' },
147
+ { name: 'prisma', displayName: 'Prisma', description: 'TypeScript ORM,Schema 优先的数据库工具链', homepage: 'https://prisma.io', category: 'framework', priority: 'high' },
148
+ { name: '@prisma/client', displayName: 'Prisma Client', description: 'Prisma 自动生成的类型安全查询客户端', homepage: 'https://prisma.io', category: 'framework', priority: 'high' },
149
+ { name: 'start-authjs', displayName: 'start-authjs', description: 'TanStack Start 的 Auth.js 集成,提供登录态管理', homepage: 'https://github.com/kophzeior/start-authjs', category: 'auth', priority: 'high' },
150
+ { name: '@auth/core', displayName: 'Auth.js Core', description: 'Auth.js 核心,支持 Credentials/OAuth 等多种登录方式', homepage: 'https://authjs.dev', category: 'auth', priority: 'normal' },
151
+
152
+ // editor
153
+ { name: '@tiptap/core', displayName: 'TipTap Core', description: '无头(headless)富文本编辑器核心,可扩展', homepage: 'https://tiptap.dev', category: 'editor', priority: 'high' },
154
+ { name: '@tiptap/react', displayName: 'TipTap React', description: 'TipTap 编辑器的 React 绑定', homepage: 'https://tiptap.dev', category: 'editor', priority: 'high' },
155
+ { name: '@tiptap/starter-kit', displayName: 'TipTap Starter Kit', description: 'TipTap 预置扩展集合(段落/列表/历史等)', homepage: 'https://tiptap.dev', category: 'editor', priority: 'normal' },
156
+ { name: 'mind-elixir', displayName: 'Mind Elixir', description: '轻量思维导图库,支持节点编辑与导出', homepage: 'https://github.com/ssshooter/mind-elixir', category: 'editor', priority: 'high' },
157
+ { name: 'lowlight', displayName: 'Lowlight', description: '基于 highlight.js 的语法高亮解析器', homepage: 'https://github.com/wooorm/lowlight', category: 'editor', priority: 'normal' },
158
+
159
+ // ai
160
+ { name: '@tanstack/ai', displayName: 'TanStack AI', description: '类型安全的 LLM SDK,支持流式输出与工具调用', homepage: 'https://tanstack.com/ai', category: 'ai', priority: 'high' },
161
+ { name: '@tanstack/ai-react', displayName: 'TanStack AI React', description: 'TanStack AI 的 React hooks(useChat 等)', homepage: 'https://tanstack.com/ai', category: 'ai', priority: 'normal' },
162
+ { name: '@tanstack/ai-openai', displayName: 'TanStack AI OpenAI Adapter', description: 'TanStack AI 的 OpenAI 官方模型适配器', homepage: 'https://tanstack.com/ai', category: 'ai', priority: 'normal' },
163
+ { name: '@tanstack/ai-anthropic', displayName: 'TanStack AI Anthropic Adapter', description: 'TanStack AI 的 Anthropic Claude 适配器', homepage: 'https://tanstack.com/ai', category: 'ai', priority: 'normal' },
164
+ { name: '@tanstack/ai-openrouter', displayName: 'TanStack AI OpenRouter Adapter', description: 'OpenRouter 多模型聚合适配器', homepage: 'https://tanstack.com/ai', category: 'ai', priority: 'normal' },
165
+ { name: 'openai', displayName: 'OpenAI SDK', description: 'OpenAI 官方 SDK,本项目用于 embedding 生成', homepage: 'https://openai.com', category: 'ai', priority: 'normal' },
166
+
167
+ // ui
168
+ { name: 'radix-ui', displayName: 'Radix UI', description: '无样式可访问组件库统一入口(dialog/menu 等)', homepage: 'https://radix-ui.com', category: 'ui', priority: 'high' },
169
+ { name: 'motion', displayName: 'Motion', description: 'React 动画库(原 framer-motion),声明式动画', homepage: 'https://motion.dev', category: 'ui', priority: 'normal' },
170
+ { name: 'lucide-react', displayName: 'Lucide React', description: 'Lucide 图标库的 React 版本', homepage: 'https://lucide.dev', category: 'ui', priority: 'normal' },
171
+ { name: 'next-themes', displayName: 'Next Themes', description: '主题切换库,支持暗黑模式持久化', homepage: 'https://github.com/pacocoursey/next-themes', category: 'ui', priority: 'normal' },
172
+ { name: 'tailwindcss', displayName: 'Tailwind CSS', description: '原子化 CSS 框架,工具类优先', homepage: 'https://tailwindcss.com', category: 'ui', priority: 'high' },
173
+ { name: 'shadcn', displayName: 'shadcn', description: '可复制粘贴的组件集合 CLI,项目 UI 组件来源', homepage: 'https://ui.shadcn.com', category: 'ui', priority: 'normal' },
174
+ { name: 'sonner', displayName: 'Sonner', description: 'Toast 通知组件,项目消息提示', homepage: 'https://sonner.emilkowal.ski', category: 'ui', priority: 'normal' },
175
+
176
+ // state
177
+ { name: '@tanstack/react-query', displayName: 'TanStack Query', description: '服务端状态管理与缓存,数据获取利器', homepage: 'https://tanstack.com/query', category: 'state', priority: 'high' },
178
+ { name: '@tanstack/react-form', displayName: 'TanStack Form', description: '类型安全的表单管理库', homepage: 'https://tanstack.com/form', category: 'state', priority: 'normal' },
179
+
180
+ // tool
181
+ { name: 'zod', displayName: 'Zod', description: 'TypeScript 优先的 Schema 校验库', homepage: 'https://zod.dev', category: 'tool', priority: 'high' },
182
+ { name: 'i18next', displayName: 'i18next', description: '国际化框架,多语言文案管理', homepage: 'https://www.i18next.com', category: 'tool', priority: 'normal' },
183
+ { name: 'react-i18next', displayName: 'React i18next', description: 'i18next 的 React 绑定', homepage: 'https://react.i18next.com', category: 'tool', priority: 'normal' },
184
+ { name: 'nanoid', displayName: 'Nano ID', description: '轻量 URL 友好的唯一 ID 生成器', homepage: 'https://github.com/ai/nanoid', category: 'tool', priority: 'low' },
185
+ { name: 'bcryptjs', displayName: 'bcryptjs', description: '密码哈希库,纯 JS 实现', homepage: 'https://github.com/dcodeIO/bcrypt.js', category: 'auth', priority: 'normal' },
186
+ ]
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { moduleRegistry } from "./registry"
19
+ import { prdModule } from "./definitions/prd.module"
20
+ import { prototypeModule } from "./definitions/prototype.module"
21
+ import { pluginModule } from "./definitions/plugin.module"
22
+
23
+ export function registerDefaultModules(): void {
24
+ moduleRegistry.register(prdModule)
25
+ moduleRegistry.register(prototypeModule)
26
+ moduleRegistry.register(pluginModule)
27
+ }
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { AllBlueModule, AICommandDef } from "../interfaces/module"
19
+
20
+ class ModuleRegistry {
21
+ private modules = new Map<string, AllBlueModule>()
22
+
23
+ register(mod: AllBlueModule): void {
24
+ if (this.modules.has(mod.id)) {
25
+ console.warn(`[ModuleRegistry] "${mod.id}" already registered, overwriting`)
26
+ }
27
+ this.modules.set(mod.id, mod)
28
+ }
29
+
30
+ getModule(id: string): AllBlueModule | undefined {
31
+ return this.modules.get(id)
32
+ }
33
+
34
+ getAll(): AllBlueModule[] {
35
+ return [...this.modules.values()]
36
+ }
37
+
38
+ getAICommands(): AICommandDef[] {
39
+ return [...this.modules.values()].flatMap(m => m.aiCommands)
40
+ }
41
+
42
+ getSearchFields(): { module: string; type: string; fields: string[] }[] {
43
+ return [...this.modules.values()].flatMap(m =>
44
+ m.entities.map(e => ({
45
+ module: m.id,
46
+ type: e.type,
47
+ fields: e.searchFields,
48
+ }))
49
+ )
50
+ }
51
+ }
52
+
53
+ export const moduleRegistry = new ModuleRegistry()
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * PrismaSeam — 注入式 prisma 接入点
20
+ *
21
+ * 解决 shared → database (prisma) → shared 的循环依赖:
22
+ * shared 包声明 seam 接口,database 包启动时注册实现。
23
+ * 复用 kernel 的 ServerSeam 注入模式。
24
+ */
25
+
26
+ export interface PrismaSeam {
27
+ reference: {
28
+ create: (data: unknown) => Promise<unknown>
29
+ findMany: (where: unknown) => Promise<unknown[]>
30
+ }
31
+ $queryRawUnsafe: <T = Record<string, unknown>>(
32
+ sql: string,
33
+ ...params: unknown[]
34
+ ) => Promise<T[]>
35
+ }
36
+
37
+ let _seam: PrismaSeam | null = null
38
+
39
+ export function registerPrismaSeam(seam: PrismaSeam): void {
40
+ _seam = seam
41
+ }
42
+
43
+ export function getPrismaSeam(): PrismaSeam {
44
+ if (!_seam) {
45
+ throw new Error(
46
+ "[@allbluecn/shared] PrismaSeam not registered. " +
47
+ "Call registerPrismaSeam(prisma) before using reference engine."
48
+ )
49
+ }
50
+ return _seam
51
+ }
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { CanvasElement } from "./prototype";
19
+
20
+ export interface OutlineNode {
21
+ id: string;
22
+ label: string;
23
+ type: "container" | "atom";
24
+ elementId: string;
25
+ children: OutlineNode[];
26
+ }
@@ -0,0 +1,90 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import {
19
+ Folder, FileText, BarChart3, Users, Settings as SettingsIcon,
20
+ Package, Database, ShoppingCart, Heart, Sparkles, Link,
21
+ MessageSquare, Calendar, Bell, Building2, SquareChartGantt,
22
+ HeartHandshake, Shrimp, Fish, VenetianMask, GraduationCap,
23
+ HandFist, LoaderPinwheel, ToolCase, PartyPopper, PencilRuler,
24
+ CircleStar, Brain, BadgeDollarSign, Earth, Music4,
25
+ } from "lucide-react";
26
+
27
+ export interface PRD {
28
+ id: string;
29
+ name: string;
30
+ icon: string;
31
+ description?: string | null;
32
+ prdTags?: { tag: { id: string; name: string; color: number } }[];
33
+ }
34
+
35
+ export interface PRDDetail extends PRD {
36
+ createdAt: Date;
37
+ updatedAt: Date;
38
+ }
39
+
40
+ export interface PRDVersionBase {
41
+ id: string;
42
+ versionLabel: string;
43
+ notes: string | null;
44
+ createdAt: string;
45
+ updatedAt?: string | null;
46
+ }
47
+
48
+ export interface PRDVersionWithPages extends PRDVersionBase {
49
+ pageVersions: { pageId: string; pageName: string; type?: "folder" | "page"; parentId?: string | null; version: number; pageVersionId?: string | null; canvas?: any; content?: any; isPlaceholder?: boolean }[];
50
+ }
51
+
52
+ export interface PRDVersionWithSemver extends PRDVersionBase {
53
+ major: number;
54
+ minor: number;
55
+ patch: number;
56
+ }
57
+
58
+ export const ICON_MAP: Record<string, React.ComponentType<{ className?: string }>> = {
59
+ folder: Folder,
60
+ file: FileText,
61
+ chart: BarChart3,
62
+ users: Users,
63
+ settings: SettingsIcon,
64
+ package: Package,
65
+ database: Database,
66
+ cart: ShoppingCart,
67
+ heart: Heart,
68
+ sparkles: Sparkles,
69
+ link: Link,
70
+ message: MessageSquare,
71
+ calendar: Calendar,
72
+ bell: Bell,
73
+ building2: Building2,
74
+ squareChartGantt: SquareChartGantt,
75
+ heartHandshake: HeartHandshake,
76
+ shrimp: Shrimp,
77
+ fish: Fish,
78
+ venetianMask: VenetianMask,
79
+ graduationCap: GraduationCap,
80
+ handFist: HandFist,
81
+ loaderPinwheel: LoaderPinwheel,
82
+ toolCase: ToolCase,
83
+ partyPopper: PartyPopper,
84
+ pencilRuler: PencilRuler,
85
+ circleStar: CircleStar,
86
+ brain: Brain,
87
+ badgeDollarSign: BadgeDollarSign,
88
+ earth: Earth,
89
+ music4: Music4,
90
+ };
@@ -0,0 +1,12 @@
1
+ export {
2
+ DEVICE_SIZES,
3
+ type CanvasElement,
4
+ type ComponentCategory,
5
+ type ComponentSource,
6
+ type DeviceType,
7
+ type EditableFieldType,
8
+ type EditablePropField,
9
+ type PrototypeComponentConfig,
10
+ type ResizeDirection,
11
+ type ResizeMode,
12
+ } from '@allblue/prototype'
@@ -0,0 +1,4 @@
1
+ // 声明 vite 专属 API 类型(供依赖 prototype 的包使用)
2
+ interface ImportMeta {
3
+ glob: (pattern: string, options?: { eager?: boolean; import?: string }) => Record<string, () => Promise<unknown>>
4
+ }