@memberjunction/core-actions 2.107.0 → 2.109.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/custom/ai/find-best-action.action.d.ts +53 -0
- package/dist/custom/ai/find-best-action.action.d.ts.map +1 -0
- package/dist/custom/ai/find-best-action.action.js +211 -0
- package/dist/custom/ai/find-best-action.action.js.map +1 -0
- package/dist/custom/ai/find-best-agent.action.d.ts +53 -0
- package/dist/custom/ai/find-best-agent.action.d.ts.map +1 -0
- package/dist/custom/ai/find-best-agent.action.js +194 -0
- package/dist/custom/ai/find-best-agent.action.js.map +1 -0
- package/dist/custom/ai/summarize-content.action.d.ts +3 -3
- package/dist/custom/ai/summarize-content.action.d.ts.map +1 -1
- package/dist/custom/ai/summarize-content.action.js +51 -143
- package/dist/custom/ai/summarize-content.action.js.map +1 -1
- package/dist/custom/code-execution/execute-code.action.d.ts +61 -0
- package/dist/custom/code-execution/execute-code.action.d.ts.map +1 -0
- package/dist/custom/code-execution/execute-code.action.js +172 -0
- package/dist/custom/code-execution/execute-code.action.js.map +1 -0
- package/dist/custom/data/csv-parser.action.js +1 -1
- package/dist/custom/data/csv-parser.action.js.map +1 -1
- package/dist/custom/data/execute-research-query.action.d.ts +36 -18
- package/dist/custom/data/execute-research-query.action.d.ts.map +1 -1
- package/dist/custom/data/execute-research-query.action.js +221 -114
- package/dist/custom/data/execute-research-query.action.js.map +1 -1
- package/dist/custom/data/explore-database-schema.action.d.ts +4 -0
- package/dist/custom/data/explore-database-schema.action.d.ts.map +1 -1
- package/dist/custom/data/explore-database-schema.action.js +101 -8
- package/dist/custom/data/explore-database-schema.action.js.map +1 -1
- package/dist/custom/data/get-entity-details.action.d.ts +63 -0
- package/dist/custom/data/get-entity-details.action.d.ts.map +1 -0
- package/dist/custom/data/get-entity-details.action.js +284 -0
- package/dist/custom/data/get-entity-details.action.js.map +1 -0
- package/dist/custom/data/get-entity-list.action.d.ts +57 -0
- package/dist/custom/data/get-entity-list.action.d.ts.map +1 -0
- package/dist/custom/data/get-entity-list.action.js +177 -0
- package/dist/custom/data/get-entity-list.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-chart.action.d.ts +97 -0
- package/dist/custom/visualization/create-svg-chart.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-chart.action.js +326 -0
- package/dist/custom/visualization/create-svg-chart.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-diagram.action.d.ts +151 -0
- package/dist/custom/visualization/create-svg-diagram.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-diagram.action.js +764 -0
- package/dist/custom/visualization/create-svg-diagram.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-infographic.action.d.ts +72 -0
- package/dist/custom/visualization/create-svg-infographic.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-infographic.action.js +343 -0
- package/dist/custom/visualization/create-svg-infographic.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-network.action.d.ts +106 -0
- package/dist/custom/visualization/create-svg-network.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-network.action.js +687 -0
- package/dist/custom/visualization/create-svg-network.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.d.ts +97 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.js +730 -0
- package/dist/custom/visualization/create-svg-sketch-diagram.action.js.map +1 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.d.ts +94 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.d.ts.map +1 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.js +497 -0
- package/dist/custom/visualization/create-svg-word-cloud.action.js.map +1 -0
- package/dist/custom/visualization/shared/svg-theming.d.ts +91 -0
- package/dist/custom/visualization/shared/svg-theming.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-theming.js +235 -0
- package/dist/custom/visualization/shared/svg-theming.js.map +1 -0
- package/dist/custom/visualization/shared/svg-types.d.ts +354 -0
- package/dist/custom/visualization/shared/svg-types.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-types.js +11 -0
- package/dist/custom/visualization/shared/svg-types.js.map +1 -0
- package/dist/custom/visualization/shared/svg-utils.d.ts +166 -0
- package/dist/custom/visualization/shared/svg-utils.d.ts.map +1 -0
- package/dist/custom/visualization/shared/svg-utils.js +555 -0
- package/dist/custom/visualization/shared/svg-utils.js.map +1 -0
- package/dist/custom/web/google-custom-search.action.d.ts +6 -1
- package/dist/custom/web/google-custom-search.action.d.ts.map +1 -1
- package/dist/custom/web/google-custom-search.action.js +78 -10
- package/dist/custom/web/google-custom-search.action.js.map +1 -1
- package/dist/custom/web/web-page-content.action.d.ts +24 -0
- package/dist/custom/web/web-page-content.action.d.ts.map +1 -1
- package/dist/custom/web/web-page-content.action.js +90 -9
- package/dist/custom/web/web-page-content.action.js.map +1 -1
- package/dist/generated/action_subclasses.d.ts +4 -4
- package/dist/generated/action_subclasses.js +13 -13
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/package.json +30 -12
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Utility functions for SVG creation, manipulation, and sanitization.
|
|
4
|
+
* These utilities provide security, consistency, and convenience for all visualization actions.
|
|
5
|
+
*
|
|
6
|
+
* @module @memberjunction/actions-core/visualization
|
|
7
|
+
* @since 2.107.0
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SVGUtils = void 0;
|
|
11
|
+
const jsdom_1 = require("jsdom");
|
|
12
|
+
/**
|
|
13
|
+
* Utility class for SVG operations
|
|
14
|
+
*/
|
|
15
|
+
class SVGUtils {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a base SVG element with proper namespace and dimensions
|
|
18
|
+
*
|
|
19
|
+
* @param width - SVG width in pixels
|
|
20
|
+
* @param height - SVG height in pixels
|
|
21
|
+
* @param idPrefix - Optional ID prefix for the root SVG element
|
|
22
|
+
* @returns JSDOM Document containing the SVG
|
|
23
|
+
*/
|
|
24
|
+
static createSVG(width, height, idPrefix) {
|
|
25
|
+
const svgId = idPrefix ? ` id="${idPrefix}-root"` : '';
|
|
26
|
+
const dom = new jsdom_1.JSDOM(`<svg xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
width="${width}"
|
|
28
|
+
height="${height}"
|
|
29
|
+
viewBox="0 0 ${width} ${height}"${svgId}
|
|
30
|
+
></svg>`);
|
|
31
|
+
return dom.window.document;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sanitizes text content to prevent XSS attacks
|
|
35
|
+
*
|
|
36
|
+
* @param text - Raw text content
|
|
37
|
+
* @returns HTML-safe text
|
|
38
|
+
*/
|
|
39
|
+
static sanitizeText(text) {
|
|
40
|
+
return text
|
|
41
|
+
.replace(/&/g, '&')
|
|
42
|
+
.replace(/</g, '<')
|
|
43
|
+
.replace(/>/g, '>')
|
|
44
|
+
.replace(/"/g, '"')
|
|
45
|
+
.replace(/'/g, ''');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Sanitizes SVG string to remove potentially malicious content
|
|
49
|
+
* - Removes event handlers (on*)
|
|
50
|
+
* - Removes external image references
|
|
51
|
+
* - Removes external use references
|
|
52
|
+
* - Restricts href to # and mailto: only
|
|
53
|
+
*
|
|
54
|
+
* @param svgString - Raw SVG XML string
|
|
55
|
+
* @returns Sanitized SVG string
|
|
56
|
+
*/
|
|
57
|
+
static sanitizeSVG(svgString) {
|
|
58
|
+
let sanitized = svgString;
|
|
59
|
+
// Remove event handlers
|
|
60
|
+
sanitized = sanitized.replace(/\son\w+="[^"]*"/gi, '');
|
|
61
|
+
sanitized = sanitized.replace(/\son\w+='[^']*'/gi, '');
|
|
62
|
+
// Remove external xlink:href (keep data URIs)
|
|
63
|
+
sanitized = sanitized.replace(/xlink:href="(?!data:)[^"]*"/gi, 'xlink:href=""');
|
|
64
|
+
// Remove external href (keep # anchors and mailto:)
|
|
65
|
+
sanitized = sanitized.replace(/href="(?!#|mailto:)[^"]*"/gi, 'href=""');
|
|
66
|
+
// Remove script tags
|
|
67
|
+
sanitized = sanitized.replace(/<script[\s\S]*?<\/script>/gi, '');
|
|
68
|
+
return sanitized;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generates a unique ID with prefix and timestamp
|
|
72
|
+
*
|
|
73
|
+
* @param prefix - ID prefix (e.g., 'flow', 'node')
|
|
74
|
+
* @param index - Index or identifier
|
|
75
|
+
* @returns Unique ID string
|
|
76
|
+
*/
|
|
77
|
+
static generateId(prefix, index) {
|
|
78
|
+
return `${prefix}-${index}-${Date.now()}`;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Adds accessibility elements to SVG root
|
|
82
|
+
*
|
|
83
|
+
* @param svg - SVG element to enhance
|
|
84
|
+
* @param a11y - Accessibility configuration
|
|
85
|
+
*/
|
|
86
|
+
static addA11y(svg, a11y) {
|
|
87
|
+
if (!a11y)
|
|
88
|
+
return;
|
|
89
|
+
const doc = svg.ownerDocument;
|
|
90
|
+
const ns = svg.namespaceURI;
|
|
91
|
+
// Add title
|
|
92
|
+
if (a11y.title) {
|
|
93
|
+
const title = doc.createElementNS(ns, 'title');
|
|
94
|
+
title.textContent = a11y.title;
|
|
95
|
+
svg.insertBefore(title, svg.firstChild);
|
|
96
|
+
}
|
|
97
|
+
// Add description
|
|
98
|
+
if (a11y.desc) {
|
|
99
|
+
const desc = doc.createElementNS(ns, 'desc');
|
|
100
|
+
desc.textContent = a11y.desc;
|
|
101
|
+
// Insert after title if it exists
|
|
102
|
+
const titleEl = svg.querySelector('title');
|
|
103
|
+
if (titleEl && titleEl.nextSibling) {
|
|
104
|
+
svg.insertBefore(desc, titleEl.nextSibling);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
svg.insertBefore(desc, svg.firstChild);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Set ARIA role
|
|
111
|
+
if (a11y.ariaRole) {
|
|
112
|
+
svg.setAttribute('role', a11y.ariaRole);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Injects inline CSS styles into SVG
|
|
117
|
+
*
|
|
118
|
+
* @param svg - SVG element
|
|
119
|
+
* @param css - CSS string to inject
|
|
120
|
+
*/
|
|
121
|
+
static addStyles(svg, css) {
|
|
122
|
+
const doc = svg.ownerDocument;
|
|
123
|
+
const ns = svg.namespaceURI;
|
|
124
|
+
const style = doc.createElementNS(ns, 'style');
|
|
125
|
+
style.textContent = css;
|
|
126
|
+
// Insert style after title/desc but before content
|
|
127
|
+
const lastMetaElement = Array.from(svg.children).find((el) => el.tagName === 'desc' || el.tagName === 'title');
|
|
128
|
+
if (lastMetaElement && lastMetaElement.nextSibling) {
|
|
129
|
+
svg.insertBefore(style, lastMetaElement.nextSibling);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
svg.insertBefore(style, svg.firstChild);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Calculates viewBox with padding applied
|
|
137
|
+
*
|
|
138
|
+
* @param viewBox - ViewBox configuration
|
|
139
|
+
* @returns Padding-adjusted dimensions and offsets
|
|
140
|
+
*/
|
|
141
|
+
static calculateViewBox(viewBox) {
|
|
142
|
+
let top = 0, right = 0, bottom = 0, left = 0;
|
|
143
|
+
if (viewBox.padding !== undefined) {
|
|
144
|
+
if (typeof viewBox.padding === 'number') {
|
|
145
|
+
top = right = bottom = left = viewBox.padding;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
top = viewBox.padding.top || 0;
|
|
149
|
+
right = viewBox.padding.right || 0;
|
|
150
|
+
bottom = viewBox.padding.bottom || 0;
|
|
151
|
+
left = viewBox.padding.left || 0;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
x: left,
|
|
156
|
+
y: top,
|
|
157
|
+
width: viewBox.width,
|
|
158
|
+
height: viewBox.height,
|
|
159
|
+
contentWidth: viewBox.width - left - right,
|
|
160
|
+
contentHeight: viewBox.height - top - bottom,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a <defs> element if it doesn't exist in SVG
|
|
165
|
+
*
|
|
166
|
+
* @param svg - SVG element
|
|
167
|
+
* @returns The defs element (existing or newly created)
|
|
168
|
+
*/
|
|
169
|
+
static getOrCreateDefs(svg) {
|
|
170
|
+
let defs = svg.querySelector('defs');
|
|
171
|
+
if (!defs) {
|
|
172
|
+
defs = svg.ownerDocument.createElementNS(svg.namespaceURI, 'defs');
|
|
173
|
+
svg.insertBefore(defs, svg.firstChild);
|
|
174
|
+
}
|
|
175
|
+
return defs;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Adds an arrowhead marker definition to SVG
|
|
179
|
+
*
|
|
180
|
+
* @param svg - SVG element
|
|
181
|
+
* @param id - Marker ID
|
|
182
|
+
* @param color - Arrow color
|
|
183
|
+
* @returns Marker ID for use in marker-end attribute
|
|
184
|
+
*/
|
|
185
|
+
static addArrowMarker(svg, id, color = '#000') {
|
|
186
|
+
const defs = this.getOrCreateDefs(svg);
|
|
187
|
+
const doc = svg.ownerDocument;
|
|
188
|
+
const ns = svg.namespaceURI;
|
|
189
|
+
// Check if marker already exists
|
|
190
|
+
if (defs.querySelector(`#${id}`)) {
|
|
191
|
+
return `url(#${id})`;
|
|
192
|
+
}
|
|
193
|
+
const marker = doc.createElementNS(ns, 'marker');
|
|
194
|
+
marker.setAttribute('id', id);
|
|
195
|
+
marker.setAttribute('markerWidth', '10');
|
|
196
|
+
marker.setAttribute('markerHeight', '10');
|
|
197
|
+
marker.setAttribute('refX', '9');
|
|
198
|
+
marker.setAttribute('refY', '3');
|
|
199
|
+
marker.setAttribute('orient', 'auto');
|
|
200
|
+
marker.setAttribute('markerUnits', 'strokeWidth');
|
|
201
|
+
const path = doc.createElementNS(ns, 'path');
|
|
202
|
+
path.setAttribute('d', 'M0,0 L0,6 L9,3 z');
|
|
203
|
+
path.setAttribute('fill', color);
|
|
204
|
+
marker.appendChild(path);
|
|
205
|
+
defs.appendChild(marker);
|
|
206
|
+
return `url(#${id})`;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Creates a seeded pseudo-random number generator
|
|
210
|
+
* Uses simple Linear Congruential Generator for deterministic output
|
|
211
|
+
*
|
|
212
|
+
* @param seed - Random seed
|
|
213
|
+
* @returns Function that returns random numbers between 0 and 1
|
|
214
|
+
*/
|
|
215
|
+
static seededRandom(seed) {
|
|
216
|
+
let s = seed;
|
|
217
|
+
return function () {
|
|
218
|
+
s = (s * 9301 + 49297) % 233280;
|
|
219
|
+
return s / 233280;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Wraps text to fit within a specified width
|
|
224
|
+
*
|
|
225
|
+
* @param text - Text to wrap
|
|
226
|
+
* @param maxWidth - Maximum width in characters (approximate)
|
|
227
|
+
* @returns Array of text lines
|
|
228
|
+
*/
|
|
229
|
+
static wrapText(text, maxWidth) {
|
|
230
|
+
const words = text.split(/\s+/);
|
|
231
|
+
const lines = [];
|
|
232
|
+
let currentLine = '';
|
|
233
|
+
for (const word of words) {
|
|
234
|
+
const testLine = currentLine ? `${currentLine} ${word}` : word;
|
|
235
|
+
if (testLine.length <= maxWidth) {
|
|
236
|
+
currentLine = testLine;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
if (currentLine)
|
|
240
|
+
lines.push(currentLine);
|
|
241
|
+
currentLine = word;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (currentLine)
|
|
245
|
+
lines.push(currentLine);
|
|
246
|
+
return lines;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Calculates text width (approximate based on character count and font size)
|
|
250
|
+
* More accurate measurement would require actual rendering
|
|
251
|
+
*
|
|
252
|
+
* @param text - Text content
|
|
253
|
+
* @param fontSize - Font size in pixels
|
|
254
|
+
* @returns Estimated width in pixels
|
|
255
|
+
*/
|
|
256
|
+
static estimateTextWidth(text, fontSize = 14) {
|
|
257
|
+
// Average character width is approximately 0.6 of font size
|
|
258
|
+
return text.length * fontSize * 0.6;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Creates a rounded rectangle path
|
|
262
|
+
*
|
|
263
|
+
* @param x - X coordinate
|
|
264
|
+
* @param y - Y coordinate
|
|
265
|
+
* @param width - Width
|
|
266
|
+
* @param height - Height
|
|
267
|
+
* @param radius - Corner radius
|
|
268
|
+
* @returns SVG path data string
|
|
269
|
+
*/
|
|
270
|
+
static roundedRectPath(x, y, width, height, radius) {
|
|
271
|
+
radius = Math.min(radius, width / 2, height / 2);
|
|
272
|
+
return `
|
|
273
|
+
M ${x + radius},${y}
|
|
274
|
+
L ${x + width - radius},${y}
|
|
275
|
+
Q ${x + width},${y} ${x + width},${y + radius}
|
|
276
|
+
L ${x + width},${y + height - radius}
|
|
277
|
+
Q ${x + width},${y + height} ${x + width - radius},${y + height}
|
|
278
|
+
L ${x + radius},${y + height}
|
|
279
|
+
Q ${x},${y + height} ${x},${y + height - radius}
|
|
280
|
+
L ${x},${y + radius}
|
|
281
|
+
Q ${x},${y} ${x + radius},${y}
|
|
282
|
+
Z
|
|
283
|
+
`.replace(/\s+/g, ' ').trim();
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Wraps SVG string in a scrollable HTML container
|
|
287
|
+
* Useful for large visualizations that exceed viewport size
|
|
288
|
+
*
|
|
289
|
+
* @param svgString - The SVG XML string to wrap
|
|
290
|
+
* @param maxWidth - Maximum container width in pixels (default: 1200)
|
|
291
|
+
* @param maxHeight - Maximum container height in pixels (default: 800)
|
|
292
|
+
* @param showBorder - Whether to show container border (default: true)
|
|
293
|
+
* @param borderColor - Border color (default: #ddd)
|
|
294
|
+
* @returns HTML string with SVG wrapped in scrollable div
|
|
295
|
+
*/
|
|
296
|
+
static wrapWithScrollContainer(svgString, maxWidth = 1200, maxHeight = 800, showBorder = true, borderColor = '#ddd') {
|
|
297
|
+
const borderStyle = showBorder ? `border: 1px solid ${borderColor};` : '';
|
|
298
|
+
return `<div style="max-width: ${maxWidth}px; max-height: ${maxHeight}px; overflow: auto; ${borderStyle} border-radius: 4px; background: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">${svgString}</div>`;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Generates self-contained pan/zoom script for SVG
|
|
302
|
+
* No external dependencies - fully embedded JavaScript
|
|
303
|
+
*
|
|
304
|
+
* @param containerId - ID of the SVG group to apply transform to
|
|
305
|
+
* @param minScale - Minimum zoom level (default: 0.5)
|
|
306
|
+
* @param maxScale - Maximum zoom level (default: 3)
|
|
307
|
+
* @param showControls - Show zoom in/out/reset buttons (default: false)
|
|
308
|
+
* @returns Script tag with pan/zoom implementation
|
|
309
|
+
*/
|
|
310
|
+
static generatePanZoomScript(containerId = 'pan-zoom-container', minScale = 0.5, maxScale = 3, showControls = false) {
|
|
311
|
+
return `<script type="text/javascript"><![CDATA[
|
|
312
|
+
(function() {
|
|
313
|
+
const svg = document.currentScript.closest('svg');
|
|
314
|
+
const container = svg.getElementById('${containerId}');
|
|
315
|
+
if (!container) return;
|
|
316
|
+
|
|
317
|
+
let scale = 1, translateX = 0, translateY = 0;
|
|
318
|
+
let isDragging = false, startX, startY;
|
|
319
|
+
|
|
320
|
+
function updateTransform() {
|
|
321
|
+
container.setAttribute('transform',
|
|
322
|
+
'translate(' + translateX + ',' + translateY + ') scale(' + scale + ')');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Mouse wheel zoom
|
|
326
|
+
svg.addEventListener('wheel', function(e) {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
const delta = e.deltaY > 0 ? 0.9 : 1.1;
|
|
329
|
+
const newScale = Math.max(${minScale}, Math.min(${maxScale}, scale * delta));
|
|
330
|
+
|
|
331
|
+
// Zoom toward mouse position
|
|
332
|
+
const rect = svg.getBoundingClientRect();
|
|
333
|
+
const x = e.clientX - rect.left;
|
|
334
|
+
const y = e.clientY - rect.top;
|
|
335
|
+
|
|
336
|
+
translateX = x - (x - translateX) * (newScale / scale);
|
|
337
|
+
translateY = y - (y - translateY) * (newScale / scale);
|
|
338
|
+
scale = newScale;
|
|
339
|
+
|
|
340
|
+
updateTransform();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Pan with drag
|
|
344
|
+
svg.addEventListener('mousedown', function(e) {
|
|
345
|
+
if (e.button !== 0) return; // Left button only
|
|
346
|
+
isDragging = true;
|
|
347
|
+
startX = e.clientX - translateX;
|
|
348
|
+
startY = e.clientY - translateY;
|
|
349
|
+
svg.style.cursor = 'grabbing';
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
svg.addEventListener('mousemove', function(e) {
|
|
353
|
+
if (!isDragging) return;
|
|
354
|
+
translateX = e.clientX - startX;
|
|
355
|
+
translateY = e.clientY - startY;
|
|
356
|
+
updateTransform();
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
svg.addEventListener('mouseup', function() {
|
|
360
|
+
isDragging = false;
|
|
361
|
+
svg.style.cursor = 'grab';
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
svg.addEventListener('mouseleave', function() {
|
|
365
|
+
isDragging = false;
|
|
366
|
+
svg.style.cursor = 'default';
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// Touch gestures
|
|
370
|
+
let touchStartDist = 0;
|
|
371
|
+
let touch1StartX = 0, touch1StartY = 0;
|
|
372
|
+
|
|
373
|
+
svg.addEventListener('touchstart', function(e) {
|
|
374
|
+
if (e.touches.length === 2) {
|
|
375
|
+
touchStartDist = Math.hypot(
|
|
376
|
+
e.touches[0].clientX - e.touches[1].clientX,
|
|
377
|
+
e.touches[0].clientY - e.touches[1].clientY
|
|
378
|
+
);
|
|
379
|
+
} else if (e.touches.length === 1) {
|
|
380
|
+
touch1StartX = e.touches[0].clientX - translateX;
|
|
381
|
+
touch1StartY = e.touches[0].clientY - translateY;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
svg.addEventListener('touchmove', function(e) {
|
|
386
|
+
if (e.touches.length === 2) {
|
|
387
|
+
e.preventDefault();
|
|
388
|
+
const dist = Math.hypot(
|
|
389
|
+
e.touches[0].clientX - e.touches[1].clientX,
|
|
390
|
+
e.touches[0].clientY - e.touches[1].clientY
|
|
391
|
+
);
|
|
392
|
+
const delta = dist / touchStartDist;
|
|
393
|
+
scale = Math.max(${minScale}, Math.min(${maxScale}, scale * delta));
|
|
394
|
+
touchStartDist = dist;
|
|
395
|
+
updateTransform();
|
|
396
|
+
} else if (e.touches.length === 1 && !isDragging) {
|
|
397
|
+
translateX = e.touches[0].clientX - touch1StartX;
|
|
398
|
+
translateY = e.touches[0].clientY - touch1StartY;
|
|
399
|
+
updateTransform();
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
svg.style.cursor = 'grab';
|
|
404
|
+
${showControls ? this.generateZoomControlsScript() : ''}
|
|
405
|
+
})();
|
|
406
|
+
]]></script>`;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Generates zoom control buttons script
|
|
410
|
+
* @returns Script code for zoom controls (internal use)
|
|
411
|
+
*/
|
|
412
|
+
static generateZoomControlsScript() {
|
|
413
|
+
return `
|
|
414
|
+
// Add zoom controls
|
|
415
|
+
const controlsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
416
|
+
controlsGroup.setAttribute('id', 'zoom-controls');
|
|
417
|
+
controlsGroup.setAttribute('transform', 'translate(10, 10)');
|
|
418
|
+
|
|
419
|
+
const minScaleVal = ${0.5};
|
|
420
|
+
const maxScaleVal = ${3};
|
|
421
|
+
|
|
422
|
+
const buttonData = [
|
|
423
|
+
{ y: 0, text: '+', action: 'in' },
|
|
424
|
+
{ y: 35, text: '-', action: 'out' },
|
|
425
|
+
{ y: 70, text: '⟲', action: 'reset' }
|
|
426
|
+
];
|
|
427
|
+
|
|
428
|
+
buttonData.forEach(function(btn) {
|
|
429
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
430
|
+
g.style.cursor = 'pointer';
|
|
431
|
+
|
|
432
|
+
const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
433
|
+
rect.setAttribute('width', '30');
|
|
434
|
+
rect.setAttribute('height', '30');
|
|
435
|
+
rect.setAttribute('y', btn.y);
|
|
436
|
+
rect.setAttribute('fill', '#fff');
|
|
437
|
+
rect.setAttribute('stroke', '#333');
|
|
438
|
+
rect.setAttribute('stroke-width', '1');
|
|
439
|
+
rect.setAttribute('rx', '4');
|
|
440
|
+
|
|
441
|
+
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
442
|
+
text.setAttribute('x', '15');
|
|
443
|
+
text.setAttribute('y', btn.y + 20);
|
|
444
|
+
text.setAttribute('text-anchor', 'middle');
|
|
445
|
+
text.setAttribute('font-size', '16');
|
|
446
|
+
text.setAttribute('font-weight', 'bold');
|
|
447
|
+
text.textContent = btn.text;
|
|
448
|
+
|
|
449
|
+
g.appendChild(rect);
|
|
450
|
+
g.appendChild(text);
|
|
451
|
+
|
|
452
|
+
g.addEventListener('click', function() {
|
|
453
|
+
if (btn.action === 'in') {
|
|
454
|
+
scale = Math.min(maxScaleVal, scale * 1.2);
|
|
455
|
+
} else if (btn.action === 'out') {
|
|
456
|
+
scale = Math.max(minScaleVal, scale * 0.8);
|
|
457
|
+
} else if (btn.action === 'reset') {
|
|
458
|
+
scale = 1;
|
|
459
|
+
translateX = 0;
|
|
460
|
+
translateY = 0;
|
|
461
|
+
}
|
|
462
|
+
updateTransform();
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
controlsGroup.appendChild(g);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
svg.appendChild(controlsGroup);
|
|
469
|
+
`;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Generates interactive tooltip script for SVG elements
|
|
473
|
+
* Elements must have data-tooltip attribute
|
|
474
|
+
*
|
|
475
|
+
* @param svg - SVG element to add tooltip to
|
|
476
|
+
* @param doc - Document to create elements in
|
|
477
|
+
* @returns Script tag with tooltip implementation
|
|
478
|
+
*/
|
|
479
|
+
static addTooltipSupport(svg, doc) {
|
|
480
|
+
const ns = svg.namespaceURI;
|
|
481
|
+
// Create tooltip text element
|
|
482
|
+
const tooltip = doc.createElementNS(ns, 'text');
|
|
483
|
+
tooltip.setAttribute('id', 'mj-tooltip');
|
|
484
|
+
tooltip.setAttribute('visibility', 'hidden');
|
|
485
|
+
tooltip.setAttribute('pointer-events', 'none');
|
|
486
|
+
tooltip.setAttribute('font-size', '12');
|
|
487
|
+
tooltip.setAttribute('font-family', 'sans-serif');
|
|
488
|
+
tooltip.setAttribute('fill', '#000');
|
|
489
|
+
// Add background rect for better readability
|
|
490
|
+
const tooltipBg = doc.createElementNS(ns, 'rect');
|
|
491
|
+
tooltipBg.setAttribute('id', 'mj-tooltip-bg');
|
|
492
|
+
tooltipBg.setAttribute('visibility', 'hidden');
|
|
493
|
+
tooltipBg.setAttribute('pointer-events', 'none');
|
|
494
|
+
tooltipBg.setAttribute('fill', '#fff');
|
|
495
|
+
tooltipBg.setAttribute('stroke', '#333');
|
|
496
|
+
tooltipBg.setAttribute('stroke-width', '1');
|
|
497
|
+
tooltipBg.setAttribute('rx', '3');
|
|
498
|
+
tooltipBg.setAttribute('opacity', '0.95');
|
|
499
|
+
svg.appendChild(tooltipBg);
|
|
500
|
+
svg.appendChild(tooltip);
|
|
501
|
+
// Add script for tooltip behavior
|
|
502
|
+
const script = doc.createElementNS(ns, 'script');
|
|
503
|
+
script.setAttribute('type', 'text/javascript');
|
|
504
|
+
script.textContent = `
|
|
505
|
+
(function() {
|
|
506
|
+
const svg = document.currentScript.closest('svg');
|
|
507
|
+
const tooltip = svg.getElementById('mj-tooltip');
|
|
508
|
+
const tooltipBg = svg.getElementById('mj-tooltip-bg');
|
|
509
|
+
|
|
510
|
+
svg.querySelectorAll('[data-tooltip]').forEach(function(el) {
|
|
511
|
+
el.addEventListener('mouseenter', function(e) {
|
|
512
|
+
const content = this.getAttribute('data-tooltip');
|
|
513
|
+
const rect = svg.getBoundingClientRect();
|
|
514
|
+
const x = e.clientX - rect.left + 10;
|
|
515
|
+
const y = e.clientY - rect.top - 10;
|
|
516
|
+
|
|
517
|
+
tooltip.textContent = content;
|
|
518
|
+
tooltip.setAttribute('x', x);
|
|
519
|
+
tooltip.setAttribute('y', y);
|
|
520
|
+
tooltip.setAttribute('visibility', 'visible');
|
|
521
|
+
|
|
522
|
+
// Size background to text
|
|
523
|
+
const bbox = tooltip.getBBox();
|
|
524
|
+
tooltipBg.setAttribute('x', bbox.x - 4);
|
|
525
|
+
tooltipBg.setAttribute('y', bbox.y - 2);
|
|
526
|
+
tooltipBg.setAttribute('width', bbox.width + 8);
|
|
527
|
+
tooltipBg.setAttribute('height', bbox.height + 4);
|
|
528
|
+
tooltipBg.setAttribute('visibility', 'visible');
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
el.addEventListener('mouseleave', function() {
|
|
532
|
+
tooltip.setAttribute('visibility', 'hidden');
|
|
533
|
+
tooltipBg.setAttribute('visibility', 'hidden');
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
el.addEventListener('mousemove', function(e) {
|
|
537
|
+
const rect = svg.getBoundingClientRect();
|
|
538
|
+
const x = e.clientX - rect.left + 10;
|
|
539
|
+
const y = e.clientY - rect.top - 10;
|
|
540
|
+
|
|
541
|
+
tooltip.setAttribute('x', x);
|
|
542
|
+
tooltip.setAttribute('y', y);
|
|
543
|
+
|
|
544
|
+
const bbox = tooltip.getBBox();
|
|
545
|
+
tooltipBg.setAttribute('x', bbox.x - 4);
|
|
546
|
+
tooltipBg.setAttribute('y', bbox.y - 2);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
})();
|
|
550
|
+
`;
|
|
551
|
+
svg.appendChild(script);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
exports.SVGUtils = SVGUtils;
|
|
555
|
+
//# sourceMappingURL=svg-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-utils.js","sourceRoot":"","sources":["../../../../src/custom/visualization/shared/svg-utils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAA8B;AAG9B;;GAEG;AACH,MAAa,QAAQ;IACjB;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS,CAAC,KAAa,EAAE,MAAc,EAAE,QAAiB;QAC7D,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,QAAQ,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,MAAM,GAAG,GAAG,IAAI,aAAK,CAAC;8CACgB,KAAK;+CACJ,MAAM;oDACD,KAAK,IAAI,MAAM,IAAI,KAAK;wCACpC,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,IAAY;QAC5B,OAAO,IAAI;aACN,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;aACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,WAAW,CAAC,SAAiB;QAChC,IAAI,SAAS,GAAG,SAAS,CAAC;QAE1B,wBAAwB;QACxB,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAm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AAY,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAC9C,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC/C,SAAS,CAAC,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;QACjD,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzC,SAAS,CAAC,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QAC5C,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE1C,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC3B,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEzB,kCAAkC;QAClC,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC/C,MAAM,CAAC,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8CpB,CAAC;QAEF,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACJ;AA1lBD,4BA0lBC"}
|
|
@@ -30,18 +30,23 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
30
30
|
* }, {
|
|
31
31
|
* Name: 'SiteSearch',
|
|
32
32
|
* Value: 'europa.eu'
|
|
33
|
+
* }, {
|
|
34
|
+
* Name: 'Verbosity',
|
|
35
|
+
* Value: 'minimal' // 'minimal' | 'standard' (default) | 'detailed'
|
|
33
36
|
* }]
|
|
34
37
|
* });
|
|
35
38
|
* ```
|
|
36
39
|
*/
|
|
37
40
|
export declare class GoogleCustomSearchAction extends BaseAction {
|
|
38
41
|
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
39
|
-
private
|
|
42
|
+
private transformItemByVerbosity;
|
|
43
|
+
private buildResultData;
|
|
40
44
|
private extractFirstString;
|
|
41
45
|
private normalizeSafeSearch;
|
|
42
46
|
private normalizeSiteSearchFilter;
|
|
43
47
|
private normalizeLanguageRestriction;
|
|
44
48
|
private normalizeSearchType;
|
|
49
|
+
private normalizeVerbosity;
|
|
45
50
|
private clamp;
|
|
46
51
|
private getStringParam;
|
|
47
52
|
private getNumericParam;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-custom-search.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/google-custom-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA6BrD
|
|
1
|
+
{"version":3,"file":"google-custom-search.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/google-custom-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA6BrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBACa,wBAAyB,SAAQ,UAAU;cAEpC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyJvF,OAAO,CAAC,wBAAwB;IAyChC,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,mBAAmB;IAsB3B,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,4BAA4B;IAiBpC,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;CAO5B;AAED;;GAEG;AACH,wBAAgB,4BAA4B,SAE3C"}
|