insync-stage-handler 4.0.0-beta.2 → 4.0.0-beta.3
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/library.js +43 -18
- package/dist/library.js.map +1 -1
- package/dist/module.js +44 -19
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
-
import { flip, prop, path, curry, map as map$1, compose, indexBy, pipe, converge, pathOr, defaultTo, of, prepend, append, flatten, join, applyTo, assoc, dissocPath, filter, propSatisfies, startsWith, pair, replace, reduce, assocPath, tap, propOr, always, last, gte, nth, apply, nAry, unless } from 'ramda';
|
|
2
|
+
import { flip, prop, path, curry, map as map$1, compose, indexBy, pipe, converge, pathOr, defaultTo, hasPath, of, prepend, append, flatten, join, applyTo, assoc, dissocPath, filter, propSatisfies, startsWith, pair, replace, reduce, assocPath, tap, propOr, always, last, gte, nth, apply, nAry, unless } from 'ramda';
|
|
3
3
|
import Ajv from 'ajv';
|
|
4
4
|
import { formatWithOptions, parseISO } from 'date-fns/fp';
|
|
5
5
|
|
|
@@ -12,9 +12,23 @@ const listEntities = curry((entitiesContainerPath, from) => pipe(converge(lookup
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Return the version of a stage object.
|
|
15
|
+
*
|
|
16
|
+
* Compatibility rule:
|
|
17
|
+
* Some legacy stages are marked as version 4 while still carrying
|
|
18
|
+
* Golden Layout data under layout.entities.layoutSections and no
|
|
19
|
+
* layout.dockviewLayout. Those need to pass through v3-to-v4.
|
|
20
|
+
*
|
|
15
21
|
* @param {Object} stage The stage for which to return the version.
|
|
16
22
|
*/
|
|
17
|
-
var detectVersion =
|
|
23
|
+
var detectVersion = (stage = {}) => {
|
|
24
|
+
const version = defaultTo(1)(prop("version", stage));
|
|
25
|
+
const hasLegacyLayoutSections = hasPath(["layout", "entities", "layoutSections", "byId"], stage);
|
|
26
|
+
const hasDockviewLayout = hasPath(["layout", "dockviewLayout"], stage);
|
|
27
|
+
if (version >= 4 && hasLegacyLayoutSections && !hasDockviewLayout) {
|
|
28
|
+
return 3;
|
|
29
|
+
}
|
|
30
|
+
return version;
|
|
31
|
+
};
|
|
18
32
|
|
|
19
33
|
class ValidationError extends Error {
|
|
20
34
|
setErrors(errors) {
|
|
@@ -3562,10 +3576,10 @@ const scaleZoomSteps$1 = stage => {
|
|
|
3562
3576
|
zoomSteps: rest.zoomStepsIsScaled ? zoomSteps : zoomSteps.map(step => step * Math.sqrt(measurementScale))
|
|
3563
3577
|
}))))(stage);
|
|
3564
3578
|
};
|
|
3565
|
-
const updateVersion$
|
|
3579
|
+
const updateVersion$2 = R.assoc("version", 3);
|
|
3566
3580
|
var v2ToV3$1 = R.pipe(R.tap(stage => {
|
|
3567
3581
|
console.log("upgrading ", stage, " from 2 to 3");
|
|
3568
|
-
}), consolidate, R.unless(R.prop("error"), R.pipe(R.prop("stage"), removeOutlets$1, scaleZoomSteps$1, dataStreamsToMeasurements$1, createTimingSlice, createTimelineSlice, createFilesTimings, createComments, createCommentsTimings, createTimelineGroups, createTimeline, fixTracks, updateVersion$
|
|
3582
|
+
}), consolidate, R.unless(R.prop("error"), R.pipe(R.prop("stage"), removeOutlets$1, scaleZoomSteps$1, dataStreamsToMeasurements$1, createTimingSlice, createTimelineSlice, createFilesTimings, createComments, createCommentsTimings, createTimelineGroups, createTimeline, fixTracks, updateVersion$2, fixPanels$1, upgradeResources)));
|
|
3569
3583
|
|
|
3570
3584
|
/**
|
|
3571
3585
|
* v3-to-v4 Stage Upgrader
|
|
@@ -3601,7 +3615,11 @@ const isComponentSection = section => {
|
|
|
3601
3615
|
};
|
|
3602
3616
|
const getRootSection = (content, sections) => {
|
|
3603
3617
|
const rootId = getSectionId(content && content[0]);
|
|
3604
|
-
|
|
3618
|
+
if (rootId) {
|
|
3619
|
+
return sections[rootId];
|
|
3620
|
+
}
|
|
3621
|
+
const firstId = Object.keys(sections)[0];
|
|
3622
|
+
return firstId ? sections[firstId] : undefined;
|
|
3605
3623
|
};
|
|
3606
3624
|
const getOrientationForSection = section => {
|
|
3607
3625
|
return (section === null || section === void 0 ? void 0 : section.type) === "row" ? DOCKVIEW_HORIZONTAL : DOCKVIEW_VERTICAL;
|
|
@@ -3640,6 +3658,19 @@ const createDockviewGroupId = section => {
|
|
|
3640
3658
|
}
|
|
3641
3659
|
return `${section.id}__group`;
|
|
3642
3660
|
};
|
|
3661
|
+
const findFirstLeafGroupId = node => {
|
|
3662
|
+
if (!node) {
|
|
3663
|
+
return undefined;
|
|
3664
|
+
}
|
|
3665
|
+
if (node.type === "leaf") {
|
|
3666
|
+
var _node$data;
|
|
3667
|
+
return (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.id;
|
|
3668
|
+
}
|
|
3669
|
+
if (!Array.isArray(node.data) || node.data.length === 0) {
|
|
3670
|
+
return undefined;
|
|
3671
|
+
}
|
|
3672
|
+
return findFirstLeafGroupId(node.data[0]);
|
|
3673
|
+
};
|
|
3643
3674
|
const createDockviewLeaf = (section, sections) => {
|
|
3644
3675
|
const childValues = section.type === "stack" ? section.content || [] : [section.id];
|
|
3645
3676
|
const panelIds = childValues.map(getSectionId).filter(panelId => Boolean(sections[panelId]));
|
|
@@ -3701,7 +3732,6 @@ const createPanelsById = sections => {
|
|
|
3701
3732
|
}, {}))(sections);
|
|
3702
3733
|
};
|
|
3703
3734
|
const convertLegacyLayoutToDockview = stage => {
|
|
3704
|
-
var _rootSection$content;
|
|
3705
3735
|
const content = R.path(["layout", "content"], stage);
|
|
3706
3736
|
const rawSections = R.pathOr({}, ["layout", "entities", "layoutSections", "byId"], stage);
|
|
3707
3737
|
const assetsById = R.pathOr({}, ["assets", "entities", "assets", "byId"], stage);
|
|
@@ -3719,7 +3749,7 @@ const convertLegacyLayoutToDockview = stage => {
|
|
|
3719
3749
|
orientation: getOrientationForSection(rootSection)
|
|
3720
3750
|
},
|
|
3721
3751
|
panels: createPanelsById(sections),
|
|
3722
|
-
activeGroup:
|
|
3752
|
+
activeGroup: findFirstLeafGroupId(rootNode)
|
|
3723
3753
|
};
|
|
3724
3754
|
};
|
|
3725
3755
|
const upgradeToDockviewLayout = stage => {
|
|
@@ -3739,12 +3769,12 @@ const upgradeToDockviewLayout = stage => {
|
|
|
3739
3769
|
// Preserve these layout state properties if they exist
|
|
3740
3770
|
R.when(R.hasPath(["layout", "focus"]), R.identity), R.when(R.hasPath(["layout", "dragging"]), R.identity), R.when(R.hasPath(["layout", "resizingPanels"]), R.identity))(stage);
|
|
3741
3771
|
};
|
|
3742
|
-
const updateVersion$
|
|
3743
|
-
var
|
|
3772
|
+
const updateVersion$1 = R.assoc("version", 4);
|
|
3773
|
+
var stageV3ToV4 = R.pipe(R.tap(stage => {
|
|
3744
3774
|
console.log("upgrading ", stage, " from 3 to 4");
|
|
3745
|
-
}), upgradeToDockviewLayout, updateVersion$
|
|
3775
|
+
}), upgradeToDockviewLayout, updateVersion$1);
|
|
3746
3776
|
|
|
3747
|
-
var upgraders = () => [[2, v1ToV2], [3, v2ToV3$1], [4,
|
|
3777
|
+
var upgraders = () => [[2, v1ToV2], [3, v2ToV3$1], [4, stageV3ToV4]];
|
|
3748
3778
|
|
|
3749
3779
|
const resolveFrom = stage => detectVersion(stage);
|
|
3750
3780
|
const resolveTo = to => defaultTo(last(versions))(to);
|
|
@@ -3926,19 +3956,14 @@ const scaleZoomSteps = stage => settings => {
|
|
|
3926
3956
|
}))))(settings);
|
|
3927
3957
|
};
|
|
3928
3958
|
const removeTimeline = R.dissoc("timeline");
|
|
3929
|
-
const updateVersion
|
|
3959
|
+
const updateVersion = R.assoc("version", 3);
|
|
3930
3960
|
var v2ToV3 = R.curry((stage, settings) => {
|
|
3931
3961
|
return R.pipe(R.tap(s => {
|
|
3932
3962
|
console.log("upgrading settings", s, " from 2 to 3");
|
|
3933
|
-
}), R.pipe(removeOutlets, dataStreamsToMeasurements, updateVersion
|
|
3963
|
+
}), R.pipe(removeOutlets, dataStreamsToMeasurements, updateVersion, scaleZoomSteps(stage), fixPanels, removeTimeline))(settings);
|
|
3934
3964
|
});
|
|
3935
3965
|
|
|
3936
|
-
|
|
3937
|
-
var v3ToV4 = R.curry((stage, settings) => {
|
|
3938
|
-
return R.pipe(R.tap(s => {
|
|
3939
|
-
console.log("upgrading settings", s, " from 3 to 4", stage.version);
|
|
3940
|
-
}), updateVersion)(settings);
|
|
3941
|
-
});
|
|
3966
|
+
var v3ToV4 = (stage, settings) => stageV3ToV4(settings);
|
|
3942
3967
|
|
|
3943
3968
|
var settingsUpgrader = R.curry((stage, settings) => {
|
|
3944
3969
|
const targetVersion = R.propOr(3, "version", stage);
|