@immense/vue-pom-generator 1.0.116 → 1.0.117
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 +39 -0
- package/RELEASE_NOTES.md +14 -19
- package/dist/index.cjs +51 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +51 -5
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts +27 -1
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/format.d.ts +4 -0
- package/dist/plugin/runtime/annotator/format.d.ts.map +1 -1
- package/dist/tests/annotator-submit.test.d.ts +2 -0
- package/dist/tests/annotator-submit.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/plugin/runtime/annotator/client.ts +98 -10
- package/plugin/runtime/annotator/format.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import createVuePomGeneratorPlugins from "./plugin/create-vue-pom-generator-plugins";
|
|
2
2
|
import { mountAnnotatorClient } from "./plugin/runtime/annotator/client";
|
|
3
|
-
import type { AnnotatorClientOptions } from "./plugin/runtime/annotator/client";
|
|
3
|
+
import type { AnnotatorClientOptions, AnnotatorSubmitHandler } from "./plugin/runtime/annotator/client";
|
|
4
4
|
import type { NuxtPomGeneratorPluginOptions, VuePomGeneratorPluginOptions } from "./plugin/types";
|
|
5
5
|
export { createVuePomGeneratorPlugins };
|
|
6
6
|
export { createVuePomGeneratorPlugins as vuePomGenerator };
|
|
7
7
|
export default createVuePomGeneratorPlugins;
|
|
8
8
|
export { generateVuePoms, type VuePomGenerationViteOptions } from "./plugin/generate-vue-poms";
|
|
9
9
|
export { mountAnnotatorClient };
|
|
10
|
-
export type { AnnotatorClientOptions };
|
|
10
|
+
export type { AnnotatorClientOptions, AnnotatorSubmitHandler };
|
|
11
|
+
export type { FormattedAnnotation } from "./plugin/runtime/annotator/format";
|
|
11
12
|
export declare function defineVuePomGeneratorConfig(options: VuePomGeneratorPluginOptions): VuePomGeneratorPluginOptions;
|
|
12
13
|
export declare function defineNuxtPomGeneratorConfig(options: NuxtPomGeneratorPluginOptions): NuxtPomGeneratorPluginOptions;
|
|
13
14
|
export type { ExistingIdBehavior, ExistingIdBehaviorByComponent, ExistingIdBehaviorConfig, MissingSemanticNameBehavior, NuxtPomGeneratorPluginOptions, PomGeneratorPluginOptions, PomNameCollisionBehavior, VuePomGeneratorPluginOptions, VuePomGeneratorRuntimeOptions, VuePomGeneratorRuntimeAnnotatorOptions, VuePomGeneratorRuntimeAnnotatorUiOptions, } from "./plugin/types";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAExG,OAAO,KAAK,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAIlG,OAAO,EAAE,4BAA4B,EAAE,CAAC;AACxC,OAAO,EAAE,4BAA4B,IAAI,eAAe,EAAE,CAAC;AAC3D,eAAe,4BAA4B,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,4BAA4B,CAE/G;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,6BAA6B,CAOlH;AAED,YAAY,EACV,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,sCAAsC,EACtC,wCAAwC,GACzC,MAAM,gBAAgB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -12347,11 +12347,13 @@ const SETTINGS_STORAGE_KEY = "vpg-annotator-settings";
|
|
|
12347
12347
|
const ANNOTATIONS_STORAGE_KEY = "vpg-annotator-annotations";
|
|
12348
12348
|
const TOOLBAR_POSITION_STORAGE_KEY = "vpg-annotator-toolbar-position";
|
|
12349
12349
|
const RUNTIME_GUARD = "__VUE_POM_GENERATOR_ANNOTATOR_RUNTIME__";
|
|
12350
|
+
const SUBMIT_HOOK = "__VUE_POM_GENERATOR_ANNOTATOR_SUBMIT__";
|
|
12350
12351
|
const TOOLBAR_ICON_MARKUP = {
|
|
12351
12352
|
drag: '<svg viewBox="0 0 16 16"><path d="M5 3h1v1H5zM10 3h1v1h-1zM5 7h1v1H5zM10 7h1v1h-1zM5 11h1v1H5zM10 11h1v1h-1z" fill="currentColor" stroke="none" /></svg>',
|
|
12352
12353
|
inspect: '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="4.5"/><path d="M8 1v2.5M8 12.5v2.5M1 8h2.5M12.5 8h2.5"/><circle cx="8" cy="8" r="0.9" fill="currentColor" stroke="none"/></svg>',
|
|
12353
12354
|
preview: '<svg viewBox="0 0 16 16"><path d="M1.5 8s2.4-4 6.5-4 6.5 4 6.5 4-2.4 4-6.5 4-6.5-4-6.5-4Z"/><circle cx="8" cy="8" r="1.8"/></svg>',
|
|
12354
12355
|
copy: '<svg viewBox="0 0 16 16"><path d="M6 2.5h6.5v9H6z"/><path d="M3.5 5.5H5v6.5h5.5v1.5h-7z"/></svg>',
|
|
12356
|
+
submit: '<svg viewBox="0 0 16 16"><path d="M14 2 2 7.5l5 1.5 1.5 5z"/><path d="M14 2 7 9"/></svg>',
|
|
12355
12357
|
clear: '<svg viewBox="0 0 16 16"><path d="M2.5 4.5h11"/><path d="M6 2.5h4"/><path d="M5 4.5v8"/><path d="M8 4.5v8"/><path d="M11 4.5v8"/><path d="M4 4.5h8l-.6 9H4.6z"/></svg>',
|
|
12356
12358
|
settings: '<svg viewBox="0 0 16 16"><path d="M8 2.2l1 .6 1.2-.2.8 1 .9.7-.3 1.2.5 1-.5 1 .3 1.2-.9.7-.8 1-1.2-.2-1 .6-1-.6-1.2.2-.8-1-.9-.7.3-1.2-.5-1 .5-1-.3-1.2.9-.7.8-1 1.2.2z"/><circle cx="8" cy="8" r="2.2"/></svg>'
|
|
12357
12359
|
};
|
|
@@ -12484,6 +12486,9 @@ async function copyTextToClipboard(text) {
|
|
|
12484
12486
|
throw new Error("Clipboard copy failed.");
|
|
12485
12487
|
}
|
|
12486
12488
|
}
|
|
12489
|
+
function annotationMatchesSubmitted(submitted, current) {
|
|
12490
|
+
return submitted.comment === current.comment && submitted.targetLabel === current.targetLabel && submitted.source === current.source && submitted.component === current.component && submitted.uiText === current.uiText && submitted.locator === current.locator && submitted.domHint === current.domHint && submitted.pageUrl === current.pageUrl;
|
|
12491
|
+
}
|
|
12487
12492
|
class AnnotatorRuntime {
|
|
12488
12493
|
options;
|
|
12489
12494
|
settings;
|
|
@@ -12505,6 +12510,7 @@ class AnnotatorRuntime {
|
|
|
12505
12510
|
currentPanelEl = null;
|
|
12506
12511
|
toastTimer = null;
|
|
12507
12512
|
toolbarPosition = null;
|
|
12513
|
+
submitting = false;
|
|
12508
12514
|
constructor(options) {
|
|
12509
12515
|
this.options = options;
|
|
12510
12516
|
this.settings = this.loadSettings();
|
|
@@ -12570,12 +12576,15 @@ class AnnotatorRuntime {
|
|
|
12570
12576
|
const copyButton = createIconButton("Copy annotations", "copy", () => this.copyAnnotations(), {
|
|
12571
12577
|
disabled: this.annotations.length === 0
|
|
12572
12578
|
});
|
|
12579
|
+
const submitButton = typeof window[SUBMIT_HOOK] === "function" ? createIconButton("Submit annotations", "submit", () => void this.submitAnnotations(), {
|
|
12580
|
+
disabled: this.submitting || this.annotations.length === 0
|
|
12581
|
+
}) : null;
|
|
12573
12582
|
const clearButton = createIconButton("Clear annotations", "clear", () => this.clearAnnotations(), {
|
|
12574
12583
|
disabled: this.annotations.length === 0
|
|
12575
12584
|
});
|
|
12576
12585
|
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings());
|
|
12577
12586
|
this.settingsButton = settingsButton;
|
|
12578
|
-
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, clearButton, settingsButton, count);
|
|
12587
|
+
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, ...submitButton ? [submitButton] : [], clearButton, settingsButton, count);
|
|
12579
12588
|
this.applyToolbarPosition();
|
|
12580
12589
|
}
|
|
12581
12590
|
renderMarkers() {
|
|
@@ -12805,6 +12814,7 @@ class AnnotatorRuntime {
|
|
|
12805
12814
|
uiText: getNearbyText(element),
|
|
12806
12815
|
locator: getNearbyLocator(element),
|
|
12807
12816
|
domHint: getElementPath(element),
|
|
12817
|
+
pageUrl: window.location.href,
|
|
12808
12818
|
pageX: rect.left + rect.width / 2,
|
|
12809
12819
|
pageY: rect.top + window.scrollY
|
|
12810
12820
|
};
|
|
@@ -13034,6 +13044,43 @@ class AnnotatorRuntime {
|
|
|
13034
13044
|
this.showToast("Copy failed");
|
|
13035
13045
|
}
|
|
13036
13046
|
}
|
|
13047
|
+
/** Re-renders the toolbar, for example after an app registers or removes a submit handler. */
|
|
13048
|
+
refresh() {
|
|
13049
|
+
this.renderToolbar();
|
|
13050
|
+
}
|
|
13051
|
+
async submitAnnotations() {
|
|
13052
|
+
if (this.submitting || !this.annotations.length) {
|
|
13053
|
+
return;
|
|
13054
|
+
}
|
|
13055
|
+
const handler = window[SUBMIT_HOOK];
|
|
13056
|
+
if (typeof handler !== "function") {
|
|
13057
|
+
return;
|
|
13058
|
+
}
|
|
13059
|
+
this.submitting = true;
|
|
13060
|
+
this.renderToolbar();
|
|
13061
|
+
const batch = [...this.annotations];
|
|
13062
|
+
const submitted = new Map(batch.map((annotation) => [annotation.id, { ...annotation }]));
|
|
13063
|
+
try {
|
|
13064
|
+
const accepted = await handler(batch, { pageUrl: window.location.href });
|
|
13065
|
+
if (accepted !== true) {
|
|
13066
|
+
this.showToast("Submit failed");
|
|
13067
|
+
return;
|
|
13068
|
+
}
|
|
13069
|
+
this.annotations = this.annotations.filter((annotation) => {
|
|
13070
|
+
const snapshot = submitted.get(annotation.id);
|
|
13071
|
+
return snapshot === void 0 || !annotationMatchesSubmitted(snapshot, annotation);
|
|
13072
|
+
});
|
|
13073
|
+
this.saveAnnotations();
|
|
13074
|
+
this.closePanel();
|
|
13075
|
+
this.showToast("Submitted");
|
|
13076
|
+
} catch (error) {
|
|
13077
|
+
console.error("[vue-pom-generator] Annotator submit handler failed", error);
|
|
13078
|
+
this.showToast("Submit failed");
|
|
13079
|
+
} finally {
|
|
13080
|
+
this.submitting = false;
|
|
13081
|
+
this.renderToolbar();
|
|
13082
|
+
}
|
|
13083
|
+
}
|
|
13037
13084
|
showToast(message) {
|
|
13038
13085
|
this.toastEl?.remove();
|
|
13039
13086
|
if (this.toastTimer !== null) {
|
|
@@ -13055,13 +13102,12 @@ class AnnotatorRuntime {
|
|
|
13055
13102
|
}
|
|
13056
13103
|
}
|
|
13057
13104
|
function mountAnnotatorClient(options) {
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
return runtimeWindow[RUNTIME_GUARD];
|
|
13105
|
+
if (window[RUNTIME_GUARD]) {
|
|
13106
|
+
return window[RUNTIME_GUARD];
|
|
13061
13107
|
}
|
|
13062
13108
|
const runtime = new AnnotatorRuntime(options);
|
|
13063
13109
|
runtime.mount();
|
|
13064
|
-
|
|
13110
|
+
window[RUNTIME_GUARD] = runtime;
|
|
13065
13111
|
return runtime;
|
|
13066
13112
|
}
|
|
13067
13113
|
let generating = false;
|