@publish.os/nextjs 0.0.1-alpha.6 → 0.0.1-alpha.7
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/README.md +3 -5
- package/compiler-assets/nextjs/defaults/app/globals.css +6 -0
- package/compiler-assets/nextjs/defaults/group/layout.tsx +23 -0
- package/compiler-assets/nextjs/defaults/group/leaf.tsx +48 -0
- package/compiler-assets/nextjs/defaults/group/page.tsx +50 -0
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +45 -0
- package/compiler-assets/nextjs/defaults/project/postcss.config.mjs +5 -0
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +41 -0
- package/compiler-assets/nextjs/defaults/root/css/animation.css +90 -0
- package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/drawer.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/menu.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +25 -0
- package/compiler-assets/nextjs/defaults/root/css/components/popover.css +17 -0
- package/compiler-assets/nextjs/defaults/root/css/components/select.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/toast.css +19 -0
- package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +15 -0
- package/compiler-assets/nextjs/defaults/root/css/layout.css +22 -0
- package/compiler-assets/nextjs/defaults/root/css/media.css +81 -0
- package/compiler-assets/nextjs/defaults/root/css/radius.css +49 -0
- package/compiler-assets/nextjs/defaults/root/css/scrollbar.css +43 -0
- package/compiler-assets/nextjs/defaults/root/css/shadow.css +145 -0
- package/compiler-assets/nextjs/defaults/root/css/typography.css +607 -0
- package/compiler-assets/nextjs/defaults/root/css/zindex.css +39 -0
- package/compiler-assets/nextjs/defaults/root/globals.css +191 -0
- package/compiler-assets/nextjs/defaults/root/layout.tsx +19 -0
- package/compiler-assets/nextjs/defaults/root/page.tsx +61 -0
- package/compiler-assets/nextjs/defaults/root/theme.css +50 -0
- package/compiler-assets/nextjs/defaults/source/_internal/logger.ts +21 -0
- package/compiler-assets/nextjs/shims/generated-group-layout.tsx +19 -0
- package/compiler-assets/nextjs/shims/generated-group-page.tsx +18 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +21 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +134 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +29 -0
- package/compiler-assets/nextjs/shims/og-image-route.ts +18 -0
- package/compiler-assets/nextjs/shims/powered-by-footer.tsx +40 -0
- package/compiler-assets/nextjs/shims/providers.tsx +13 -0
- package/compiler-assets/nextjs/shims/proxy.ts +317 -0
- package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +77 -0
- package/compiler-assets/nextjs/shims/root-page.tsx +13 -0
- package/compiler-assets/nextjs/shims/theme-defaults.css +177 -0
- package/dist/button-CFdx-ohV.d.ts +20 -0
- package/dist/cache/tags.js +6 -14
- package/dist/compiler.d.ts +100 -0
- package/dist/compiler.js +13379 -0
- package/dist/config/createNextConfig.d.ts +2 -1
- package/dist/config/createNextConfig.js +16 -12
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +303 -15
- package/dist/index.js +30 -1198
- package/dist/kernel/components/blocks/AgentActions.d.ts +9 -3
- package/dist/kernel/components/blocks/AgentActions.js +114 -200
- package/dist/kernel/components/blocks/animated-icon-swap.js +4 -25
- package/dist/kernel/components/blocks/color-palette.js +88 -169
- package/dist/kernel/components/blocks/design-system-preview.d.ts +38 -6
- package/dist/kernel/components/blocks/design-system-preview.js +44 -52
- package/dist/kernel/components/blocks/link-playground.js +23 -71
- package/dist/kernel/components/blocks/logo-block.js +18 -47
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +28 -42
- package/dist/kernel/components/blocks/navbar.d.ts +1 -1
- package/dist/kernel/components/blocks/navbar.js +14 -41
- package/dist/kernel/components/blocks/navigation-progress-playground.js +56 -149
- package/dist/kernel/components/blocks/navigation-progress.js +53 -157
- package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
- package/dist/kernel/components/blocks/next-prev.js +16 -42
- package/dist/kernel/components/blocks/page-list.d.ts +1 -1
- package/dist/kernel/components/blocks/page-list.js +11 -16
- package/dist/kernel/components/blocks/search.d.ts +13 -2
- package/dist/kernel/components/blocks/search.js +116 -247
- package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
- package/dist/kernel/components/blocks/sidebar-node.js +56 -95
- package/dist/kernel/components/blocks/sidebar.d.ts +5 -23
- package/dist/kernel/components/blocks/sidebar.js +35 -103
- package/dist/kernel/components/blocks/theme-toggle.d.ts +7 -3
- package/dist/kernel/components/blocks/theme-toggle.js +2 -2
- package/dist/kernel/components/blocks/toc.js +42 -178
- package/dist/kernel/components/mdx/components/blockquote.js +3 -24
- package/dist/kernel/components/mdx/components/callout.d.ts +1 -1
- package/dist/kernel/components/mdx/components/callout.js +15 -47
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/figure-caption.js +6 -24
- package/dist/kernel/components/mdx/components/figure.js +9 -36
- package/dist/kernel/components/mdx/components/footnotes.js +3 -24
- package/dist/kernel/components/mdx/components/heading-copy-link.js +13 -37
- package/dist/kernel/components/mdx/components/heading.d.ts +8 -3
- package/dist/kernel/components/mdx/components/heading.js +32 -116
- package/dist/kernel/components/mdx/components/hr.d.ts +5 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +2 -3
- package/dist/kernel/components/mdx/components/image.js +22 -62
- package/dist/kernel/components/mdx/components/inline-code.js +3 -24
- package/dist/kernel/components/mdx/components/kbd.d.ts +9 -4
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +1 -2
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +13 -41
- package/dist/kernel/components/mdx/components/pre.js +3 -24
- package/dist/kernel/components/mdx/components/strikethrough.js +6 -24
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +6 -28
- package/dist/kernel/components/mdx/components/video-player.js +53 -88
- package/dist/kernel/components/mdx/components/video.js +27 -75
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +12 -15
- package/dist/kernel/components/mdx/error-fallback.js +4 -4
- package/dist/kernel/components/mdx/mdx.d.ts +68 -11
- package/dist/kernel/components/mdx/mdx.js +29 -29
- package/dist/kernel/components/mdx/rehype-heading-ids.js +11 -67
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/ui/accordion.js +3 -26
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +23 -7
- package/dist/kernel/components/ui/breadcrumb-trail.js +32 -80
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +20 -54
- package/dist/kernel/components/ui/button-group.d.ts +4 -3
- package/dist/kernel/components/ui/button-group.js +7 -30
- package/dist/kernel/components/ui/button.js +13 -36
- package/dist/kernel/components/ui/card.d.ts +2 -2
- package/dist/kernel/components/ui/card.js +2 -23
- package/dist/kernel/components/ui/dialog.d.ts +9 -9
- package/dist/kernel/components/ui/dialog.js +15 -33
- package/dist/kernel/components/ui/drawer.d.ts +10 -10
- package/dist/kernel/components/ui/drawer.js +15 -33
- package/dist/kernel/components/ui/input.js +6 -30
- package/dist/kernel/components/ui/kbd.js +10 -31
- package/dist/kernel/components/ui/link.d.ts +1 -1
- package/dist/kernel/components/ui/link.js +53 -104
- package/dist/kernel/components/ui/menu.d.ts +21 -21
- package/dist/kernel/components/ui/menu.js +10 -32
- package/dist/kernel/components/ui/meta-key.d.ts +9 -4
- package/dist/kernel/components/ui/meta-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.d.ts +14 -14
- package/dist/kernel/components/ui/navigation-menu.js +9 -30
- package/dist/kernel/components/ui/popover.d.ts +10 -10
- package/dist/kernel/components/ui/popover.js +19 -34
- package/dist/kernel/components/ui/progress.js +2 -25
- package/dist/kernel/components/ui/scroll-area.js +39 -118
- package/dist/kernel/components/ui/select.d.ts +15 -15
- package/dist/kernel/components/ui/select.js +19 -35
- package/dist/kernel/components/ui/separator.js +2 -25
- package/dist/kernel/components/ui/table.js +2 -23
- package/dist/kernel/components/ui/tabs.js +39 -99
- package/dist/kernel/components/ui/tag.d.ts +2 -2
- package/dist/kernel/components/ui/tag.js +4 -25
- package/dist/kernel/components/ui/text.d.ts +2 -2
- package/dist/kernel/components/ui/text.js +3 -25
- package/dist/kernel/components/ui/theme-toggle.d.ts +18 -4
- package/dist/kernel/components/ui/theme-toggle.js +18 -44
- package/dist/kernel/components/ui/toast.d.ts +10 -10
- package/dist/kernel/components/ui/toast.js +13 -35
- package/dist/kernel/components/ui/tooltip.d.ts +8 -8
- package/dist/kernel/components/ui/tooltip.js +8 -29
- package/dist/kernel/defaults.registry.d.ts +1 -1
- package/dist/kernel/defaults.registry.js +2 -2
- package/dist/kernel/framework-icons.d.ts +1 -0
- package/dist/kernel/framework-icons.js +39 -0
- package/dist/kernel/routes/agent/markdown.js +36 -65
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +20 -109
- package/dist/kernel/routes/metadata/feed.d.ts +1 -2
- package/dist/kernel/routes/metadata/feed.js +46 -127
- package/dist/kernel/routes/metadata/llms.d.ts +1 -2
- package/dist/kernel/routes/metadata/llms.js +40 -120
- package/dist/kernel/routes/metadata/og-image.d.ts +10 -0
- package/dist/kernel/routes/metadata/og-image.js +264 -198
- package/dist/kernel/routes/metadata/robots.d.ts +1 -2
- package/dist/kernel/routes/metadata/robots.js +21 -90
- package/dist/kernel/routes/metadata/sitemap.d.ts +1 -2
- package/dist/kernel/routes/metadata/sitemap.js +36 -102
- package/dist/kernel/routes/pages/group.d.ts +1 -1
- package/dist/kernel/routes/pages/group.js +42 -137
- package/dist/kernel/routes/pages/leaf.d.ts +1 -1
- package/dist/kernel/routes/pages/leaf.js +74 -213
- package/dist/kernel/routes/pages/root.d.ts +1 -1
- package/dist/kernel/routes/pages/root.js +37 -108
- package/dist/keyboard-shortcuts.js +69 -141
- package/dist/link-CYaCRDb6.d.ts +35 -0
- package/dist/resolvers/manifest-resolver.d.ts +3 -3
- package/dist/resolvers/manifest-resolver.js +15 -21
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.d.ts +81 -4
- package/dist/search.js +124 -195
- package/dist/sidebar-types-Bgchdfd6.d.ts +25 -0
- package/dist/theme-scope.d.ts +15 -0
- package/dist/theme-scope.js +23 -0
- package/dist/types-B_b3C0U6.d.ts +63 -0
- package/dist/types-CIwwieNw.d.ts +127 -0
- package/dist/types-DHBm7-j6.d.ts +57 -0
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +0 -1
- package/dist/types.js +1 -1
- package/dist/utils/cn.d.ts +5 -9
- package/dist/utils/cn.js +13 -7
- package/dist/utils/heading-ids.js +20 -47
- package/dist/utils/pretty-date.js +7 -13
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.png +0 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +54 -0
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +31 -0
- package/init/seed/minimal/publish.os/docs/content/theme.mdx +64 -0
- package/init/seed/minimal/publish.os/publish.os.config.json +21 -0
- package/init/seed/minimal/publish.os/theme.css +47 -0
- package/init/seed/minimal/seed.json +13 -0
- package/package.json +469 -35
- package/release/{package.json → app/lucide/package.json} +11 -5
- package/release/app/lucide/pnpm-lock.yaml.template +2905 -0
- package/release/app/lucide/pnpm-workspace.yaml +11 -0
- package/release/app/phosphor/package.json +30 -0
- package/release/app/phosphor/pnpm-lock.yaml.template +2908 -0
- package/release/app/phosphor/pnpm-workspace.yaml +11 -0
- package/release/app/tabler/package.json +30 -0
- package/release/app/tabler/pnpm-lock.yaml.template +2911 -0
- package/release/app/tabler/pnpm-workspace.yaml +11 -0
- package/release/compiler/package.json +20 -0
- package/release/compiler/pnpm-lock.yaml.template +2432 -0
- package/release/compiler/pnpm-workspace.yaml +11 -0
- package/release/release.json +29 -5
- package/release/runtime-pnpm-lock.yaml +0 -1316
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/keyboard-shortcuts.tsx
|
|
3
|
+
// src/lib/keyboard/keyboard-shortcuts.tsx
|
|
4
4
|
import {
|
|
5
5
|
createContext,
|
|
6
6
|
use,
|
|
@@ -13,23 +13,21 @@ import {
|
|
|
13
13
|
import { jsx } from "react/jsx-runtime";
|
|
14
14
|
var DEFAULT_OPTIONS = {
|
|
15
15
|
description: "",
|
|
16
|
-
enabled:
|
|
17
|
-
enableOnContentEditable:
|
|
18
|
-
enableOnFormFields:
|
|
19
|
-
enableWhileComposing:
|
|
16
|
+
enabled: !0,
|
|
17
|
+
enableOnContentEditable: !1,
|
|
18
|
+
enableOnFormFields: !1,
|
|
19
|
+
enableWhileComposing: !1,
|
|
20
20
|
group: "",
|
|
21
|
-
preventDefault:
|
|
21
|
+
preventDefault: !0,
|
|
22
22
|
priority: 0,
|
|
23
|
-
stopPropagation:
|
|
24
|
-
}
|
|
25
|
-
var MODIFIER_TOKENS = /* @__PURE__ */ new Set([
|
|
23
|
+
stopPropagation: !1
|
|
24
|
+
}, MODIFIER_TOKENS = /* @__PURE__ */ new Set([
|
|
26
25
|
"mod",
|
|
27
26
|
"meta",
|
|
28
27
|
"ctrl",
|
|
29
28
|
"alt",
|
|
30
29
|
"shift"
|
|
31
|
-
])
|
|
32
|
-
var KEY_ALIASES = {
|
|
30
|
+
]), KEY_ALIASES = {
|
|
33
31
|
cmd: "meta",
|
|
34
32
|
command: "meta",
|
|
35
33
|
control: "ctrl",
|
|
@@ -46,9 +44,7 @@ var KEY_ALIASES = {
|
|
|
46
44
|
space: " ",
|
|
47
45
|
spacebar: " ",
|
|
48
46
|
up: "arrowup"
|
|
49
|
-
}
|
|
50
|
-
var EDITABLE_TAGS = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]);
|
|
51
|
-
var SYMBOLS_MAC = {
|
|
47
|
+
}, EDITABLE_TAGS = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), SYMBOLS_MAC = {
|
|
52
48
|
" ": "Space",
|
|
53
49
|
alt: "\u2325",
|
|
54
50
|
arrowdown: "\u2193",
|
|
@@ -62,8 +58,7 @@ var SYMBOLS_MAC = {
|
|
|
62
58
|
escape: "\u238B",
|
|
63
59
|
meta: "\u2318",
|
|
64
60
|
shift: "\u21E7"
|
|
65
|
-
}
|
|
66
|
-
var LABELS_OTHER = {
|
|
61
|
+
}, LABELS_OTHER = {
|
|
67
62
|
" ": "Space",
|
|
68
63
|
alt: "Alt",
|
|
69
64
|
arrowdown: "\u2193",
|
|
@@ -79,65 +74,53 @@ var LABELS_OTHER = {
|
|
|
79
74
|
shift: "Shift"
|
|
80
75
|
};
|
|
81
76
|
function platform() {
|
|
82
|
-
|
|
83
|
-
return navigator.platform ?? "";
|
|
77
|
+
return typeof navigator > "u" ? "" : navigator.platform ?? "";
|
|
84
78
|
}
|
|
85
79
|
function isMacPlatform() {
|
|
86
80
|
return /mac|iphone|ipad|ipod/i.test(platform());
|
|
87
81
|
}
|
|
88
82
|
function parseChord(input) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (rawParts.length === 0) {
|
|
83
|
+
let source = input.trim(), rawParts = source.split("+").map((part) => part.trim().toLowerCase()).filter(Boolean);
|
|
84
|
+
if (rawParts.length === 0)
|
|
92
85
|
throw new Error(`useShortcut: empty key combo "${input}"`);
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
let key = "";
|
|
97
|
-
let meta = false;
|
|
98
|
-
let shift = false;
|
|
99
|
-
for (const part of rawParts) {
|
|
100
|
-
const aliased = KEY_ALIASES[part] ?? part;
|
|
86
|
+
let alt = !1, ctrl = !1, key = "", meta = !1, shift = !1;
|
|
87
|
+
for (let part of rawParts) {
|
|
88
|
+
let aliased = KEY_ALIASES[part] ?? part;
|
|
101
89
|
if (MODIFIER_TOKENS.has(aliased)) {
|
|
102
90
|
switch (aliased) {
|
|
103
91
|
case "mod":
|
|
104
|
-
|
|
105
|
-
else ctrl = true;
|
|
92
|
+
isMacPlatform() ? meta = !0 : ctrl = !0;
|
|
106
93
|
break;
|
|
107
94
|
case "meta":
|
|
108
|
-
meta =
|
|
95
|
+
meta = !0;
|
|
109
96
|
break;
|
|
110
97
|
case "ctrl":
|
|
111
|
-
ctrl =
|
|
98
|
+
ctrl = !0;
|
|
112
99
|
break;
|
|
113
100
|
case "alt":
|
|
114
|
-
alt =
|
|
101
|
+
alt = !0;
|
|
115
102
|
break;
|
|
116
103
|
case "shift":
|
|
117
|
-
shift =
|
|
104
|
+
shift = !0;
|
|
118
105
|
break;
|
|
119
106
|
}
|
|
120
107
|
continue;
|
|
121
108
|
}
|
|
122
|
-
if (key)
|
|
109
|
+
if (key)
|
|
123
110
|
throw new Error(
|
|
124
111
|
`useShortcut: combo "${input}" has more than one non-modifier key`
|
|
125
112
|
);
|
|
126
|
-
}
|
|
127
113
|
key = aliased;
|
|
128
114
|
}
|
|
129
|
-
if (!key)
|
|
115
|
+
if (!key)
|
|
130
116
|
throw new Error(`useShortcut: combo "${input}" has no non-modifier key`);
|
|
131
|
-
}
|
|
132
117
|
return { alt, ctrl, key, meta, shift, source };
|
|
133
118
|
}
|
|
134
119
|
function codeToLogicalKey(code) {
|
|
135
|
-
if (code.length === 4 && code.startsWith("Key"))
|
|
120
|
+
if (code.length === 4 && code.startsWith("Key"))
|
|
136
121
|
return code[3]?.toLowerCase() ?? null;
|
|
137
|
-
|
|
138
|
-
if (code.length === 6 && code.startsWith("Digit")) {
|
|
122
|
+
if (code.length === 6 && code.startsWith("Digit"))
|
|
139
123
|
return code[5] ?? null;
|
|
140
|
-
}
|
|
141
124
|
switch (code) {
|
|
142
125
|
case "Backquote":
|
|
143
126
|
return "`";
|
|
@@ -166,24 +149,19 @@ function codeToLogicalKey(code) {
|
|
|
166
149
|
}
|
|
167
150
|
}
|
|
168
151
|
function chordMatches(event, chord) {
|
|
169
|
-
if (event.metaKey !== chord.meta || event.ctrlKey !== chord.ctrl || event.altKey !== chord.alt)
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
if (event.key.toLowerCase() === chord.key) return true;
|
|
176
|
-
const logicalKey = codeToLogicalKey(event.code);
|
|
152
|
+
if (event.metaKey !== chord.meta || event.ctrlKey !== chord.ctrl || event.altKey !== chord.alt)
|
|
153
|
+
return !1;
|
|
154
|
+
let keyIsSingleChar = chord.key.length === 1;
|
|
155
|
+
if (!keyIsSingleChar && event.shiftKey !== chord.shift || keyIsSingleChar && chord.shift && !event.shiftKey) return !1;
|
|
156
|
+
if (event.key.toLowerCase() === chord.key) return !0;
|
|
157
|
+
let logicalKey = codeToLogicalKey(event.code);
|
|
177
158
|
return logicalKey !== null && logicalKey === chord.key;
|
|
178
159
|
}
|
|
179
160
|
function inspectTarget(target) {
|
|
180
|
-
|
|
181
|
-
return { isContentEditable: false, isFormField: false };
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
161
|
+
return target instanceof HTMLElement ? {
|
|
184
162
|
isContentEditable: target.isContentEditable,
|
|
185
163
|
isFormField: EDITABLE_TAGS.has(target.tagName)
|
|
186
|
-
};
|
|
164
|
+
} : { isContentEditable: !1, isFormField: !1 };
|
|
187
165
|
}
|
|
188
166
|
function resolvedOptions(options) {
|
|
189
167
|
return { ...DEFAULT_OPTIONS, ...options };
|
|
@@ -192,28 +170,18 @@ var ShortcutContext = createContext(null);
|
|
|
192
170
|
function KeyboardShortcutsProvider({
|
|
193
171
|
children
|
|
194
172
|
}) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const register = useCallback(
|
|
203
|
-
(registration) => {
|
|
204
|
-
registry.current.set(registration.id, registration);
|
|
205
|
-
rebuildOrder();
|
|
206
|
-
return () => {
|
|
207
|
-
registry.current.delete(registration.id);
|
|
208
|
-
rebuildOrder();
|
|
209
|
-
};
|
|
210
|
-
},
|
|
173
|
+
let registry = useRef(/* @__PURE__ */ new Map()), ordered = useRef([]), rebuildOrder = useCallback(() => {
|
|
174
|
+
let next = Array.from(registry.current.values());
|
|
175
|
+
next.sort((a, b) => b.priority - a.priority), ordered.current = next;
|
|
176
|
+
}, []), register = useCallback(
|
|
177
|
+
(registration) => (registry.current.set(registration.id, registration), rebuildOrder(), () => {
|
|
178
|
+
registry.current.delete(registration.id), rebuildOrder();
|
|
179
|
+
}),
|
|
211
180
|
[rebuildOrder]
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const { options } = registration.ref.current;
|
|
181
|
+
), list = useCallback(() => {
|
|
182
|
+
let items = [];
|
|
183
|
+
for (let registration of registry.current.values()) {
|
|
184
|
+
let { options } = registration.ref.current;
|
|
217
185
|
items.push({
|
|
218
186
|
description: options.description,
|
|
219
187
|
enabled: options.enabled,
|
|
@@ -223,100 +191,60 @@ function KeyboardShortcutsProvider({
|
|
|
223
191
|
});
|
|
224
192
|
}
|
|
225
193
|
return items;
|
|
226
|
-
}, [])
|
|
227
|
-
|
|
228
|
-
const registrations = ordered.current;
|
|
194
|
+
}, []), handleKeyDown = useCallback((event) => {
|
|
195
|
+
let registrations = ordered.current;
|
|
229
196
|
if (registrations.length === 0) return;
|
|
230
197
|
let target = null;
|
|
231
|
-
for (
|
|
232
|
-
|
|
233
|
-
if (!options.enabled)
|
|
234
|
-
if ((event.isComposing || event.keyCode === 229) && !options.enableWhileComposing) {
|
|
198
|
+
for (let registration of registrations) {
|
|
199
|
+
let { handler, options } = registration.ref.current;
|
|
200
|
+
if (!options.enabled || (event.isComposing || event.keyCode === 229) && !options.enableWhileComposing)
|
|
235
201
|
continue;
|
|
236
|
-
|
|
237
|
-
let
|
|
238
|
-
for (const chord of registration.chords) {
|
|
202
|
+
let matched = !1;
|
|
203
|
+
for (let chord of registration.chords)
|
|
239
204
|
if (chordMatches(event, chord)) {
|
|
240
|
-
matched =
|
|
205
|
+
matched = !0;
|
|
241
206
|
break;
|
|
242
207
|
}
|
|
208
|
+
if (matched && (target ??= inspectTarget(event.target), !(target.isFormField && !options.enableOnFormFields) && !(target.isContentEditable && !options.enableOnContentEditable))) {
|
|
209
|
+
options.preventDefault && event.preventDefault(), options.stopPropagation && event.stopPropagation(), handler(event);
|
|
210
|
+
break;
|
|
243
211
|
}
|
|
244
|
-
if (!matched) continue;
|
|
245
|
-
target ??= inspectTarget(event.target);
|
|
246
|
-
if (target.isFormField && !options.enableOnFormFields) continue;
|
|
247
|
-
if (target.isContentEditable && !options.enableOnContentEditable) {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
if (options.preventDefault) event.preventDefault();
|
|
251
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
252
|
-
handler(event);
|
|
253
|
-
break;
|
|
254
212
|
}
|
|
255
213
|
}, []);
|
|
256
|
-
useEffect(() => {
|
|
257
|
-
window.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
};
|
|
261
|
-
}, [handleKeyDown]);
|
|
262
|
-
const api = useMemo(
|
|
214
|
+
useEffect(() => (window.addEventListener("keydown", handleKeyDown, { capture: !0 }), () => {
|
|
215
|
+
window.removeEventListener("keydown", handleKeyDown, { capture: !0 });
|
|
216
|
+
}), [handleKeyDown]);
|
|
217
|
+
let api = useMemo(
|
|
263
218
|
() => ({ list, register }),
|
|
264
219
|
[list, register]
|
|
265
220
|
);
|
|
266
221
|
return /* @__PURE__ */ jsx(ShortcutContext, { value: api, children });
|
|
267
222
|
}
|
|
268
223
|
function useShortcut(combo, handler, options) {
|
|
269
|
-
|
|
270
|
-
if (!api)
|
|
224
|
+
let api = use(ShortcutContext);
|
|
225
|
+
if (!api)
|
|
271
226
|
throw new Error(
|
|
272
227
|
"useShortcut must be used within <KeyboardShortcutsProvider>."
|
|
273
228
|
);
|
|
274
|
-
|
|
275
|
-
const id = useId();
|
|
276
|
-
const comboKey = typeof combo === "string" ? combo : combo.join("\0");
|
|
277
|
-
const chords = useMemo(() => {
|
|
278
|
-
return comboKey.split("\0").map(parseChord);
|
|
279
|
-
}, [comboKey]);
|
|
280
|
-
const optionsPriority = options?.priority ?? DEFAULT_OPTIONS.priority;
|
|
281
|
-
const live = useRef({
|
|
229
|
+
let id = useId(), comboKey = typeof combo == "string" ? combo : combo.join("\0"), chords = useMemo(() => comboKey.split("\0").map(parseChord), [comboKey]), optionsPriority = options?.priority ?? DEFAULT_OPTIONS.priority, live = useRef({
|
|
282
230
|
handler,
|
|
283
231
|
options: resolvedOptions(options)
|
|
284
232
|
});
|
|
285
|
-
live.current.handler = handler;
|
|
286
|
-
live.current.options = resolvedOptions(options);
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
return api.register({ chords, id, priority: optionsPriority, ref: live });
|
|
289
|
-
}, [api, chords, id, optionsPriority]);
|
|
233
|
+
live.current.handler = handler, live.current.options = resolvedOptions(options), useEffect(() => api.register({ chords, id, priority: optionsPriority, ref: live }), [api, chords, id, optionsPriority]);
|
|
290
234
|
}
|
|
291
235
|
function useShortcutRegistry() {
|
|
292
|
-
|
|
293
|
-
if (!api)
|
|
236
|
+
let api = use(ShortcutContext);
|
|
237
|
+
if (!api)
|
|
294
238
|
throw new Error(
|
|
295
239
|
"useShortcutRegistry must be used within <KeyboardShortcutsProvider>."
|
|
296
240
|
);
|
|
297
|
-
}
|
|
298
241
|
return { list: api.list };
|
|
299
242
|
}
|
|
300
243
|
function formatShortcut(source) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const tokens = [];
|
|
304
|
-
const push = (name) => tokens.push(labels[name] ?? name);
|
|
305
|
-
if (isMacPlatform()) {
|
|
306
|
-
if (chord.ctrl) push("ctrl");
|
|
307
|
-
if (chord.alt) push("alt");
|
|
308
|
-
if (chord.shift) push("shift");
|
|
309
|
-
if (chord.meta) push("meta");
|
|
310
|
-
} else {
|
|
311
|
-
if (chord.meta) push("meta");
|
|
312
|
-
if (chord.ctrl) push("ctrl");
|
|
313
|
-
if (chord.alt) push("alt");
|
|
314
|
-
if (chord.shift) push("shift");
|
|
315
|
-
}
|
|
316
|
-
tokens.push(
|
|
244
|
+
let chord = parseChord(source), labels = isMacPlatform() ? SYMBOLS_MAC : LABELS_OTHER, tokens = [], push = (name) => tokens.push(labels[name] ?? name);
|
|
245
|
+
return isMacPlatform() ? (chord.ctrl && push("ctrl"), chord.alt && push("alt"), chord.shift && push("shift"), chord.meta && push("meta")) : (chord.meta && push("meta"), chord.ctrl && push("ctrl"), chord.alt && push("alt"), chord.shift && push("shift")), tokens.push(
|
|
317
246
|
labels[chord.key] ?? (chord.key.length === 1 ? chord.key.toUpperCase() : chord.key.replace(/^\w/, (character) => character.toUpperCase()))
|
|
318
|
-
);
|
|
319
|
-
return tokens;
|
|
247
|
+
), tokens;
|
|
320
248
|
}
|
|
321
249
|
export {
|
|
322
250
|
KeyboardShortcutsProvider,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { ReactNode, AnchorHTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
declare const buttonVariants: (props?: ({
|
|
6
|
+
variant?: "solid" | "soft" | "outline" | "ghost" | null | undefined;
|
|
7
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
8
|
+
iconOnly?: boolean | null | undefined;
|
|
9
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
10
|
+
type ButtonVariantProps = VariantProps<typeof buttonVariants>;
|
|
11
|
+
|
|
12
|
+
declare const linkVariants: (props?: ({
|
|
13
|
+
color?: "accent" | "default" | null | undefined;
|
|
14
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
15
|
+
variant?: "inline" | "standalone" | null | undefined;
|
|
16
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
17
|
+
type LinkVariantProps = VariantProps<typeof linkVariants>;
|
|
18
|
+
type LinkStyleVariant = NonNullable<LinkVariantProps["variant"]>;
|
|
19
|
+
type LinkButtonVariant = `button.${NonNullable<ButtonVariantProps["variant"]>}`;
|
|
20
|
+
type LinkVariant = `link.${LinkStyleVariant}` | LinkButtonVariant;
|
|
21
|
+
type NamedLinkColor = "accent" | "default";
|
|
22
|
+
type LinkColor = NamedLinkColor | (string & {});
|
|
23
|
+
type LinkProps = {
|
|
24
|
+
active?: boolean;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
color?: LinkColor;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
href?: string;
|
|
29
|
+
iconOnly?: ButtonVariantProps["iconOnly"];
|
|
30
|
+
leftIcon?: ReactNode;
|
|
31
|
+
rightIcon?: ReactNode;
|
|
32
|
+
variant?: LinkVariant;
|
|
33
|
+
} & Omit<LinkVariantProps, "color" | "variant"> & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "color" | "href">;
|
|
34
|
+
|
|
35
|
+
export type { LinkProps as L, LinkStyleVariant as a, LinkButtonVariant as b };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IndexPageProps, PageProps, ManifestLike, LayoutProps } from '../types.js';
|
|
3
3
|
|
|
4
4
|
type ResolvedLeaf = PageProps;
|
|
5
5
|
type ResolvedGroup = Omit<IndexPageProps, "children">;
|
|
6
6
|
declare function resolveLeaf(manifest: ManifestLike, group: string, slug: string | string[]): ResolvedLeaf | null;
|
|
7
7
|
declare function resolveGroup(manifest: ManifestLike, group: string): ResolvedGroup | null;
|
|
8
|
-
declare function resolveGroupLayout(manifest: ManifestLike, group: string, children:
|
|
8
|
+
declare function resolveGroupLayout(manifest: ManifestLike, group: string, children: React.ReactNode): LayoutProps | null;
|
|
9
9
|
declare function listStaticParams(manifest: ManifestLike, group: string): Array<{
|
|
10
10
|
slug: string[];
|
|
11
11
|
}>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/manifest-resolver.ts
|
|
2
2
|
function findNodeInTree(nodes, id) {
|
|
3
|
-
for (
|
|
3
|
+
for (let node of nodes) {
|
|
4
4
|
if (node.type === "page") {
|
|
5
5
|
if (node.fileID === id) return node;
|
|
6
|
-
} else if (node.id === id)
|
|
6
|
+
} else if (node.id === id)
|
|
7
7
|
return node;
|
|
8
|
-
}
|
|
9
8
|
if (node.type === "section" || node.type === "folder") {
|
|
10
|
-
|
|
9
|
+
let found = findNodeInTree(node.children, id);
|
|
11
10
|
if (found) return found;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
@@ -40,40 +39,35 @@ function groupNode(group) {
|
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
function resolveLeaf(manifest, group, slug) {
|
|
43
|
-
|
|
44
|
-
const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
|
|
42
|
+
let slugPath = Array.isArray(slug) ? slug.join("/") : slug, page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
|
|
45
43
|
if (!page) return null;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return {
|
|
44
|
+
let groupData = manifest.groups[group];
|
|
45
|
+
return groupData ? {
|
|
49
46
|
site: manifest.site,
|
|
50
47
|
tree: groupData.tree,
|
|
51
48
|
node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(page),
|
|
52
49
|
page,
|
|
53
50
|
currentPath: page.path,
|
|
54
51
|
group
|
|
55
|
-
};
|
|
52
|
+
} : null;
|
|
56
53
|
}
|
|
57
54
|
function resolveGroup(manifest, group) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
55
|
+
let groupData = manifest.groups[group];
|
|
56
|
+
return groupData ? {
|
|
61
57
|
site: manifest.site,
|
|
62
58
|
tree: groupData.tree,
|
|
63
59
|
node: groupNode(groupData),
|
|
64
60
|
currentPath: groupData.path,
|
|
65
61
|
group
|
|
66
|
-
};
|
|
62
|
+
} : null;
|
|
67
63
|
}
|
|
68
64
|
function resolveGroupLayout(manifest, group, children) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return { ...resolved, children };
|
|
65
|
+
let resolved = resolveGroup(manifest, group);
|
|
66
|
+
return resolved ? { ...resolved, children } : null;
|
|
72
67
|
}
|
|
73
68
|
function listStaticParams(manifest, group) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
|
|
69
|
+
let groupData = manifest.groups[group];
|
|
70
|
+
return groupData ? groupData.pages.map((page) => ({ slug: page.slug.split("/") })) : [];
|
|
77
71
|
}
|
|
78
72
|
export {
|
|
79
73
|
listStaticParams,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type OgImageEntryLike = {
|
|
2
|
+
key: string;
|
|
3
|
+
routePath: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
source: "asset" | "generated" | "remote";
|
|
7
|
+
url: string;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
alt: string;
|
|
11
|
+
group?: string;
|
|
12
|
+
logo?: {
|
|
13
|
+
dataUri?: string;
|
|
14
|
+
height?: number;
|
|
15
|
+
kind: "logo" | "mark" | "wordmark";
|
|
16
|
+
url: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
};
|
|
19
|
+
siteName?: string;
|
|
20
|
+
siteUrl?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
background?: string;
|
|
23
|
+
textPrimary?: string;
|
|
24
|
+
textSecondary?: string;
|
|
25
|
+
accent?: string;
|
|
26
|
+
stroke?: string;
|
|
27
|
+
theme?: "light" | "dark";
|
|
28
|
+
fonts?: {
|
|
29
|
+
main: OgFontRoleLike;
|
|
30
|
+
mono: OgFontRoleLike;
|
|
31
|
+
};
|
|
32
|
+
emoji?: Readonly<Record<string, string>>;
|
|
33
|
+
fallbackGlyphs?: Partial<Record<"main" | "mono", Readonly<Record<string, string>>>>;
|
|
34
|
+
fallbackFonts?: ReadonlyArray<{
|
|
35
|
+
family: string;
|
|
36
|
+
data: string;
|
|
37
|
+
style: "normal" | "italic";
|
|
38
|
+
weight: number;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
type OgManifestLike = {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
generated: Record<string, OgImageEntryLike>;
|
|
45
|
+
};
|
|
46
|
+
type OgFontRoleLike = {
|
|
47
|
+
family: string;
|
|
48
|
+
files?: ReadonlyArray<{
|
|
49
|
+
data: string;
|
|
50
|
+
path?: string;
|
|
51
|
+
probe?: string;
|
|
52
|
+
style: "normal" | "italic";
|
|
53
|
+
weight: number;
|
|
54
|
+
}>;
|
|
55
|
+
sourceType: "google" | "local";
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type { OgManifestLike as O };
|
package/dist/search.d.ts
CHANGED
|
@@ -1,7 +1,84 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { RefObject, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type SearchInput = {
|
|
5
|
+
filters?: {
|
|
6
|
+
author?: string;
|
|
7
|
+
group?: string;
|
|
8
|
+
tag?: string;
|
|
9
|
+
};
|
|
10
|
+
limit?: number;
|
|
11
|
+
offset?: number;
|
|
12
|
+
q: string;
|
|
13
|
+
};
|
|
14
|
+
type SearchStatus = "idle" | "building" | "stale" | "ready" | "error";
|
|
15
|
+
type SearchSubResult = {
|
|
16
|
+
excerpt: string;
|
|
17
|
+
plainExcerpt: string;
|
|
18
|
+
title: string;
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
|
+
type SearchResult = {
|
|
22
|
+
excerpt: string;
|
|
23
|
+
id: string;
|
|
24
|
+
meta: {
|
|
25
|
+
author?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
group?: string;
|
|
28
|
+
image?: string;
|
|
29
|
+
nodeId?: string;
|
|
30
|
+
path?: string;
|
|
31
|
+
publishedAt?: string;
|
|
32
|
+
section?: string;
|
|
33
|
+
tags?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
updatedAt?: string;
|
|
36
|
+
};
|
|
37
|
+
plainExcerpt: string;
|
|
38
|
+
score?: number;
|
|
39
|
+
subResults: SearchSubResult[];
|
|
40
|
+
title: string;
|
|
41
|
+
url: string;
|
|
42
|
+
};
|
|
43
|
+
type SearchOutput = {
|
|
44
|
+
items: SearchResult[];
|
|
45
|
+
message?: string;
|
|
46
|
+
nextOffset: number | null;
|
|
47
|
+
status: SearchStatus;
|
|
48
|
+
total: number;
|
|
49
|
+
};
|
|
50
|
+
type SearchBlockVariant = "desktop" | "mobile";
|
|
51
|
+
type SearchBlockState = {
|
|
52
|
+
displayResults: SearchResult[];
|
|
53
|
+
isTyping: boolean;
|
|
54
|
+
loading: boolean;
|
|
55
|
+
message?: string;
|
|
56
|
+
open: boolean;
|
|
57
|
+
query: string;
|
|
58
|
+
selectedValue: string;
|
|
59
|
+
status: SearchStatus;
|
|
60
|
+
total: number;
|
|
61
|
+
};
|
|
62
|
+
type SearchBlockActions = {
|
|
63
|
+
handleInputChange(value: string): void;
|
|
64
|
+
navigateToResult(result: SearchResult): void;
|
|
65
|
+
setOpen(open: boolean): void;
|
|
66
|
+
setQuery(value: string): void;
|
|
67
|
+
setSelectedValue(id: string): void;
|
|
68
|
+
};
|
|
69
|
+
type SearchBlockMeta = {
|
|
70
|
+
inputId: string;
|
|
71
|
+
inputRef: RefObject<HTMLInputElement | null>;
|
|
72
|
+
listId: string;
|
|
73
|
+
listRef: RefObject<HTMLDivElement | null>;
|
|
74
|
+
shortcut: string;
|
|
75
|
+
variant: SearchBlockVariant;
|
|
76
|
+
};
|
|
77
|
+
type SearchBlockContextValue = {
|
|
78
|
+
actions: SearchBlockActions;
|
|
79
|
+
meta: SearchBlockMeta;
|
|
80
|
+
state: SearchBlockState;
|
|
81
|
+
};
|
|
5
82
|
|
|
6
83
|
declare function search(input: SearchInput): Promise<SearchOutput>;
|
|
7
84
|
declare function useSearch(input: SearchInput): SearchOutput;
|
|
@@ -17,4 +94,4 @@ type SearchProviderProps = {
|
|
|
17
94
|
};
|
|
18
95
|
declare function SearchProvider({ children, defaultOpen, limit, onOpenChange, open: controlledOpen, shortcut, variant, }: SearchProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
96
|
|
|
20
|
-
export { SearchProvider, type SearchProviderProps, search, useSearch, useSearchBlock };
|
|
97
|
+
export { type SearchBlockActions, type SearchBlockContextValue, type SearchBlockMeta, type SearchBlockState, type SearchBlockVariant, type SearchInput, type SearchOutput, SearchProvider, type SearchProviderProps, type SearchResult, type SearchStatus, type SearchSubResult, search, useSearch, useSearchBlock };
|