insync-stage-handler 4.0.0-beta.2 → 4.0.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/library.js +60 -21
- package/dist/library.js.map +1 -1
- package/dist/module.js +61 -22
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
package/dist/library.js
CHANGED
|
@@ -38,9 +38,23 @@ const listEntities = R.curry((entitiesContainerPath, from) => R.pipe(R.converge(
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Return the version of a stage object.
|
|
41
|
+
*
|
|
42
|
+
* Compatibility rule:
|
|
43
|
+
* Some legacy stages are marked as version 4 while still carrying
|
|
44
|
+
* Golden Layout data under layout.entities.layoutSections and no
|
|
45
|
+
* layout.dockviewLayout. Those need to pass through v3-to-v4.
|
|
46
|
+
*
|
|
41
47
|
* @param {Object} stage The stage for which to return the version.
|
|
42
48
|
*/
|
|
43
|
-
var detectVersion =
|
|
49
|
+
var detectVersion = (stage = {}) => {
|
|
50
|
+
const version = R.defaultTo(1)(R.prop("version", stage));
|
|
51
|
+
const hasLegacyLayoutSections = R.hasPath(["layout", "entities", "layoutSections", "byId"], stage);
|
|
52
|
+
const hasDockviewLayout = R.hasPath(["layout", "dockviewLayout"], stage);
|
|
53
|
+
if (version >= 4 && hasLegacyLayoutSections && !hasDockviewLayout) {
|
|
54
|
+
return 3;
|
|
55
|
+
}
|
|
56
|
+
return version;
|
|
57
|
+
};
|
|
44
58
|
|
|
45
59
|
class ValidationError extends Error {
|
|
46
60
|
setErrors(errors) {
|
|
@@ -3588,10 +3602,10 @@ const scaleZoomSteps$1 = stage => {
|
|
|
3588
3602
|
zoomSteps: rest.zoomStepsIsScaled ? zoomSteps : zoomSteps.map(step => step * Math.sqrt(measurementScale))
|
|
3589
3603
|
}))))(stage);
|
|
3590
3604
|
};
|
|
3591
|
-
const updateVersion$
|
|
3605
|
+
const updateVersion$2 = R__namespace.assoc("version", 3);
|
|
3592
3606
|
var v2ToV3$1 = R__namespace.pipe(R__namespace.tap(stage => {
|
|
3593
3607
|
console.log("upgrading ", stage, " from 2 to 3");
|
|
3594
|
-
}), consolidate, R__namespace.unless(R__namespace.prop("error"), R__namespace.pipe(R__namespace.prop("stage"), removeOutlets$1, scaleZoomSteps$1, dataStreamsToMeasurements$1, createTimingSlice, createTimelineSlice, createFilesTimings, createComments, createCommentsTimings, createTimelineGroups, createTimeline, fixTracks, updateVersion$
|
|
3608
|
+
}), consolidate, R__namespace.unless(R__namespace.prop("error"), R__namespace.pipe(R__namespace.prop("stage"), removeOutlets$1, scaleZoomSteps$1, dataStreamsToMeasurements$1, createTimingSlice, createTimelineSlice, createFilesTimings, createComments, createCommentsTimings, createTimelineGroups, createTimeline, fixTracks, updateVersion$2, fixPanels$1, upgradeResources)));
|
|
3595
3609
|
|
|
3596
3610
|
/**
|
|
3597
3611
|
* v3-to-v4 Stage Upgrader
|
|
@@ -3627,7 +3641,11 @@ const isComponentSection = section => {
|
|
|
3627
3641
|
};
|
|
3628
3642
|
const getRootSection = (content, sections) => {
|
|
3629
3643
|
const rootId = getSectionId(content && content[0]);
|
|
3630
|
-
|
|
3644
|
+
if (rootId) {
|
|
3645
|
+
return sections[rootId];
|
|
3646
|
+
}
|
|
3647
|
+
const firstId = Object.keys(sections)[0];
|
|
3648
|
+
return firstId ? sections[firstId] : undefined;
|
|
3631
3649
|
};
|
|
3632
3650
|
const getOrientationForSection = section => {
|
|
3633
3651
|
return (section === null || section === void 0 ? void 0 : section.type) === "row" ? DOCKVIEW_HORIZONTAL : DOCKVIEW_VERTICAL;
|
|
@@ -3666,6 +3684,19 @@ const createDockviewGroupId = section => {
|
|
|
3666
3684
|
}
|
|
3667
3685
|
return `${section.id}__group`;
|
|
3668
3686
|
};
|
|
3687
|
+
const findFirstLeafGroupId = node => {
|
|
3688
|
+
if (!node) {
|
|
3689
|
+
return undefined;
|
|
3690
|
+
}
|
|
3691
|
+
if (node.type === "leaf") {
|
|
3692
|
+
var _node$data;
|
|
3693
|
+
return (_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.id;
|
|
3694
|
+
}
|
|
3695
|
+
if (!Array.isArray(node.data) || node.data.length === 0) {
|
|
3696
|
+
return undefined;
|
|
3697
|
+
}
|
|
3698
|
+
return findFirstLeafGroupId(node.data[0]);
|
|
3699
|
+
};
|
|
3669
3700
|
const createDockviewLeaf = (section, sections) => {
|
|
3670
3701
|
const childValues = section.type === "stack" ? section.content || [] : [section.id];
|
|
3671
3702
|
const panelIds = childValues.map(getSectionId).filter(panelId => Boolean(sections[panelId]));
|
|
@@ -3709,6 +3740,19 @@ const createDockviewGridNode = (section, sections) => {
|
|
|
3709
3740
|
data: children
|
|
3710
3741
|
};
|
|
3711
3742
|
};
|
|
3743
|
+
const ensureBranchRoot = node => {
|
|
3744
|
+
if (!node || node.type !== "leaf") {
|
|
3745
|
+
return node;
|
|
3746
|
+
}
|
|
3747
|
+
return {
|
|
3748
|
+
type: "branch",
|
|
3749
|
+
size: 100,
|
|
3750
|
+
data: [{
|
|
3751
|
+
...node,
|
|
3752
|
+
size: 100
|
|
3753
|
+
}]
|
|
3754
|
+
};
|
|
3755
|
+
};
|
|
3712
3756
|
const filterLayoutSectionsByAssets = (sectionsById, assetsById) => {
|
|
3713
3757
|
return R__namespace.pipe(R__namespace.map(section => {
|
|
3714
3758
|
const assetId = R__namespace.path(["props", "assetId"], section);
|
|
@@ -3727,25 +3771,25 @@ const createPanelsById = sections => {
|
|
|
3727
3771
|
}, {}))(sections);
|
|
3728
3772
|
};
|
|
3729
3773
|
const convertLegacyLayoutToDockview = stage => {
|
|
3730
|
-
var _rootSection$content;
|
|
3731
3774
|
const content = R__namespace.path(["layout", "content"], stage);
|
|
3732
3775
|
const rawSections = R__namespace.pathOr({}, ["layout", "entities", "layoutSections", "byId"], stage);
|
|
3733
3776
|
const assetsById = R__namespace.pathOr({}, ["assets", "entities", "assets", "byId"], stage);
|
|
3734
3777
|
const sections = filterLayoutSectionsByAssets(rawSections, assetsById);
|
|
3735
3778
|
const rootSection = getRootSection(content, sections);
|
|
3736
3779
|
const rootNode = createDockviewGridNode(rootSection, sections);
|
|
3737
|
-
|
|
3780
|
+
const dockviewRoot = ensureBranchRoot(rootNode);
|
|
3781
|
+
if (!rootSection || !dockviewRoot) {
|
|
3738
3782
|
return null;
|
|
3739
3783
|
}
|
|
3740
3784
|
return {
|
|
3741
3785
|
grid: {
|
|
3742
|
-
root:
|
|
3786
|
+
root: dockviewRoot,
|
|
3743
3787
|
height: 100,
|
|
3744
3788
|
width: 100,
|
|
3745
3789
|
orientation: getOrientationForSection(rootSection)
|
|
3746
3790
|
},
|
|
3747
3791
|
panels: createPanelsById(sections),
|
|
3748
|
-
activeGroup:
|
|
3792
|
+
activeGroup: findFirstLeafGroupId(rootNode)
|
|
3749
3793
|
};
|
|
3750
3794
|
};
|
|
3751
3795
|
const upgradeToDockviewLayout = stage => {
|
|
@@ -3765,12 +3809,12 @@ const upgradeToDockviewLayout = stage => {
|
|
|
3765
3809
|
// Preserve these layout state properties if they exist
|
|
3766
3810
|
R__namespace.when(R__namespace.hasPath(["layout", "focus"]), R__namespace.identity), R__namespace.when(R__namespace.hasPath(["layout", "dragging"]), R__namespace.identity), R__namespace.when(R__namespace.hasPath(["layout", "resizingPanels"]), R__namespace.identity))(stage);
|
|
3767
3811
|
};
|
|
3768
|
-
const updateVersion$
|
|
3769
|
-
var
|
|
3812
|
+
const updateVersion$1 = R__namespace.assoc("version", 4);
|
|
3813
|
+
var stageV3ToV4 = R__namespace.pipe(R__namespace.tap(stage => {
|
|
3770
3814
|
console.log("upgrading ", stage, " from 3 to 4");
|
|
3771
|
-
}), upgradeToDockviewLayout, updateVersion$
|
|
3815
|
+
}), upgradeToDockviewLayout, updateVersion$1);
|
|
3772
3816
|
|
|
3773
|
-
var upgraders = () => [[2, v1ToV2], [3, v2ToV3$1], [4,
|
|
3817
|
+
var upgraders = () => [[2, v1ToV2], [3, v2ToV3$1], [4, stageV3ToV4]];
|
|
3774
3818
|
|
|
3775
3819
|
const resolveFrom = stage => detectVersion(stage);
|
|
3776
3820
|
const resolveTo = to => R.defaultTo(R.last(versions))(to);
|
|
@@ -3952,19 +3996,14 @@ const scaleZoomSteps = stage => settings => {
|
|
|
3952
3996
|
}))))(settings);
|
|
3953
3997
|
};
|
|
3954
3998
|
const removeTimeline = R__namespace.dissoc("timeline");
|
|
3955
|
-
const updateVersion
|
|
3999
|
+
const updateVersion = R__namespace.assoc("version", 3);
|
|
3956
4000
|
var v2ToV3 = R__namespace.curry((stage, settings) => {
|
|
3957
4001
|
return R__namespace.pipe(R__namespace.tap(s => {
|
|
3958
4002
|
console.log("upgrading settings", s, " from 2 to 3");
|
|
3959
|
-
}), R__namespace.pipe(removeOutlets, dataStreamsToMeasurements, updateVersion
|
|
4003
|
+
}), R__namespace.pipe(removeOutlets, dataStreamsToMeasurements, updateVersion, scaleZoomSteps(stage), fixPanels, removeTimeline))(settings);
|
|
3960
4004
|
});
|
|
3961
4005
|
|
|
3962
|
-
|
|
3963
|
-
var v3ToV4 = R__namespace.curry((stage, settings) => {
|
|
3964
|
-
return R__namespace.pipe(R__namespace.tap(s => {
|
|
3965
|
-
console.log("upgrading settings", s, " from 3 to 4", stage.version);
|
|
3966
|
-
}), updateVersion)(settings);
|
|
3967
|
-
});
|
|
4006
|
+
var v3ToV4 = (stage, settings) => stageV3ToV4(settings);
|
|
3968
4007
|
|
|
3969
4008
|
var settingsUpgrader = R__namespace.curry((stage, settings) => {
|
|
3970
4009
|
const targetVersion = R__namespace.propOr(3, "version", stage);
|
|
@@ -3983,7 +4022,7 @@ const settingsCleaner = R__namespace.pipe(R__namespace.dissocPath(["timer", "wan
|
|
|
3983
4022
|
var settingsHandler = (stage, settings) => R__namespace.pipe(settingsUpgrader(stage), settingsCleaner)(settings);
|
|
3984
4023
|
|
|
3985
4024
|
var name = "insync-stage-handler";
|
|
3986
|
-
var version = "4.0.0
|
|
4025
|
+
var version = "4.0.0";
|
|
3987
4026
|
var description = "Handles stages files. This consists of validating, upgrading and consolodating them.";
|
|
3988
4027
|
var author = "David Ammeraal (Noterik B.V.)";
|
|
3989
4028
|
var license = "MIT";
|