@popmelt.com/core 0.20.3 → 0.21.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.
package/dist/media.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { d as ImageObjectBox, e as VideoSubjectStore, f as VideoObjectBox } from './video-adapter-C5qDzl4Q.mjs';
2
- export { B as BrowserImageSubjectStoreOptions, g as ImageContentHasher, h as ImageObjectObservation, I as ImageRecognitionProvider, i as ImageSubjectAdapter, b as ImageSubjectAdapterOptions, j as ImageSubjectStore, P as PersistedImageAnalysis, k as PersistedImageSubject, l as PersistedImageSuppression, m as PersistedVideoAnalysis, n as PersistedVideoTrack, o as VideoBackwardAnalysisOptions, p as VideoBackwardAnalysisResult, q as VideoMotionAttempt, r as VideoMotionPolicy, s as VideoMotionPresenceDecision, t as VideoMotionState, u as VideoSegmentationObservation, v as VideoSegmentationPoint, a as VideoSegmentationProvider, w as VideoSubjectAdapter, c as VideoSubjectAdapterOptions, x as VideoTrackKeyframe, y as VideoTrackObservation, z as VideoTrackSegment, A as VideoTrackSmoother, C as VideoTrackingAnchor, D as VideoTrackingAttempt, V as VideoTrackingProvider, E as VideoTrackingSeed, F as VideoTrackingSession, G as createBrowserImageSubjectStore, H as createImageSubjectAdapter, J as createMemoryImageSubjectStore, K as createVideoSubjectAdapter } from './video-adapter-C5qDzl4Q.mjs';
1
+ import { d as ImageObjectBox, e as VideoSubjectStore, f as VideoObjectBox } from './video-adapter-CCLbp86L.mjs';
2
+ export { B as BrowserImageSubjectStoreOptions, g as ImageContentHasher, h as ImageObjectObservation, a as ImageRecognitionProvider, i as ImageSubjectAdapter, I as ImageSubjectAdapterOptions, j as ImageSubjectStore, P as PersistedImageAnalysis, k as PersistedImageSubject, l as PersistedImageSuppression, m as PersistedVideoAnalysis, n as PersistedVideoTrack, o as VideoBackwardAnalysisOptions, p as VideoBackwardAnalysisResult, q as VideoMotionAttempt, r as VideoMotionPolicy, s as VideoMotionPresenceDecision, t as VideoMotionState, u as VideoSegmentationObservation, v as VideoSegmentationPoint, c as VideoSegmentationProvider, w as VideoSubjectAdapter, V as VideoSubjectAdapterOptions, x as VideoTrackKeyframe, y as VideoTrackObservation, z as VideoTrackSegment, A as VideoTrackSmoother, C as VideoTrackingAnchor, D as VideoTrackingAttempt, b as VideoTrackingProvider, E as VideoTrackingSeed, F as VideoTrackingSession, G as createBrowserImageSubjectStore, H as createImageSubjectAdapter, J as createMemoryImageSubjectStore, K as createVideoSubjectAdapter } from './video-adapter-CCLbp86L.mjs';
3
3
  import { g as PopmeltSubjectBounds } from './subjects-DzjWdlAk.mjs';
4
4
 
