@copilotkitnext/web-inspector 1.51.4-next.7 → 1.51.4-next.8
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/CHANGELOG.md +6 -0
- package/dist/index.js +594 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +594 -189
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +388 -139
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/web-inspector.spec.ts +25 -9
- package/src/components.d.ts +6 -10
- package/src/index.ts +958 -373
- package/src/lib/context-helpers.ts +60 -19
- package/src/lib/persistence.ts +16 -11
- package/src/lib/types.ts +4 -4
- package/tsup.config.ts +7 -7
- package/.turbo/turbo-build$colon$css.log +0 -7
- package/.turbo/turbo-build.log +0 -36
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Anchor, ContextState, Position, Size } from
|
|
1
|
+
import type { Anchor, ContextState, Position, Size } from "./types";
|
|
2
2
|
|
|
3
3
|
export function updateSizeFromElement(
|
|
4
4
|
state: ContextState,
|
|
@@ -34,8 +34,14 @@ export function constrainToViewport(
|
|
|
34
34
|
viewport: Size,
|
|
35
35
|
edgeMargin: number,
|
|
36
36
|
): Position {
|
|
37
|
-
const maxX = Math.max(
|
|
38
|
-
|
|
37
|
+
const maxX = Math.max(
|
|
38
|
+
edgeMargin,
|
|
39
|
+
viewport.width - state.size.width - edgeMargin,
|
|
40
|
+
);
|
|
41
|
+
const maxY = Math.max(
|
|
42
|
+
edgeMargin,
|
|
43
|
+
viewport.height - state.size.height - edgeMargin,
|
|
44
|
+
);
|
|
39
45
|
|
|
40
46
|
return {
|
|
41
47
|
x: clamp(position.x, edgeMargin, maxX),
|
|
@@ -48,7 +54,12 @@ export function keepPositionWithinViewport(
|
|
|
48
54
|
viewport: Size,
|
|
49
55
|
edgeMargin: number,
|
|
50
56
|
): void {
|
|
51
|
-
state.position = constrainToViewport(
|
|
57
|
+
state.position = constrainToViewport(
|
|
58
|
+
state,
|
|
59
|
+
state.position,
|
|
60
|
+
viewport,
|
|
61
|
+
edgeMargin,
|
|
62
|
+
);
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
export function centerContext(
|
|
@@ -74,23 +85,39 @@ export function updateAnchorFromPosition(
|
|
|
74
85
|
const centerX = state.position.x + state.size.width / 2;
|
|
75
86
|
const centerY = state.position.y + state.size.height / 2;
|
|
76
87
|
|
|
77
|
-
const horizontal: Anchor[
|
|
78
|
-
|
|
88
|
+
const horizontal: Anchor["horizontal"] =
|
|
89
|
+
centerX < viewport.width / 2 ? "left" : "right";
|
|
90
|
+
const vertical: Anchor["vertical"] =
|
|
91
|
+
centerY < viewport.height / 2 ? "top" : "bottom";
|
|
79
92
|
|
|
80
93
|
state.anchor = { horizontal, vertical };
|
|
81
94
|
|
|
82
|
-
const maxHorizontalOffset = Math.max(
|
|
83
|
-
|
|
95
|
+
const maxHorizontalOffset = Math.max(
|
|
96
|
+
edgeMargin,
|
|
97
|
+
viewport.width - state.size.width - edgeMargin,
|
|
98
|
+
);
|
|
99
|
+
const maxVerticalOffset = Math.max(
|
|
100
|
+
edgeMargin,
|
|
101
|
+
viewport.height - state.size.height - edgeMargin,
|
|
102
|
+
);
|
|
84
103
|
|
|
85
104
|
state.anchorOffset = {
|
|
86
105
|
x:
|
|
87
|
-
horizontal ===
|
|
106
|
+
horizontal === "left"
|
|
88
107
|
? clamp(state.position.x, edgeMargin, maxHorizontalOffset)
|
|
89
|
-
: clamp(
|
|
108
|
+
: clamp(
|
|
109
|
+
viewport.width - state.position.x - state.size.width,
|
|
110
|
+
edgeMargin,
|
|
111
|
+
maxHorizontalOffset,
|
|
112
|
+
),
|
|
90
113
|
y:
|
|
91
|
-
vertical ===
|
|
114
|
+
vertical === "top"
|
|
92
115
|
? clamp(state.position.y, edgeMargin, maxVerticalOffset)
|
|
93
|
-
: clamp(
|
|
116
|
+
: clamp(
|
|
117
|
+
viewport.height - state.position.y - state.size.height,
|
|
118
|
+
edgeMargin,
|
|
119
|
+
maxVerticalOffset,
|
|
120
|
+
),
|
|
94
121
|
};
|
|
95
122
|
}
|
|
96
123
|
|
|
@@ -99,19 +126,33 @@ export function applyAnchorPosition(
|
|
|
99
126
|
viewport: Size,
|
|
100
127
|
edgeMargin: number,
|
|
101
128
|
): Position {
|
|
102
|
-
const maxHorizontalOffset = Math.max(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
129
|
+
const maxHorizontalOffset = Math.max(
|
|
130
|
+
edgeMargin,
|
|
131
|
+
viewport.width - state.size.width - edgeMargin,
|
|
132
|
+
);
|
|
133
|
+
const maxVerticalOffset = Math.max(
|
|
134
|
+
edgeMargin,
|
|
135
|
+
viewport.height - state.size.height - edgeMargin,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const horizontalOffset = clamp(
|
|
139
|
+
state.anchorOffset.x,
|
|
140
|
+
edgeMargin,
|
|
141
|
+
maxHorizontalOffset,
|
|
142
|
+
);
|
|
143
|
+
const verticalOffset = clamp(
|
|
144
|
+
state.anchorOffset.y,
|
|
145
|
+
edgeMargin,
|
|
146
|
+
maxVerticalOffset,
|
|
147
|
+
);
|
|
107
148
|
|
|
108
149
|
const x =
|
|
109
|
-
state.anchor.horizontal ===
|
|
150
|
+
state.anchor.horizontal === "left"
|
|
110
151
|
? horizontalOffset
|
|
111
152
|
: viewport.width - state.size.width - horizontalOffset;
|
|
112
153
|
|
|
113
154
|
const y =
|
|
114
|
-
state.anchor.vertical ===
|
|
155
|
+
state.anchor.vertical === "top"
|
|
115
156
|
? verticalOffset
|
|
116
157
|
: viewport.height - state.size.height - verticalOffset;
|
|
117
158
|
|
package/src/lib/persistence.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Anchor, DockMode, Position, Size } from
|
|
1
|
+
import type { Anchor, DockMode, Position, Size } from "./types";
|
|
2
2
|
|
|
3
3
|
export type PersistedContextState = {
|
|
4
4
|
anchor?: Anchor;
|
|
@@ -8,7 +8,7 @@ export type PersistedContextState = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export type PersistedState = {
|
|
11
|
-
button?: Omit<PersistedContextState,
|
|
11
|
+
button?: Omit<PersistedContextState, "size">;
|
|
12
12
|
window?: PersistedContextState;
|
|
13
13
|
isOpen?: boolean;
|
|
14
14
|
dockMode?: DockMode;
|
|
@@ -36,7 +36,9 @@ export function loadInspectorState(storageKey: string): PersistedState | null {
|
|
|
36
36
|
// Backwards compatibility: try to read the legacy cookie and migrate it
|
|
37
37
|
if (typeof document !== "undefined") {
|
|
38
38
|
const prefix = `${storageKey}=`;
|
|
39
|
-
const entry = document.cookie
|
|
39
|
+
const entry = document.cookie
|
|
40
|
+
.split("; ")
|
|
41
|
+
.find((cookie) => cookie.startsWith(prefix));
|
|
40
42
|
if (entry) {
|
|
41
43
|
const legacyRaw = entry.substring(prefix.length);
|
|
42
44
|
try {
|
|
@@ -53,7 +55,10 @@ export function loadInspectorState(storageKey: string): PersistedState | null {
|
|
|
53
55
|
return null;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
export function saveInspectorState(
|
|
58
|
+
export function saveInspectorState(
|
|
59
|
+
storageKey: string,
|
|
60
|
+
state: PersistedState,
|
|
61
|
+
): void {
|
|
57
62
|
if (typeof window === "undefined") {
|
|
58
63
|
return;
|
|
59
64
|
}
|
|
@@ -66,19 +71,19 @@ export function saveInspectorState(storageKey: string, state: PersistedState): v
|
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
export function isValidAnchor(value: unknown): value is Anchor {
|
|
69
|
-
if (!value || typeof value !==
|
|
74
|
+
if (!value || typeof value !== "object") {
|
|
70
75
|
return false;
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
const candidate = value as Anchor;
|
|
74
79
|
return (
|
|
75
|
-
(candidate.horizontal ===
|
|
76
|
-
(candidate.vertical ===
|
|
80
|
+
(candidate.horizontal === "left" || candidate.horizontal === "right") &&
|
|
81
|
+
(candidate.vertical === "top" || candidate.vertical === "bottom")
|
|
77
82
|
);
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
export function isValidPosition(value: unknown): value is Position {
|
|
81
|
-
if (!value || typeof value !==
|
|
86
|
+
if (!value || typeof value !== "object") {
|
|
82
87
|
return false;
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -87,7 +92,7 @@ export function isValidPosition(value: unknown): value is Position {
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
export function isValidSize(value: unknown): value is Size {
|
|
90
|
-
if (!value || typeof value !==
|
|
95
|
+
if (!value || typeof value !== "object") {
|
|
91
96
|
return false;
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -96,9 +101,9 @@ export function isValidSize(value: unknown): value is Size {
|
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
export function isFiniteNumber(value: unknown): value is number {
|
|
99
|
-
return typeof value ===
|
|
104
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
export function isValidDockMode(value: unknown): value is DockMode {
|
|
103
|
-
return value ===
|
|
108
|
+
return value === "floating" || value === "docked-left";
|
|
104
109
|
}
|
package/src/lib/types.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export type Position = { x: number; y: number };
|
|
2
2
|
|
|
3
3
|
export type Anchor = {
|
|
4
|
-
horizontal:
|
|
5
|
-
vertical:
|
|
4
|
+
horizontal: "left" | "right";
|
|
5
|
+
vertical: "top" | "bottom";
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export type Size = { width: number; height: number };
|
|
9
9
|
|
|
10
|
-
export type ContextKey =
|
|
10
|
+
export type ContextKey = "button" | "window";
|
|
11
11
|
|
|
12
|
-
export type DockMode =
|
|
12
|
+
export type DockMode = "floating" | "docked-left";
|
|
13
13
|
|
|
14
14
|
export type ContextState = {
|
|
15
15
|
position: Position;
|
package/tsup.config.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineConfig } from
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
entry: [
|
|
5
|
-
format: [
|
|
4
|
+
entry: ["src/index.ts"],
|
|
5
|
+
format: ["cjs", "esm"],
|
|
6
6
|
dts: true,
|
|
7
7
|
sourcemap: true,
|
|
8
8
|
clean: true,
|
|
9
|
-
target:
|
|
10
|
-
outDir:
|
|
9
|
+
target: "es2022",
|
|
10
|
+
outDir: "dist",
|
|
11
11
|
loader: {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
".css": "text",
|
|
13
|
+
".svg": "dataurl",
|
|
14
14
|
},
|
|
15
15
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @copilotkitnext/web-inspector@1.51.4-next.7 build:css /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector
|
|
3
|
-
> npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./src/styles/generated.css -m
|
|
4
|
-
|
|
5
|
-
[3m[1m[34m≈[39m[22m[23m tailwindcss [34mv4.1.18[39m
|
|
6
|
-
|
|
7
|
-
Done in [34m152ms[39m
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @copilotkitnext/web-inspector@1.51.4-next.7 build /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector
|
|
3
|
-
> pnpm run build:ts && rollup -c rollup.config.mjs && pnpm run build:css
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @copilotkitnext/web-inspector@1.51.4-next.7 build:ts /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector
|
|
7
|
-
> tsup
|
|
8
|
-
|
|
9
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
10
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
11
|
-
[34mCLI[39m tsup v8.5.1
|
|
12
|
-
[34mCLI[39m Using tsup config: /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector/tsup.config.ts
|
|
13
|
-
[34mCLI[39m Target: es2022
|
|
14
|
-
[34mCLI[39m Cleaning output folder
|
|
15
|
-
[34mCJS[39m Build start
|
|
16
|
-
[34mESM[39m Build start
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m149.99 KB[39m
|
|
18
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m217.56 KB[39m
|
|
19
|
-
[32mESM[39m ⚡️ Build success in 172ms
|
|
20
|
-
[32mCJS[39m [1mdist/index.js [22m[32m152.17 KB[39m
|
|
21
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m217.59 KB[39m
|
|
22
|
-
[32mCJS[39m ⚡️ Build success in 185ms
|
|
23
|
-
[34mDTS[39m Build start
|
|
24
|
-
[32mDTS[39m ⚡️ Build success in 5128ms
|
|
25
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m6.30 KB[39m
|
|
26
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m6.30 KB[39m
|
|
27
|
-
[36m
|
|
28
|
-
[1msrc/index.ts[22m → [1mdist/index.umd.js[22m...[39m
|
|
29
|
-
[32mcreated [1mdist/index.umd.js[22m in [1m21.4s[22m[39m
|
|
30
|
-
|
|
31
|
-
> @copilotkitnext/web-inspector@1.51.4-next.7 build:css /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector
|
|
32
|
-
> npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./src/styles/generated.css -m
|
|
33
|
-
|
|
34
|
-
[3m[1m[34m≈[39m[22m[23m tailwindcss [34mv4.1.18[39m
|
|
35
|
-
|
|
36
|
-
Done in [34m96ms[39m
|