@jant/core 0.3.32 → 0.3.33

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/dist/client/client.css +1 -1
  2. package/dist/client/client.js +1442 -989
  3. package/dist/index.js +1429 -1055
  4. package/package.json +1 -1
  5. package/src/__tests__/helpers/app.ts +6 -3
  6. package/src/__tests__/helpers/db.ts +3 -0
  7. package/src/client.ts +2 -1
  8. package/src/db/migrations/0011_add_path_registry.sql +23 -0
  9. package/src/db/schema.ts +12 -1
  10. package/src/i18n/locales/en.po +225 -91
  11. package/src/i18n/locales/en.ts +1 -1
  12. package/src/i18n/locales/zh-Hans.po +201 -152
  13. package/src/i18n/locales/zh-Hans.ts +1 -1
  14. package/src/i18n/locales/zh-Hant.po +201 -152
  15. package/src/i18n/locales/zh-Hant.ts +1 -1
  16. package/src/lib/__tests__/excerpt.test.ts +25 -0
  17. package/src/lib/__tests__/resolve-config.test.ts +26 -2
  18. package/src/lib/__tests__/timeline.test.ts +2 -1
  19. package/src/lib/compose-bridge.ts +30 -1
  20. package/src/lib/excerpt.ts +16 -7
  21. package/src/lib/nav-manager-bridge.ts +54 -0
  22. package/src/lib/navigation.ts +7 -4
  23. package/src/lib/render.tsx +5 -2
  24. package/src/lib/resolve-config.ts +7 -0
  25. package/src/lib/view.ts +42 -10
  26. package/src/middleware/error-handler.ts +16 -0
  27. package/src/routes/api/__tests__/posts.test.ts +80 -0
  28. package/src/routes/api/__tests__/settings.test.ts +1 -1
  29. package/src/routes/api/posts.ts +6 -29
  30. package/src/routes/api/upload.ts +2 -14
  31. package/src/routes/auth/__tests__/setup.test.ts +2 -1
  32. package/src/routes/compose.tsx +13 -5
  33. package/src/routes/dash/__tests__/pages.test.ts +2 -1
  34. package/src/routes/dash/__tests__/settings-avatar.test.ts +151 -33
  35. package/src/routes/dash/appearance.tsx +71 -4
  36. package/src/routes/dash/collections.tsx +15 -21
  37. package/src/routes/dash/media.tsx +1 -13
  38. package/src/routes/dash/pages.tsx +5 -150
  39. package/src/routes/dash/posts.tsx +25 -32
  40. package/src/routes/dash/redirects.tsx +9 -11
  41. package/src/routes/dash/settings.tsx +29 -111
  42. package/src/routes/feed/__tests__/rss.test.ts +5 -1
  43. package/src/routes/pages/__tests__/collections.test.ts +2 -1
  44. package/src/routes/pages/__tests__/featured.test.ts +2 -1
  45. package/src/routes/pages/page.tsx +20 -25
  46. package/src/services/__tests__/collection.test.ts +2 -1
  47. package/src/services/__tests__/media.test.ts +78 -1
  48. package/src/services/__tests__/navigation.test.ts +2 -1
  49. package/src/services/__tests__/page.test.ts +78 -1
  50. package/src/services/__tests__/path-registry.test.ts +165 -0
  51. package/src/services/__tests__/post-timeline.test.ts +2 -1
  52. package/src/services/__tests__/post.test.ts +103 -1
  53. package/src/services/__tests__/redirect.test.ts +53 -4
  54. package/src/services/__tests__/search.test.ts +2 -1
  55. package/src/services/__tests__/settings.test.ts +153 -0
  56. package/src/services/index.ts +12 -4
  57. package/src/services/media.ts +72 -4
  58. package/src/services/page.ts +64 -17
  59. package/src/services/path-registry.ts +160 -0
  60. package/src/services/post.ts +119 -24
  61. package/src/services/redirect.ts +23 -3
  62. package/src/services/settings.ts +181 -0
  63. package/src/styles/components.css +135 -0
  64. package/src/styles/tokens.css +6 -1
  65. package/src/styles/ui.css +70 -26
  66. package/src/types/bindings.ts +1 -0
  67. package/src/types/config.ts +7 -2
  68. package/src/types/constants.ts +9 -1
  69. package/src/types/sortablejs.d.ts +8 -2
  70. package/src/types/views.ts +1 -1
  71. package/src/ui/color-themes.ts +31 -31
  72. package/src/ui/components/__tests__/jant-settings-avatar.test.ts +0 -3
  73. package/src/ui/components/__tests__/jant-settings-general.test.ts +2 -6
  74. package/src/ui/components/jant-compose-dialog.ts +3 -2
  75. package/src/ui/components/jant-compose-editor.ts +17 -2
  76. package/src/ui/components/jant-nav-manager.ts +1067 -0
  77. package/src/ui/components/jant-settings-general.ts +2 -35
  78. package/src/ui/components/nav-manager-types.ts +72 -0
  79. package/src/ui/components/settings-types.ts +0 -3
  80. package/src/ui/compose/ComposePrompt.tsx +3 -11
  81. package/src/ui/dash/appearance/AdvancedContent.tsx +0 -3
  82. package/src/ui/dash/appearance/AppearanceNav.tsx +12 -8
  83. package/src/ui/dash/appearance/ColorThemeContent.tsx +1 -4
  84. package/src/ui/dash/appearance/FontThemeContent.tsx +0 -3
  85. package/src/ui/dash/appearance/NavigationContent.tsx +302 -0
  86. package/src/ui/dash/pages/PagesContent.tsx +74 -0
  87. package/src/ui/dash/settings/AccountContent.tsx +0 -3
  88. package/src/ui/dash/settings/GeneralContent.tsx +1 -19
  89. package/src/ui/dash/settings/SettingsNav.tsx +2 -6
  90. package/src/ui/feed/NoteCard.tsx +2 -2
  91. package/src/ui/layouts/DashLayout.tsx +83 -86
  92. package/src/ui/layouts/SiteLayout.tsx +82 -21
  93. package/src/lib/nav-reorder.ts +0 -26
  94. package/src/ui/dash/pages/LinkFormContent.tsx +0 -119
  95. package/src/ui/dash/pages/UnifiedPagesContent.tsx +0 -203
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jant/core",
3
- "version": "0.3.32",
3
+ "version": "0.3.33",
4
4
  "description": "A modern, open-source microblogging platform built on Cloudflare Workers",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,7 @@ import { createCollectionService } from "../../services/collection.js";
