@inditextech/weave-sdk 0.54.0 → 0.55.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/sdk.cjs +67 -56
- package/dist/sdk.d.cts +166 -160
- package/dist/sdk.d.cts.map +1 -1
- package/dist/sdk.d.ts +166 -160
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +80 -67
- package/dist/sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.cjs
CHANGED
|
@@ -5884,7 +5884,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
5884
5884
|
* @returns {Function} Returns the new memoized function.
|
|
5885
5885
|
*/
|
|
5886
5886
|
function memoizeCapped(func) {
|
|
5887
|
-
var result$1 = memoize(func, function(key) {
|
|
5887
|
+
var result$1 = memoize$1(func, function(key) {
|
|
5888
5888
|
if (cache.size === MAX_MEMOIZE_SIZE) cache.clear();
|
|
5889
5889
|
return key;
|
|
5890
5890
|
});
|
|
@@ -9544,7 +9544,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
9544
9544
|
* // Replace `_.memoize.Cache`.
|
|
9545
9545
|
* _.memoize.Cache = WeakMap;
|
|
9546
9546
|
*/
|
|
9547
|
-
function memoize(func, resolver) {
|
|
9547
|
+
function memoize$1(func, resolver) {
|
|
9548
9548
|
if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError$1(FUNC_ERROR_TEXT);
|
|
9549
9549
|
var memoized = function() {
|
|
9550
9550
|
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
@@ -9553,10 +9553,10 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
9553
9553
|
memoized.cache = cache.set(key, result$1) || cache;
|
|
9554
9554
|
return result$1;
|
|
9555
9555
|
};
|
|
9556
|
-
memoized.cache = new (memoize.Cache || MapCache)();
|
|
9556
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
9557
9557
|
return memoized;
|
|
9558
9558
|
}
|
|
9559
|
-
memoize.Cache = MapCache;
|
|
9559
|
+
memoize$1.Cache = MapCache;
|
|
9560
9560
|
/**
|
|
9561
9561
|
* Creates a function that negates the result of the predicate `func`. The
|
|
9562
9562
|
* `func` predicate is invoked with the `this` binding and arguments of the
|
|
@@ -15063,7 +15063,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
|
|
|
15063
15063
|
lodash.mapValues = mapValues;
|
|
15064
15064
|
lodash.matches = matches;
|
|
15065
15065
|
lodash.matchesProperty = matchesProperty;
|
|
15066
|
-
lodash.memoize = memoize;
|
|
15066
|
+
lodash.memoize = memoize$1;
|
|
15067
15067
|
lodash.merge = merge;
|
|
15068
15068
|
lodash.mergeWith = mergeWith;
|
|
15069
15069
|
lodash.method = method;
|
|
@@ -15718,26 +15718,6 @@ function moveNodeToContainer(instance, node, containerToMove, invalidOriginsType
|
|
|
15718
15718
|
}
|
|
15719
15719
|
return false;
|
|
15720
15720
|
}
|
|
15721
|
-
function getContrastTextColor(hex) {
|
|
15722
|
-
const cleaned = hex.replace(/^#/, "");
|
|
15723
|
-
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
15724
|
-
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
15725
|
-
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
15726
|
-
const luminance = (.299 * r + .587 * g + .114 * b) / 255;
|
|
15727
|
-
return luminance > .5 ? "black" : "white";
|
|
15728
|
-
}
|
|
15729
|
-
function stringToColor(str) {
|
|
15730
|
-
let hash = 0;
|
|
15731
|
-
str.split("").forEach((char) => {
|
|
15732
|
-
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
|
15733
|
-
});
|
|
15734
|
-
let color = "#";
|
|
15735
|
-
for (let i = 0; i < 3; i++) {
|
|
15736
|
-
const value = hash >> i * 8 & 255;
|
|
15737
|
-
color += value.toString(16).padStart(2, "0");
|
|
15738
|
-
}
|
|
15739
|
-
return color;
|
|
15740
|
-
}
|
|
15741
15721
|
function getExportBoundingBox(stage, nodes) {
|
|
15742
15722
|
if (nodes.length === 0) return {
|
|
15743
15723
|
x: 0,
|
|
@@ -15946,6 +15926,16 @@ function getVisibleNodes(instance, stage, nodeParent, skipNodes, referenceLayer)
|
|
|
15946
15926
|
if (nodesSelection) nodesSelection.getTransformer().show();
|
|
15947
15927
|
return finalVisibleNodes;
|
|
15948
15928
|
}
|
|
15929
|
+
function memoize(fn) {
|
|
15930
|
+
const cache = new Map();
|
|
15931
|
+
return function(...args) {
|
|
15932
|
+
const key = JSON.stringify(args);
|
|
15933
|
+
if (cache.has(key)) return cache.get(key);
|
|
15934
|
+
const result = fn(...args);
|
|
15935
|
+
cache.set(key, result);
|
|
15936
|
+
return result;
|
|
15937
|
+
};
|
|
15938
|
+
}
|
|
15949
15939
|
|
|
15950
15940
|
//#endregion
|
|
15951
15941
|
//#region src/actions/selection-tool/constants.ts
|
|
@@ -17085,29 +17075,11 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17085
17075
|
}
|
|
17086
17076
|
});
|
|
17087
17077
|
if (catcher) {
|
|
17088
|
-
document.addEventListener("paste", (e) => {
|
|
17078
|
+
document.addEventListener("paste", async (e) => {
|
|
17089
17079
|
e.preventDefault();
|
|
17090
17080
|
const dataList = e.clipboardData?.items;
|
|
17091
17081
|
if (!dataList) return;
|
|
17092
|
-
if (dataList?.length > 0)
|
|
17093
|
-
const container = stage.container();
|
|
17094
|
-
const scale = stage.scale();
|
|
17095
|
-
const position = stage.position();
|
|
17096
|
-
const width = container.clientWidth;
|
|
17097
|
-
const height = container.clientHeight;
|
|
17098
|
-
const centerX = (width / 2 - position.x) / scale.x;
|
|
17099
|
-
const centerY = (height / 2 - position.y) / scale.y;
|
|
17100
|
-
const pastePosition = {
|
|
17101
|
-
x: centerX,
|
|
17102
|
-
y: centerY
|
|
17103
|
-
};
|
|
17104
|
-
this.instance.emitEvent("onPasteExternal", {
|
|
17105
|
-
positionCalculated: true,
|
|
17106
|
-
position: pastePosition,
|
|
17107
|
-
dataList,
|
|
17108
|
-
items: void 0
|
|
17109
|
-
});
|
|
17110
|
-
}
|
|
17082
|
+
if (dataList?.length > 0) this.sendExternalPasteEvent(dataList);
|
|
17111
17083
|
});
|
|
17112
17084
|
catcher.addEventListener("paste", async (e) => {
|
|
17113
17085
|
e.preventDefault();
|
|
@@ -17122,10 +17094,34 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
17122
17094
|
const continueToPaste = this.isWeaveData(readText);
|
|
17123
17095
|
if (continueToPaste) hasWeaveData = true;
|
|
17124
17096
|
}
|
|
17125
|
-
if (hasWeaveData)
|
|
17097
|
+
if (hasWeaveData) {
|
|
17098
|
+
this.handlePaste();
|
|
17099
|
+
return;
|
|
17100
|
+
}
|
|
17101
|
+
this.sendExternalPasteEvent(void 0, items);
|
|
17126
17102
|
});
|
|
17127
17103
|
}
|
|
17128
17104
|
}
|
|
17105
|
+
sendExternalPasteEvent(dataList, items) {
|
|
17106
|
+
const stage = this.instance.getStage();
|
|
17107
|
+
const container = stage.container();
|
|
17108
|
+
const scale = stage.scale();
|
|
17109
|
+
const position = stage.position();
|
|
17110
|
+
const width = container.clientWidth;
|
|
17111
|
+
const height = container.clientHeight;
|
|
17112
|
+
const centerX = (width / 2 - position.x) / scale.x;
|
|
17113
|
+
const centerY = (height / 2 - position.y) / scale.y;
|
|
17114
|
+
const pastePosition = {
|
|
17115
|
+
x: centerX,
|
|
17116
|
+
y: centerY
|
|
17117
|
+
};
|
|
17118
|
+
this.instance.emitEvent("onPasteExternal", {
|
|
17119
|
+
positionCalculated: true,
|
|
17120
|
+
position: pastePosition,
|
|
17121
|
+
dataList,
|
|
17122
|
+
items
|
|
17123
|
+
});
|
|
17124
|
+
}
|
|
17129
17125
|
isWeaveData(text) {
|
|
17130
17126
|
try {
|
|
17131
17127
|
const object = JSON.parse(text);
|
|
@@ -19274,7 +19270,7 @@ var WeaveRegisterManager = class {
|
|
|
19274
19270
|
|
|
19275
19271
|
//#endregion
|
|
19276
19272
|
//#region package.json
|
|
19277
|
-
var version = "0.
|
|
19273
|
+
var version = "0.55.0";
|
|
19278
19274
|
|
|
19279
19275
|
//#endregion
|
|
19280
19276
|
//#region src/managers/setup.ts
|
|
@@ -24011,6 +24007,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24011
24007
|
});
|
|
24012
24008
|
const handlePointerDown = (e) => {
|
|
24013
24009
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
24010
|
+
if (this.getZoomPlugin()?.isPinching()) return;
|
|
24014
24011
|
const pointPressure = this.getPointPressure(e);
|
|
24015
24012
|
this.handleStartStroke(pointPressure);
|
|
24016
24013
|
e.evt.stopPropagation();
|
|
@@ -24018,6 +24015,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24018
24015
|
stage.on("pointerdown touchstart", handlePointerDown);
|
|
24019
24016
|
const handlePointerMove = (e) => {
|
|
24020
24017
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
24018
|
+
if (this.getZoomPlugin()?.isPinching()) return;
|
|
24021
24019
|
stage.container().style.cursor = "crosshair";
|
|
24022
24020
|
const pointPressure = this.getPointPressure(e);
|
|
24023
24021
|
this.handleMovement(pointPressure);
|
|
@@ -24026,6 +24024,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24026
24024
|
stage.on("pointermove touchmove", handlePointerMove);
|
|
24027
24025
|
const handlePointerUp = (e) => {
|
|
24028
24026
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
24027
|
+
if (this.getZoomPlugin()?.isPinching()) return;
|
|
24029
24028
|
this.handleEndStroke();
|
|
24030
24029
|
e.evt.stopPropagation();
|
|
24031
24030
|
};
|
|
@@ -24172,6 +24171,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
24172
24171
|
this.clickPoint = null;
|
|
24173
24172
|
this.setState(BRUSH_TOOL_STATE.INACTIVE);
|
|
24174
24173
|
}
|
|
24174
|
+
getZoomPlugin() {
|
|
24175
|
+
const zoomPlugin = this.instance.getPlugin("stageZoom");
|
|
24176
|
+
return zoomPlugin;
|
|
24177
|
+
}
|
|
24175
24178
|
};
|
|
24176
24179
|
|
|
24177
24180
|
//#endregion
|
|
@@ -25974,6 +25977,8 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
25974
25977
|
super();
|
|
25975
25978
|
const { config } = params;
|
|
25976
25979
|
this.config = config;
|
|
25980
|
+
this.config.getUser = memoize(this.config.getUser);
|
|
25981
|
+
this.config.getUserColor = memoize(this.config.getUserColor);
|
|
25977
25982
|
this.usersSelection = {};
|
|
25978
25983
|
}
|
|
25979
25984
|
getName() {
|
|
@@ -26027,6 +26032,7 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
26027
26032
|
const userInfo = this.config.getUser();
|
|
26028
26033
|
const store = this.instance.getStore();
|
|
26029
26034
|
store.setAwarenessInfo(WEAVE_USER_SELECTION_KEY, {
|
|
26035
|
+
rawUser: userInfo,
|
|
26030
26036
|
user: userInfo.id,
|
|
26031
26037
|
nodes: tr.nodes().map((node) => node.getAttrs().id)
|
|
26032
26038
|
});
|
|
@@ -26082,6 +26088,7 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
26082
26088
|
listening: false
|
|
26083
26089
|
});
|
|
26084
26090
|
userSelectorNode.moveToBottom();
|
|
26091
|
+
const userColor = this.config.getUserColor(userSelector.rawUser);
|
|
26085
26092
|
const userSelectorRect = new konva.default.Rect({
|
|
26086
26093
|
x: -this.padding / stage.scaleX(),
|
|
26087
26094
|
y: -this.padding / stage.scaleY(),
|
|
@@ -26090,7 +26097,7 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
|
|
|
26090
26097
|
height: (selectionRect.height + 2 * this.padding) / stage.scaleY(),
|
|
26091
26098
|
fill: "transparent",
|
|
26092
26099
|
listening: false,
|
|
26093
|
-
stroke:
|
|
26100
|
+
stroke: userColor,
|
|
26094
26101
|
strokeWidth: 3,
|
|
26095
26102
|
strokeScaleEnabled: false
|
|
26096
26103
|
});
|
|
@@ -26140,6 +26147,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26140
26147
|
super();
|
|
26141
26148
|
const { config } = params;
|
|
26142
26149
|
this.config = config;
|
|
26150
|
+
this.config.getUser = memoize(this.config.getUser);
|
|
26151
|
+
this.config.getUserBackgroundColor = memoize(this.config.getUserBackgroundColor);
|
|
26152
|
+
this.config.getUserForegroundColor = memoize(this.config.getUserForegroundColor);
|
|
26143
26153
|
this.uiConfig = {
|
|
26144
26154
|
...WEAVE_USER_POINTERS_DEFAULT_PROPS,
|
|
26145
26155
|
...this.config.ui
|
|
@@ -26193,6 +26203,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26193
26203
|
const userInfo = this.config.getUser();
|
|
26194
26204
|
const mousePos = stage.getRelativePointerPosition();
|
|
26195
26205
|
if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
|
|
26206
|
+
rawUser: userInfo,
|
|
26196
26207
|
user: userInfo.id,
|
|
26197
26208
|
name: userInfo.name,
|
|
26198
26209
|
x: mousePos.x,
|
|
@@ -26203,6 +26214,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26203
26214
|
const userInfo = this.config.getUser();
|
|
26204
26215
|
const mousePos = stage.getRelativePointerPosition();
|
|
26205
26216
|
if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
|
|
26217
|
+
rawUser: userInfo,
|
|
26206
26218
|
user: userInfo.id,
|
|
26207
26219
|
name: userInfo.name,
|
|
26208
26220
|
x: mousePos.x,
|
|
@@ -26231,14 +26243,14 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26231
26243
|
});
|
|
26232
26244
|
userPointerNode.moveToTop();
|
|
26233
26245
|
const { separation, pointer: { circleRadius, circleStrokeWidth }, name: { fontFamily, fontSize, backgroundCornerRadius, backgroundPaddingX, backgroundPaddingY } } = this.uiConfig;
|
|
26234
|
-
const
|
|
26235
|
-
const
|
|
26246
|
+
const userBackgroundColor = this.config.getUserBackgroundColor(userPointer.rawUser);
|
|
26247
|
+
const userForegroundColor = this.config.getUserForegroundColor(userPointer.rawUser);
|
|
26236
26248
|
const userPointNode = new konva.default.Circle({
|
|
26237
26249
|
id: `pointer_${userPointer.user}_userPoint`,
|
|
26238
26250
|
x: 0,
|
|
26239
26251
|
y: 0,
|
|
26240
26252
|
radius: circleRadius,
|
|
26241
|
-
fill:
|
|
26253
|
+
fill: userBackgroundColor,
|
|
26242
26254
|
stroke: "black",
|
|
26243
26255
|
strokeWidth: circleStrokeWidth,
|
|
26244
26256
|
strokeScaleEnabled: false,
|
|
@@ -26252,7 +26264,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26252
26264
|
fontSize,
|
|
26253
26265
|
fontFamily,
|
|
26254
26266
|
lineHeight: .9,
|
|
26255
|
-
fill:
|
|
26267
|
+
fill: userForegroundColor,
|
|
26256
26268
|
align: "center",
|
|
26257
26269
|
verticalAlign: "middle",
|
|
26258
26270
|
listening: false,
|
|
@@ -26270,7 +26282,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
|
|
|
26270
26282
|
width: textWidth + backgroundPaddingX * 2,
|
|
26271
26283
|
height: textHeight + backgroundPaddingY * 2,
|
|
26272
26284
|
cornerRadius: backgroundCornerRadius,
|
|
26273
|
-
fill:
|
|
26285
|
+
fill: userBackgroundColor,
|
|
26274
26286
|
listening: false
|
|
26275
26287
|
});
|
|
26276
26288
|
userPointNode.setAttrs({ y: userNameBackground.y() + userNameBackground.height() / 2 });
|
|
@@ -27316,7 +27328,6 @@ exports.containerOverCursor = containerOverCursor
|
|
|
27316
27328
|
exports.containsNodeDeep = containsNodeDeep
|
|
27317
27329
|
exports.getBoundingBox = getBoundingBox
|
|
27318
27330
|
exports.getClosestParentWithId = getClosestParentWithId
|
|
27319
|
-
exports.getContrastTextColor = getContrastTextColor
|
|
27320
27331
|
exports.getExportBoundingBox = getExportBoundingBox
|
|
27321
27332
|
exports.getSelectedNodesMetadata = getSelectedNodesMetadata
|
|
27322
27333
|
exports.getTargetAndSkipNodes = getTargetAndSkipNodes
|
|
@@ -27329,6 +27340,6 @@ exports.hasImages = hasImages
|
|
|
27329
27340
|
exports.intersectArrays = intersectArrays
|
|
27330
27341
|
exports.isInShadowDOM = isInShadowDOM
|
|
27331
27342
|
exports.isNodeInSelection = isNodeInSelection
|
|
27343
|
+
exports.memoize = memoize
|
|
27332
27344
|
exports.moveNodeToContainer = moveNodeToContainer
|
|
27333
|
-
exports.resetScale = resetScale
|
|
27334
|
-
exports.stringToColor = stringToColor
|
|
27345
|
+
exports.resetScale = resetScale
|