@measured/puck 0.19.4-canary.f09540db → 0.20.0-canary.3da831b0
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/{chunk-IM42S4YL.mjs → chunk-H6KSTNLT.mjs} +49 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +49 -7
- package/dist/index.mjs +1 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +49 -7
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-DhtH8sAC.d.mts} +6 -1
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-DhtH8sAC.d.ts} +6 -1
- package/package.json +1 -1
|
@@ -871,8 +871,8 @@ var migrations = [
|
|
|
871
871
|
return data;
|
|
872
872
|
},
|
|
873
873
|
// Migrate zones to slots
|
|
874
|
-
(data, config) => {
|
|
875
|
-
var _a;
|
|
874
|
+
(data, config, migrationOptions) => {
|
|
875
|
+
var _a, _b;
|
|
876
876
|
if (!config) return data;
|
|
877
877
|
console.log("Migrating DropZones to slots...");
|
|
878
878
|
const updatedItems = {};
|
|
@@ -880,13 +880,13 @@ var migrations = [
|
|
|
880
880
|
const { indexes } = walkAppState(appState, config);
|
|
881
881
|
const deletedCompounds = [];
|
|
882
882
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
883
|
-
var _a2,
|
|
883
|
+
var _a2, _b2, _c;
|
|
884
884
|
if (zoneType === "dropzone") {
|
|
885
885
|
const [id, slotName] = zoneCompound.split(":");
|
|
886
886
|
const nodeData = indexes.nodes[id].data;
|
|
887
887
|
const componentType = nodeData.type;
|
|
888
888
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
889
|
-
if (((
|
|
889
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
890
890
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
891
891
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
892
892
|
[slotName]: content
|
|
@@ -915,7 +915,49 @@ var migrations = [
|
|
|
915
915
|
);
|
|
916
916
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
917
917
|
});
|
|
918
|
-
|
|
918
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
919
|
+
const unmigratedZonesGrouped = {};
|
|
920
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
921
|
+
var _a2;
|
|
922
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
923
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
924
|
+
if (!content) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
928
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
929
|
+
}
|
|
930
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
931
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
935
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
936
|
+
return content.map((child) => {
|
|
937
|
+
var _a2;
|
|
938
|
+
if (child.props.id !== componentId) {
|
|
939
|
+
return child;
|
|
940
|
+
}
|
|
941
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
942
|
+
if (!migrateFn) {
|
|
943
|
+
return child;
|
|
944
|
+
}
|
|
945
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
946
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
947
|
+
Object.keys(zones).forEach((propName) => {
|
|
948
|
+
var _a3;
|
|
949
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
950
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
951
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
952
|
+
});
|
|
953
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
954
|
+
props: migratedProps
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
919
961
|
const [_, propName] = zoneCompound.split(":");
|
|
920
962
|
throw new Error(
|
|
921
963
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -925,9 +967,9 @@ var migrations = [
|
|
|
925
967
|
return updated.data;
|
|
926
968
|
}
|
|
927
969
|
];
|
|
928
|
-
function migrate(data, config) {
|
|
970
|
+
function migrate(data, config, migrationOptions) {
|
|
929
971
|
return migrations == null ? void 0 : migrations.reduce(
|
|
930
|
-
(acc, migration) => migration(acc, config),
|
|
972
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
931
973
|
data
|
|
932
974
|
);
|
|
933
975
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-
|
|
2
|
-
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-DhtH8sAC.mjs';
|
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-
|
|
2
|
-
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-DhtH8sAC.js';
|
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
package/dist/index.js
CHANGED
|
@@ -1627,8 +1627,8 @@ var migrations = [
|
|
|
1627
1627
|
return data;
|
|
1628
1628
|
},
|
|
1629
1629
|
// Migrate zones to slots
|
|
1630
|
-
(data, config) => {
|
|
1631
|
-
var _a;
|
|
1630
|
+
(data, config, migrationOptions) => {
|
|
1631
|
+
var _a, _b;
|
|
1632
1632
|
if (!config) return data;
|
|
1633
1633
|
console.log("Migrating DropZones to slots...");
|
|
1634
1634
|
const updatedItems = {};
|
|
@@ -1636,13 +1636,13 @@ var migrations = [
|
|
|
1636
1636
|
const { indexes } = walkAppState(appState, config);
|
|
1637
1637
|
const deletedCompounds = [];
|
|
1638
1638
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
1639
|
-
var _a2,
|
|
1639
|
+
var _a2, _b2, _c;
|
|
1640
1640
|
if (zoneType === "dropzone") {
|
|
1641
1641
|
const [id, slotName] = zoneCompound.split(":");
|
|
1642
1642
|
const nodeData = indexes.nodes[id].data;
|
|
1643
1643
|
const componentType = nodeData.type;
|
|
1644
1644
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
1645
|
-
if (((
|
|
1645
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
1646
1646
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
1647
1647
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
1648
1648
|
[slotName]: content
|
|
@@ -1671,7 +1671,49 @@ var migrations = [
|
|
|
1671
1671
|
);
|
|
1672
1672
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
1673
1673
|
});
|
|
1674
|
-
|
|
1674
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
1675
|
+
const unmigratedZonesGrouped = {};
|
|
1676
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
1677
|
+
var _a2;
|
|
1678
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
1679
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
1680
|
+
if (!content) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
1684
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
1685
|
+
}
|
|
1686
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
1687
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
1691
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
1692
|
+
return content.map((child) => {
|
|
1693
|
+
var _a2;
|
|
1694
|
+
if (child.props.id !== componentId) {
|
|
1695
|
+
return child;
|
|
1696
|
+
}
|
|
1697
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
1698
|
+
if (!migrateFn) {
|
|
1699
|
+
return child;
|
|
1700
|
+
}
|
|
1701
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
1702
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
1703
|
+
Object.keys(zones).forEach((propName) => {
|
|
1704
|
+
var _a3;
|
|
1705
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
1706
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
1707
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
1708
|
+
});
|
|
1709
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
1710
|
+
props: migratedProps
|
|
1711
|
+
});
|
|
1712
|
+
});
|
|
1713
|
+
});
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
1675
1717
|
const [_, propName] = zoneCompound.split(":");
|
|
1676
1718
|
throw new Error(
|
|
1677
1719
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -1681,9 +1723,9 @@ var migrations = [
|
|
|
1681
1723
|
return updated.data;
|
|
1682
1724
|
}
|
|
1683
1725
|
];
|
|
1684
|
-
function migrate(data, config) {
|
|
1726
|
+
function migrate(data, config, migrationOptions) {
|
|
1685
1727
|
return migrations == null ? void 0 : migrations.reduce(
|
|
1686
|
-
(acc, migration) => migration(acc, config),
|
|
1728
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
1687
1729
|
data
|
|
1688
1730
|
);
|
|
1689
1731
|
}
|
package/dist/index.mjs
CHANGED
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DhtH8sAC.mjs';
|
|
3
|
+
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DhtH8sAC.js';
|
|
3
|
+
export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DhtH8sAC.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.js
CHANGED
|
@@ -816,8 +816,8 @@ var migrations = [
|
|
|
816
816
|
return data;
|
|
817
817
|
},
|
|
818
818
|
// Migrate zones to slots
|
|
819
|
-
(data, config) => {
|
|
820
|
-
var _a;
|
|
819
|
+
(data, config, migrationOptions) => {
|
|
820
|
+
var _a, _b;
|
|
821
821
|
if (!config) return data;
|
|
822
822
|
console.log("Migrating DropZones to slots...");
|
|
823
823
|
const updatedItems = {};
|
|
@@ -825,13 +825,13 @@ var migrations = [
|
|
|
825
825
|
const { indexes } = walkAppState(appState, config);
|
|
826
826
|
const deletedCompounds = [];
|
|
827
827
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
828
|
-
var _a2,
|
|
828
|
+
var _a2, _b2, _c;
|
|
829
829
|
if (zoneType === "dropzone") {
|
|
830
830
|
const [id, slotName] = zoneCompound.split(":");
|
|
831
831
|
const nodeData = indexes.nodes[id].data;
|
|
832
832
|
const componentType = nodeData.type;
|
|
833
833
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
834
|
-
if (((
|
|
834
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
835
835
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
836
836
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
837
837
|
[slotName]: content
|
|
@@ -860,7 +860,49 @@ var migrations = [
|
|
|
860
860
|
);
|
|
861
861
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
862
862
|
});
|
|
863
|
-
|
|
863
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
864
|
+
const unmigratedZonesGrouped = {};
|
|
865
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
866
|
+
var _a2;
|
|
867
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
868
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
869
|
+
if (!content) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
873
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
874
|
+
}
|
|
875
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
876
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
880
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
881
|
+
return content.map((child) => {
|
|
882
|
+
var _a2;
|
|
883
|
+
if (child.props.id !== componentId) {
|
|
884
|
+
return child;
|
|
885
|
+
}
|
|
886
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
887
|
+
if (!migrateFn) {
|
|
888
|
+
return child;
|
|
889
|
+
}
|
|
890
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
891
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
892
|
+
Object.keys(zones).forEach((propName) => {
|
|
893
|
+
var _a3;
|
|
894
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
895
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
896
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
897
|
+
});
|
|
898
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
899
|
+
props: migratedProps
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
864
906
|
const [_, propName] = zoneCompound.split(":");
|
|
865
907
|
throw new Error(
|
|
866
908
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -870,9 +912,9 @@ var migrations = [
|
|
|
870
912
|
return updated.data;
|
|
871
913
|
}
|
|
872
914
|
];
|
|
873
|
-
function migrate(data, config) {
|
|
915
|
+
function migrate(data, config, migrationOptions) {
|
|
874
916
|
return migrations == null ? void 0 : migrations.reduce(
|
|
875
|
-
(acc, migration) => migration(acc, config),
|
|
917
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
876
918
|
data
|
|
877
919
|
);
|
|
878
920
|
}
|
package/dist/rsc.mjs
CHANGED
|
@@ -535,7 +535,12 @@ type PuckAction = {
|
|
|
535
535
|
recordHistory?: boolean;
|
|
536
536
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
537
|
|
|
538
|
-
|
|
538
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
539
|
+
migrateDynamicZonesForComponent?: {
|
|
540
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
544
|
|
|
540
545
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
546
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
|
@@ -535,7 +535,12 @@ type PuckAction = {
|
|
|
535
535
|
recordHistory?: boolean;
|
|
536
536
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
|
537
537
|
|
|
538
|
-
|
|
538
|
+
type MigrationOptions<UserConfig extends Config> = {
|
|
539
|
+
migrateDynamicZonesForComponent?: {
|
|
540
|
+
[ComponentName in keyof UserConfig["components"]]: (props: WithId<UserGenerics<UserConfig>["UserProps"][ComponentName]>, zones: Record<string, Content>) => ComponentData["props"];
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
declare function migrate<UserConfig extends Config = Config>(data: Data, config?: UserConfig, migrationOptions?: MigrationOptions<UserConfig>): Data;
|
|
539
544
|
|
|
540
545
|
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
|
541
546
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
package/package.json
CHANGED