17
17
  import { createSearchService } from "../../services/search.js";
18
18
  import { createNavItemService } from "../../services/navigation.js";
19
19
  import { createAuthService } from "../../services/auth.js";
20
+ import { createPathRegistryService } from "../../services/path-registry.js";
20
21
  import type { Database } from "../../db/index.js";
21
22
  import type BetterSqlite3 from "better-sqlite3";
22
23
  import { errorHandler } from "../../middleware/error-handler.js";
@@ -45,11 +46,13 @@ export function createTestApp(options: TestAppOptions = {}) {
45
46
  const mockD1 = createMockD1(sqlite);
46
47
 
47
48
  const settingsService = createSettingsService(db);
49
+ const pathRegistryService = createPathRegistryService(db);
48
50
  const services = {
49
- posts: createPostService(db),
50
- pages: createPageService(db),
51
+ posts: createPostService(db, pathRegistryService),
52
+ pages: createPageService(db, pathRegistryService),
51
53
  settings: settingsService,
52
- redirects: createRedirectService(db),
54
+ pathRegistry: pathRegistryService,
55
+ redirects: createRedirectService(db, pathRegistryService),
53
56
  media: createMediaService(db),
54
57
  collections: createCollectionService(db),
55
58
  search: createSearchService(mockD1),
@@ -119,6 +119,9 @@ export function createTestDatabase(options?: { fts?: boolean }) {
119
119
  // Apply 0010: performance indexes
120
120
  applyMigration(sqlite, "0010_add_performance_indexes.sql");
121
121
 
122
+ // Apply 0011: path registry
123
+ applyMigration(sqlite, "0011_add_path_registry.sql");
124
+
122
125
  const db = drizzle(sqlite, { schema });
123
126
 
124
127
  // Polyfill D1 batch() for test compatibility.
package/src/client.ts CHANGED
@@ -12,7 +12,6 @@ import "basecoat-css/all";
12
12
  import "./lib/image-processor.js";
13
13
  import "./lib/media-upload.js";
14
14
  import "./lib/avatar-upload.js";
15
- import "./lib/nav-reorder.js";
16
15
  import "./lib/collections-reorder.js";
17
16
 
18
17
  // Lit Web Components
@@ -26,3 +25,5 @@ import "./ui/components/jant-collection-form.js";
26
25
  import "./lib/collection-form-bridge.js";
27
26
  import "./ui/components/jant-post-form.js";
28
27
  import "./lib/post-form-bridge.js";
28
+ import "./ui/components/jant-nav-manager.js";
29
+ import "./lib/nav-manager-bridge.js";
@@ -0,0 +1,23 @@
1
+ -- Path Registry: single source of truth for all claimed URL paths.
2
+ -- Enforces uniqueness at the DB level via PRIMARY KEY on path.
3
+
4
+ CREATE TABLE path_registry (
5
+ path TEXT PRIMARY KEY,
6
+ owner_type TEXT NOT NULL,
7
+ owner_id INTEGER NOT NULL,
8
+ created_at INTEGER NOT NULL
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE INDEX idx_path_registry_owner ON path_registry (owner_type, owner_id);
12
+ --> statement-breakpoint
13
+ -- Backfill from existing pages (slug)
14
+ INSERT INTO path_registry (path, owner_type, owner_id, created_at)
15
+ SELECT slug, 'page', id, created_at FROM pages;
16
+ --> statement-breakpoint
17
+ -- Backfill from existing posts with custom paths (non-deleted only)
18
+ INSERT INTO path_registry (path, owner_type, owner_id, created_at)
19
+ SELECT path, 'post', id, created_at FROM posts WHERE path IS NOT NULL AND deleted_at IS NULL;
20
+ --> statement-breakpoint
21
+ -- Backfill from existing redirects
22
+ INSERT INTO path_registry (path, owner_type, owner_id, created_at)
23
+ SELECT from_path, 'redirect', id, created_at FROM redirects;
package/src/db/schema.ts CHANGED
@@ -128,7 +128,7 @@ export const postCollections = sqliteTable("post_collections", {
128
128
  export const navItems = sqliteTable("nav_items", {
129
129
  id: integer("id").primaryKey({ autoIncrement: true }),
130
130
  type: text("type", {
131
- enum: ["page", "link"],
131
+ enum: ["page", "link", "system"],
132
132
  })
133
133
  .notNull()
134
134
  .default("link"),
@@ -154,6 +154,17 @@ export const redirects = sqliteTable("redirects", {
154
154
  createdAt: integer("created_at").notNull(),
155
155
  });
156
156
 
157
+ // =============================================================================
158
+ // Path Registry (URL path ownership)
159
+ // =============================================================================
160
+
161
+ export const pathRegistry = sqliteTable("path_registry", {
162
+ path: text("path").primaryKey(),
163
+ ownerType: text("owner_type").notNull(),
164
+ ownerId: integer("owner_id").notNull(),
165
+ createdAt: integer("created_at").notNull(),
166
+ });
167
+
157
168
  // =============================================================================
158
169
  // Settings (Key-Value)
159
170
  // =============================================================================