5
5
  declare function unprojectImagePoint(image: HTMLImageElement, clientPoint: {
@@ -0,0 +1,66 @@
1
+ import { A as Annotation, P as PopmeltSubjectAdapter } from './subjects-DzjWdlAk.mjs';
2
+ import { a as ImageRecognitionProvider, b as VideoTrackingProvider, c as VideoSegmentationProvider, I as ImageSubjectAdapterOptions, V as VideoSubjectAdapterOptions } from './video-adapter-CCLbp86L.mjs';
3
+
4
+ type CommentMetaValue = null | boolean | number | string | CommentMetaValue[] | {
5
+ [key: string]: CommentMetaValue;
6
+ };
7
+ /** User-owned, JSON-serializable context captured with a human comment turn. */
8
+ type CommentMeta = Record<string, CommentMetaValue>;
9
+ type CommentMetaContext = {
10
+ kind: 'annotation';
11
+ /** Read-only inspection uses the same collector without submitting a comment. */
12
+ purpose?: 'inspection';
13
+ timestamp: number;
14
+ url: string;
15
+ pathname: string;
16
+ annotations: readonly Readonly<Annotation>[];
17
+ } | {
18
+ kind: 'reply';
19
+ timestamp: number;
20
+ url: string;
21
+ pathname: string;
22
+ threadId: string;
23
+ reply: string;
24
+ annotations: readonly Readonly<Annotation>[];
25
+ };
26
+ type GetCommentMeta = (context: CommentMetaContext) => CommentMeta | undefined | Promise<CommentMeta | undefined>;
27
+
28
+ type PopmeltExtensionRuntime = {
29
+ /** Optional perception contribution for Core's built-in image adapter. */
30
+ imageRecognition?: ImageRecognitionProvider;
31
+ /** Optional perception contribution for Core's built-in video adapter. */
32
+ videoTracking?: VideoTrackingProvider;
33
+ /** Optional point-prompted perception for Core's built-in video adapter. */
34
+ videoSegmentation?: VideoSegmentationProvider;
35
+ /** Optional non-DOM subject adapters contributed by the extension. */
36
+ subjectAdapters?: readonly PopmeltSubjectAdapter[];
37
+ /** Release extension-owned resources. */
38
+ dispose?(): void | Promise<void>;
39
+ };
40
+ type PopmeltExtension = {
41
+ /** Stable package-level identity used to reconcile extension configuration. */
42
+ id: string;
43
+ /** Stable signature for configuration changes that require reactivation. */
44
+ configurationKey: string;
45
+ /** Activate lazily after the Core provider mounts in the browser. */
46
+ activate(): PopmeltExtensionRuntime;
47
+ };
48
+
49
+ /** Host integration options, independent of the UI renderer. */
50
+ type PopmeltOptions = {
51
+ enabled?: boolean;
52
+ bridgeUrl?: string;
53
+ /** Stable project id generated by the framework plugin/bridge startup. */
54
+ projectId?: string | null;
55
+ /** Host router navigation, used for multi-page screenshot capture. */
56
+ navigate?: (url: string) => void | Promise<unknown>;
57
+ subjectAdapters?: readonly PopmeltSubjectAdapter[];
58
+ extensions?: readonly PopmeltExtension[];
59
+ /** Manual media annotation is enabled by default. */
60
+ imageAnnotation?: boolean | Omit<ImageSubjectAdapterOptions, 'id'>;
61
+ videoAnnotation?: boolean | Omit<VideoSubjectAdapterOptions, 'id'>;
62
+ /** Capture application-owned JSON context with each submitted human turn. */
63
+ getCommentMeta?: GetCommentMeta;
64
+ };
65
+
66
+ export type { CommentMeta as C, GetCommentMeta as G, PopmeltOptions as P, CommentMetaContext as a, CommentMetaValue as b, PopmeltExtension as c, PopmeltExtensionRuntime as d };
@@ -1,14 +1,31 @@
1
- import { P as PopmeltPluginOptions, D as DevServerLike } from './dev-server-rQIWJcSX.mjs';
1
+ import { P as PopmeltPluginOptions } from './dev-server-rQIWJcSX.mjs';
2
+ import { popmelt as popmelt$1 } from './plugin-vite.mjs';
2
3
  import 'node:http';
3
4
 
4
- type AstroIntegration = {
5
+ type PopmeltAstroOptions = PopmeltPluginOptions & {
6
+ /** Set false when an existing provider mounts the UI. */
7
+ client?: boolean;
8
+ };
9
+ type AstroSetup = {
10
+ command: 'dev' | 'build' | 'preview' | 'sync';
11
+ config: {
12
+ root: URL;
13
+ };
14
+ updateConfig: (config: {
15
+ vite: {
16
+ plugins: ReturnType<typeof popmelt$1>[];
17
+ optimizeDeps: {
18
+ include: string[];
19
+ };
20
+ };
21
+ }) => unknown;
22
+ injectScript: (stage: 'page', script: string) => void;
23
+ };
24
+ declare function popmelt(options?: PopmeltAstroOptions): {
5
25
  name: string;
6
26
  hooks: {
7
- 'astro:server:setup': (options: {
8
- server: DevServerLike;
9
- }) => Promise<void>;
27
+ 'astro:config:setup'({ command, config, updateConfig, injectScript, }: AstroSetup): void;
10
28
  };
11
29
  };
12
- declare function popmelt(options?: PopmeltPluginOptions): AstroIntegration;
13
30
 
14
- export { popmelt };
31
+ export { type PopmeltAstroOptions, popmelt };
@@ -1 +1,31 @@
1
- import{a as p,b as d,c as l,d as g}from"./chunk-MEDUDCL6.mjs";import"./chunk-NOHXTT24.mjs";import{Buffer as c}from"buffer";function u(e){return typeof e=="string"?e:e instanceof Uint8Array?c.from(e).toString("utf8"):String(e??"")}function m(e,t,r){let o=e.url||"";if(r.port===null||!(e.headers.accept?.includes("text/html")||o==="/"||o.endsWith(".html")))return;let a=t.write.bind(t),s=t.end.bind(t),n="";t.write=(i=>(n+=u(i),!0)),t.end=(i=>(i!==void 0&&(n+=u(i)),n=n.replace("<head>",`<head><script type="text/javascript">${g(r)}</script>`),t.getHeader("content-length")&&t.setHeader("content-length",c.byteLength(n)),a(n,"utf8"),s()))}function y(e){let t=e?.basePath??"/popmelt",r={port:null,projectId:null};return{name:"popmelt",hooks:{async"astro:server:setup"({server:o}){r=await p(e,o,4321),await d(r,o);let a=l(t,()=>r);o.middlewares.use((s,n,i)=>{if((s.url||"").startsWith(t))return a(s,n,i);m(s,n,r),i()})}}}}export{y as popmelt};
1
+ import{a as o}from"./chunk-OY63KT72.mjs";import"./chunk-V25ZE6LB.mjs";import"./chunk-NOHXTT24.mjs";import{fileURLToPath as a}from"url";function c(t={}){return{name:"popmelt",hooks:{"astro:config:setup"({command:r,config:i,updateConfig:n,injectScript:p}){if(r!=="dev")return;let{client:e=!0,...s}=t;n({vite:{plugins:[o({...s,projectRoot:t.projectRoot??a(i.root)})],optimizeDeps:{include:e?["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"]:[]}}}),p("page",e?d:`
2
+ import { bridgeUrl, projectId } from 'virtual:popmelt/bridge';
3
+ if (bridgeUrl) window.__POPMELT_BRIDGE_URL__ = bridgeUrl;
4
+ if (projectId) window.__POPMELT_PROJECT_ID__ = projectId;
5
+ `)}}}}var d=`
6
+ import { bridgeUrl, projectId } from 'virtual:popmelt/bridge';
7
+ import { navigate } from 'astro:transitions/client';
8
+ let disposed = false;
9
+ let mounting;
10
+ const start = () => {
11
+ if (disposed || mounting || !bridgeUrl || !projectId) return;
12
+ mounting = Promise.resolve(import.meta.hot?.data.cleanup).then(async () => {
13
+ if (disposed) return;
14
+ const { mountPopmelt } = await import('@popmelt.com/core/browser');
15
+ if (disposed) return;
16
+ const handle = await mountPopmelt({ enabled: true, bridgeUrl, projectId, navigate });
17
+ return handle;
18
+ }).catch(error => { console.warn('[popmelt] startup failed:', error); });
19
+ };
20
+ // The standalone hosts live outside body, so Astro's body swaps retain them.
21
+ document.addEventListener('astro:page-load', start);
22
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true });
23
+ else start();
24
+ import.meta.hot?.dispose(data => {
25
+ if (disposed) return;
26
+ disposed = true;
27
+ document.removeEventListener('astro:page-load', start);
28
+ document.removeEventListener('DOMContentLoaded', start);
29
+ data.cleanup = mounting?.then(handle => handle?.unmount());
30
+ });
31
+ `;export{c as popmelt};
@@ -0,0 +1,8 @@
1
+ import { NuxtModule } from 'nuxt/schema';
2
+ import { P as PopmeltPluginOptions } from './dev-server-rQIWJcSX.mjs';
3
+ import 'node:http';
4
+
5
+ type PopmeltNuxtOptions = Pick<PopmeltPluginOptions, 'port' | 'projectRoot' | 'bridge'>;
6
+ declare const popmeltNuxt: NuxtModule<PopmeltNuxtOptions>;
7
+
8
+ export { type PopmeltNuxtOptions, popmeltNuxt as default };
@@ -0,0 +1,29 @@
1
+ import{a as s,b as d}from"./chunk-V25ZE6LB.mjs";import{b as i}from"./chunk-NOHXTT24.mjs";import{addPluginTemplate as l,defineNuxtModule as m}from"nuxt/kit";var a=m({meta:{name:"@popmelt.com/core/nuxt",configKey:"popmelt"},async setup(n,e){if(!e.options.dev)return;let p={config:{server:e.options.devServer},middlewares:{use(){}}},t=await s({...n,projectRoot:n.projectRoot??e.options.rootDir},p,3e3);if(t.port===null)return;e.hook("vite:extend",({config:r})=>{r.optimizeDeps??={},r.optimizeDeps.include=[...new Set([...r.optimizeDeps.include??[],"react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"])]});let o=await d(t,p),u=o?i(o):void 0;e.hook("close",async()=>{u?.(),await o?.release()}),l({filename:"popmelt.client.mjs",mode:"client",getContents:()=>`import { defineNuxtPlugin } from '#app';
2
+ export default defineNuxtPlugin((nuxtApp) => {
3
+ let disposed = false;
4
+ let mounting;
5
+ const bridgeUrl = ${JSON.stringify(`http://localhost:${t.port}`)};
6
+ const projectId = ${JSON.stringify(t.projectId)};
7
+ const dispose = () => {
8
+ if (disposed) return;
9
+ disposed = true;
10
+ void mounting?.then(handle => handle?.unmount());
11
+ };
12
+ nuxtApp.hook('app:mounted', () => {
13
+ if (disposed || mounting) return;
14
+ mounting = import('@popmelt.com/core/browser').then(({ mountPopmelt }) => {
15
+ if (disposed) return;
16
+ return mountPopmelt({
17
+ enabled: true,
18
+ bridgeUrl,
19
+ projectId,
20
+ navigate: (url) => nuxtApp.$router.push(url),
21
+ });
22
+ }).then(handle => {
23
+ if (disposed) handle?.unmount();
24
+ return handle;
25
+ }).catch(error => { console.warn('[popmelt] startup failed:', error); });
26
+ });
27
+ nuxtApp.vueApp.onUnmount(dispose);
28
+ import.meta.hot?.dispose(dispose);
29
+ });`})}}),h=a;export{h as default};
@@ -3,12 +3,14 @@ import 'node:http';
3
3
 
4
4
  type Plugin = {
5
5
  name: string;
6
+ resolveId: (id: string) => string | undefined;
7
+ load: (id: string) => string | undefined;
6
8
  configureServer: (server: DevServerLike) => Promise<void>;
7
9
  transformIndexHtml: () => {
8
10
  tag: string;
9
11
  attrs: Record<string, string>;
10
12
  children: string;
11
- injectTo: string;
13
+ injectTo: 'head-prepend';
12
14
  }[] | undefined;
13
15
  };
14
16
  declare function popmelt(options?: PopmeltPluginOptions): Plugin;
@@ -1 +1 @@
1
- import{a as n,b as i,c as o,d as a}from"./chunk-MEDUDCL6.mjs";import"./chunk-NOHXTT24.mjs";function s(r){let d=r?.basePath??"/popmelt",e={port:null,projectId:null};return{name:"popmelt",async configureServer(t){e=await n(r,t,5173),await i(e,t),t.middlewares.use(o(d,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:a(e),injectTo:"head-prepend"}]}}}export{s as popmelt};
1
+ import{a}from"./chunk-OY63KT72.mjs";import"./chunk-V25ZE6LB.mjs";import"./chunk-NOHXTT24.mjs";export{a as popmelt};