@devaccel-labs/comment-service 0.7.0 → 0.9.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.
@@ -1,7 +1,10 @@
1
1
  export declare function toProjectPath(filename: string, root: string): string;
2
2
  /**
3
- * Stamp the root DOM node of each component with a stable file + component name.
3
+ * Stamp the root node of each component of each component with a stable file + component name.
4
4
  * Line numbers are intentionally not included: moving the component in the file
5
- * or on the page must not change the stamp.
5
+ * or on the page must not change the stamp. A root that is itself a component
6
+ * (`<DropdownMenu>`, `<Menu.Root>`) gets the stamp as a prop: it reaches the DOM when
7
+ * the component spreads its props, and the toolbar reads it from React's tree when
8
+ * the component renders into a portal.
6
9
  */
7
10
  export declare function annotateSource(code: string, filename: string, root: string): string;
@@ -1,2 +1,3 @@
1
1
  export { captureAnchor, resolveInDocument } from "./capture.js";
2
- export { CommentToolbar, type ToolbarPosition, type ToolbarTheme } from "./toolbar.js";
2
+ export { CommentToolbar, type ToolbarSource } from "./loader.js";
3
+ export type { ToolbarPosition, ToolbarProps, ToolbarTheme } from "./toolbar.js";
@@ -0,0 +1,10 @@
1
+ import type { ToolbarProps } from "./toolbar.js";
2
+ export type ToolbarSource = "latest" | "bundled";
3
+ export declare function CommentToolbar({ source, sessionPath, pollMs, position, theme, navigate, }: ToolbarProps & {
4
+ /**
5
+ * "latest" (default) loads the newest compatible toolbar from the comment service, so fixes ship
6
+ * without a dependency upgrade, and falls back to the copy in this package if that fails.
7
+ * "bundled" always uses the copy in this package.
8
+ */
9
+ source?: ToolbarSource;
10
+ }): null;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The contract between the loader in the npm package and the toolbar the Worker serves at
3
+ * `/v1/toolbar/<runtimeVersion>.js`. Bump it only when `mount` or `ToolbarProps` change incompatibly,
4
+ * and commit the last build of the old version under apps/worker/public/v1/toolbar/ first so apps
5
+ * still on it keep working.
6
+ */
7
+ export declare const runtimeVersion = 1;
@@ -0,0 +1,7 @@
1
+ import { type ToolbarProps } from "./toolbar.js";
2
+ export { runtimeVersion } from "./runtime-version.js";
3
+ export type ToolbarHandle = {
4
+ update(props: ToolbarProps): void;
5
+ unmount(): void;
6
+ };
7
+ export declare function mount(container: HTMLElement, props: ToolbarProps): ToolbarHandle;
@@ -1,6 +1,6 @@
1
1
  export type ToolbarPosition = "bottom-left" | "bottom-center" | "bottom-right";
2
2
  export type ToolbarTheme = "light" | "dark" | "system";
3
- export declare function CommentToolbar({ sessionPath, pollMs, position, theme, navigate, }: {
3
+ export type ToolbarProps = {
4
4
  sessionPath?: string;
5
5
  pollMs?: number;
6
6
  /** Default bar position. Each person can override it from their menu. */
@@ -12,4 +12,5 @@ export declare function CommentToolbar({ sessionPath, pollMs, position, theme, n
12
12
  * Without it, selecting a comment from another page does a full page load.
13
13
  */
14
14
  navigate?: (href: string) => void;
15
- }): import("react").ReactPortal | null;
15
+ };
16
+ export declare function ToolbarApp({ sessionPath, pollMs, position, theme, navigate, }: ToolbarProps): import("react").ReactPortal | null;
package/dist/vite.js CHANGED
@@ -58,6 +58,16 @@ function setAttr(path, name, value) {
58
58
  return;
59
59
  path.node.openingElement.attributes.push(t.jsxAttribute(t.jsxIdentifier(name), t.stringLiteral(value)));
60
60
  }
61
+ var unstampable = /^(?:React\.)?(?:Fragment|Suspense|StrictMode|Profiler|Activity|ViewTransition)$|\.(?:Provider|Consumer)$/;
62
+ function jsxName(name) {
63
+ if (t.isJSXIdentifier(name))
64
+ return name.name;
65
+ if (t.isJSXMemberExpression(name)) {
66
+ const object = jsxName(name.object);
67
+ return object ? `${object}.${name.property.name}` : null;
68
+ }
69
+ return null;
70
+ }
61
71
  function annotateSource(code, filename, root) {
62
72
  if (!filename.match(/\.[jt]sx$/))
63
73
  return code;
@@ -77,10 +87,8 @@ function annotateSource(code, filename, root) {
77
87
  let changed = false;
78
88
  traverse()(ast, {
79
89
  JSXElement(path) {
80
- const opening = path.node.openingElement.name;
81
- if (!t.isJSXIdentifier(opening))
82
- return;
83
- if (opening.name[0] !== opening.name[0].toLowerCase())
90
+ const tag = jsxName(path.node.openingElement.name);
91
+ if (!tag || unstampable.test(tag))
84
92
  return;
85
93
  if (!isRootJsx(path))
86
94
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devaccel-labs/comment-service",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "In-UI component comments for TanStack Start on Cloudflare. Anchors survive redeploys.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "esbuild": "^0.28.1",
46
- "@devaccel/comment-core": "0.1.0",
47
46
  "@devaccel/comment-compiler": "0.1.0",
47
+ "@devaccel/comment-core": "0.1.0",
48
48
  "@devaccel/comment-react": "0.1.0",
49
49
  "@devaccel/comment-server": "0.1.0",
50
50
  "@devaccel/comment-start": "0.1.0"