@immense/vue-pom-generator 1.0.115 → 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 -33
- package/dist/index.cjs +56 -19
- 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 +57 -20
- 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/dist/transform.d.ts.map +1 -1
- package/dist/wrapper-contract.d.ts +12 -6
- package/dist/wrapper-contract.d.ts.map +1 -1
- 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
|
@@ -10,7 +10,7 @@ import { parse as parse$2, NodeTypes as NodeTypes$1 } from "@vue/compiler-dom";
|
|
|
10
10
|
import { parse as parse$1, compileScript } from "@vue/compiler-sfc";
|
|
11
11
|
import { Project, QuoteKind, NewLineKind, IndentationText, CodeBlockWriter, StructureKind, VariableDeclarationKind } from "ts-morph";
|
|
12
12
|
import { camelize } from "@vue/shared";
|
|
13
|
-
import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, isArrayPattern, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral,
|
|
13
|
+
import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, isArrayPattern, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral, isExpression, isTSAsExpression, isTSTypeAssertion, isTSNonNullExpression, isImportDeclaration, isImportSpecifier, isExportDefaultDeclaration, isVariableDeclaration, isFunctionDeclaration, isFunctionExpression, isReturnStatement, isForInStatement, isIfStatement } from "@babel/types";
|
|
14
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
15
|
import { POM_ROUTER_GLOBAL_NAME } from "./router.mjs";
|
|
16
16
|
import { performance } from "node:perf_hooks";
|
|
@@ -8996,9 +8996,8 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
8996
8996
|
role: null,
|
|
8997
8997
|
targetRoles: [],
|
|
8998
8998
|
forwardedTestIdTargetOffsets: /* @__PURE__ */ new Set(),
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
explicitlyForwardedTestIdTargetSfcOffsets: /* @__PURE__ */ new Set()
|
|
8999
|
+
attrsObjectNames: /* @__PURE__ */ new Set(),
|
|
9000
|
+
attrsFunctionNames: /* @__PURE__ */ new Set()
|
|
9002
9001
|
};
|
|
9003
9002
|
}
|
|
9004
9003
|
const scriptMetadata = analyzeScriptForwardingMetadata(
|
|
@@ -9007,7 +9006,6 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
9007
9006
|
);
|
|
9008
9007
|
const ast = parse$2(template, { comments: false });
|
|
9009
9008
|
const targets = /* @__PURE__ */ new Map();
|
|
9010
|
-
const explicitTargetOffsets = /* @__PURE__ */ new Set();
|
|
9011
9009
|
if (scriptMetadata.inheritAttrs) {
|
|
9012
9010
|
for (const element of getRenderedRootElements(ast)) {
|
|
9013
9011
|
targets.set(element.loc.start.offset, element);
|
|
@@ -9016,7 +9014,6 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
9016
9014
|
walkTemplate(ast, (element) => {
|
|
9017
9015
|
if (elementExplicitlyForwardsTestId(element, options.testIdAttribute, scriptMetadata)) {
|
|
9018
9016
|
targets.set(element.loc.start.offset, element);
|
|
9019
|
-
explicitTargetOffsets.add(element.loc.start.offset);
|
|
9020
9017
|
}
|
|
9021
9018
|
});
|
|
9022
9019
|
const targetRoles = [...targets.values()].map((element) => {
|
|
@@ -9031,17 +9028,12 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
9031
9028
|
});
|
|
9032
9029
|
const uniqueRoles = new Set(targetRoles);
|
|
9033
9030
|
const role = uniqueRoles.size === 1 && !uniqueRoles.has(null) ? targetRoles[0] ?? null : null;
|
|
9034
|
-
const templateContentStartOffset = descriptor.template?.loc.start.offset ?? 0;
|
|
9035
|
-
const toSfcOffsets = (offsets) => new Set(
|
|
9036
|
-
[...offsets].map((offset2) => offset2 + templateContentStartOffset)
|
|
9037
|
-
);
|
|
9038
9031
|
return {
|
|
9039
9032
|
role,
|
|
9040
9033
|
targetRoles,
|
|
9041
9034
|
forwardedTestIdTargetOffsets: new Set(targets.keys()),
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
explicitlyForwardedTestIdTargetSfcOffsets: toSfcOffsets(explicitTargetOffsets)
|
|
9035
|
+
attrsObjectNames: scriptMetadata.attrsObjectNames,
|
|
9036
|
+
attrsFunctionNames: scriptMetadata.attrsFunctionNames
|
|
9045
9037
|
};
|
|
9046
9038
|
}
|
|
9047
9039
|
function resolveWrapperContractForTag(options) {
|
|
@@ -9710,8 +9702,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
9710
9702
|
}
|
|
9711
9703
|
}
|
|
9712
9704
|
const ownWrapperContract = getWrapperContract(componentName);
|
|
9713
|
-
const
|
|
9714
|
-
const isExplicitFallthroughTarget = ownWrapperContract?.explicitlyForwardedTestIdTargetOffsets.has(elementStartOffset) || ownWrapperContract?.explicitlyForwardedTestIdTargetSfcOffsets.has(elementStartOffset);
|
|
9705
|
+
const isExplicitFallthroughTarget = !!ownWrapperContract && elementExplicitlyForwardsTestId(element, testIdAttribute, ownWrapperContract);
|
|
9715
9706
|
if (!dependencies.isView && isExplicitFallthroughTarget) {
|
|
9716
9707
|
return;
|
|
9717
9708
|
}
|
|
@@ -12356,11 +12347,13 @@ const SETTINGS_STORAGE_KEY = "vpg-annotator-settings";
|
|
|
12356
12347
|
const ANNOTATIONS_STORAGE_KEY = "vpg-annotator-annotations";
|
|
12357
12348
|
const TOOLBAR_POSITION_STORAGE_KEY = "vpg-annotator-toolbar-position";
|
|
12358
12349
|
const RUNTIME_GUARD = "__VUE_POM_GENERATOR_ANNOTATOR_RUNTIME__";
|
|
12350
|
+
const SUBMIT_HOOK = "__VUE_POM_GENERATOR_ANNOTATOR_SUBMIT__";
|
|
12359
12351
|
const TOOLBAR_ICON_MARKUP = {
|
|
12360
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>',
|
|
12361
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>',
|
|
12362
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>',
|
|
12363
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>',
|
|
12364
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>',
|
|
12365
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>'
|
|
12366
12359
|
};
|
|
@@ -12493,6 +12486,9 @@ async function copyTextToClipboard(text) {
|
|
|
12493
12486
|
throw new Error("Clipboard copy failed.");
|
|
12494
12487
|
}
|
|
12495
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
|
+
}
|
|
12496
12492
|
class AnnotatorRuntime {
|
|
12497
12493
|
options;
|
|
12498
12494
|
settings;
|
|
@@ -12514,6 +12510,7 @@ class AnnotatorRuntime {
|
|
|
12514
12510
|
currentPanelEl = null;
|
|
12515
12511
|
toastTimer = null;
|
|
12516
12512
|
toolbarPosition = null;
|
|
12513
|
+
submitting = false;
|
|
12517
12514
|
constructor(options) {
|
|
12518
12515
|
this.options = options;
|
|
12519
12516
|
this.settings = this.loadSettings();
|
|
@@ -12579,12 +12576,15 @@ class AnnotatorRuntime {
|
|
|
12579
12576
|
const copyButton = createIconButton("Copy annotations", "copy", () => this.copyAnnotations(), {
|
|
12580
12577
|
disabled: this.annotations.length === 0
|
|
12581
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;
|
|
12582
12582
|
const clearButton = createIconButton("Clear annotations", "clear", () => this.clearAnnotations(), {
|
|
12583
12583
|
disabled: this.annotations.length === 0
|
|
12584
12584
|
});
|
|
12585
12585
|
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings());
|
|
12586
12586
|
this.settingsButton = settingsButton;
|
|
12587
|
-
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, clearButton, settingsButton, count);
|
|
12587
|
+
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, ...submitButton ? [submitButton] : [], clearButton, settingsButton, count);
|
|
12588
12588
|
this.applyToolbarPosition();
|
|
12589
12589
|
}
|
|
12590
12590
|
renderMarkers() {
|
|
@@ -12814,6 +12814,7 @@ class AnnotatorRuntime {
|
|
|
12814
12814
|
uiText: getNearbyText(element),
|
|
12815
12815
|
locator: getNearbyLocator(element),
|
|
12816
12816
|
domHint: getElementPath(element),
|
|
12817
|
+
pageUrl: window.location.href,
|
|
12817
12818
|
pageX: rect.left + rect.width / 2,
|
|
12818
12819
|
pageY: rect.top + window.scrollY
|
|
12819
12820
|
};
|
|
@@ -13043,6 +13044,43 @@ class AnnotatorRuntime {
|
|
|
13043
13044
|
this.showToast("Copy failed");
|
|
13044
13045
|
}
|
|
13045
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
|
+
}
|
|
13046
13084
|
showToast(message) {
|
|
13047
13085
|
this.toastEl?.remove();
|
|
13048
13086
|
if (this.toastTimer !== null) {
|
|
@@ -13064,13 +13102,12 @@ class AnnotatorRuntime {
|
|
|
13064
13102
|
}
|
|
13065
13103
|
}
|
|
13066
13104
|
function mountAnnotatorClient(options) {
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
return runtimeWindow[RUNTIME_GUARD];
|
|
13105
|
+
if (window[RUNTIME_GUARD]) {
|
|
13106
|
+
return window[RUNTIME_GUARD];
|
|
13070
13107
|
}
|
|
13071
13108
|
const runtime = new AnnotatorRuntime(options);
|
|
13072
13109
|
runtime.mount();
|
|
13073
|
-
|
|
13110
|
+
window[RUNTIME_GUARD] = runtime;
|
|
13074
13111
|
return runtime;
|
|
13075
13112
|
}
|
|
13076
13113
|
let generating = false;
|