@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.
@@ -1,4 +1,4 @@
1
- import type { Anchor, ContextState, Position, Size } from './types';
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(edgeMargin, viewport.width - state.size.width - edgeMargin);
38
- const maxY = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
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(state, state.position, viewport, edgeMargin);
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['horizontal'] = centerX < viewport.width / 2 ? 'left' : 'right';
78
- const vertical: Anchor['vertical'] = centerY < viewport.height / 2 ? 'top' : 'bottom';
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(edgeMargin, viewport.width - state.size.width - edgeMargin);
83
- const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
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 === 'left'
106
+ horizontal === "left"
88
107
  ? clamp(state.position.x, edgeMargin, maxHorizontalOffset)
89
- : clamp(viewport.width - state.position.x - state.size.width, edgeMargin, maxHorizontalOffset),
108
+ : clamp(
109
+ viewport.width - state.position.x - state.size.width,
110
+ edgeMargin,
111
+ maxHorizontalOffset,
112
+ ),
90
113
  y:
91
- vertical === 'top'
114
+ vertical === "top"
92
115
  ? clamp(state.position.y, edgeMargin, maxVerticalOffset)
93
- : clamp(viewport.height - state.position.y - state.size.height, edgeMargin, maxVerticalOffset),
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(edgeMargin, viewport.width - state.size.width - edgeMargin);
103
- const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
104
-
105
- const horizontalOffset = clamp(state.anchorOffset.x, edgeMargin, maxHorizontalOffset);
106
- const verticalOffset = clamp(state.anchorOffset.y, edgeMargin, maxVerticalOffset);
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 === 'left'
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 === 'top'
155
+ state.anchor.vertical === "top"
115
156
  ? verticalOffset
116
157
  : viewport.height - state.size.height - verticalOffset;
117
158
 
@@ -1,4 +1,4 @@
1
- import type { Anchor, DockMode, Position, Size } from './types';
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, 'size'>;
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.split("; ").find((cookie) => cookie.startsWith(prefix));
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(storageKey: string, state: PersistedState): void {
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 !== 'object') {
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 === 'left' || candidate.horizontal === 'right') &&
76
- (candidate.vertical === 'top' || candidate.vertical === 'bottom')
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 !== 'object') {
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 !== 'object') {
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 === 'number' && Number.isFinite(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 === 'floating' || value === 'docked-left';
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: 'left' | 'right';
5
- vertical: 'top' | 'bottom';
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 = 'button' | 'window';
10
+ export type ContextKey = "button" | "window";
11
11
 
12
- export type DockMode = 'floating' | 'docked-left';
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 'tsup';
1
+ import { defineConfig } from "tsup";
2
2
 
3
3
  export default defineConfig({
4
- entry: ['src/index.ts'],
5
- format: ['cjs', 'esm'],
4
+ entry: ["src/index.ts"],
5
+ format: ["cjs", "esm"],
6
6
  dts: true,
7
7
  sourcemap: true,
8
8
  clean: true,
9
- target: 'es2022',
10
- outDir: 'dist',
9
+ target: "es2022",
10
+ outDir: "dist",
11
11
  loader: {
12
- '.css': 'text',
13
- '.svg': 'dataurl',
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
- ≈ tailwindcss v4.1.18
6
-
7
- Done in 152ms
@@ -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
- CLI Building entry: src/index.ts
10
- CLI Using tsconfig: tsconfig.json
11
- CLI tsup v8.5.1
12
- CLI Using tsup config: /home/runner/work/CopilotKit/CopilotKit/src/v2.x/packages/web-inspector/tsup.config.ts
13
- CLI Target: es2022
14
- CLI Cleaning output folder
15
- CJS Build start
16
- ESM Build start
17
- ESM dist/index.mjs 149.99 KB
18
- ESM dist/index.mjs.map 217.56 KB
19
- ESM ⚡️ Build success in 172ms
20
- CJS dist/index.js 152.17 KB
21
- CJS dist/index.js.map 217.59 KB
22
- CJS ⚡️ Build success in 185ms
23
- DTS Build start
24
- DTS ⚡️ Build success in 5128ms
25
- DTS dist/index.d.ts 6.30 KB
26
- DTS dist/index.d.mts 6.30 KB
27
- 
28
- src/index.ts → dist/index.umd.js...
29
- created dist/index.umd.js in 21.4s
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
- ≈ tailwindcss v4.1.18
35
-
36
- Done in 96ms