@contentstack/studio-internal 1.1.5 → 1.2.1
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/constants/condition.d.ts +190 -4290
- package/dist/constants/condition.d.ts.map +1 -1
- package/dist/constants/condition.js +26 -6
- package/dist/constants/condition.js.map +1 -1
- package/dist/constants/id.d.ts +13 -0
- package/dist/constants/id.d.ts.map +1 -0
- package/dist/constants/id.js +15 -0
- package/dist/constants/id.js.map +1 -0
- package/dist/core/apply.d.ts.map +1 -1
- package/dist/core/apply.js +15 -2
- package/dist/core/apply.js.map +1 -1
- package/dist/editor/pathRef.js +1 -1
- package/dist/editor/without-normalizing.js +1 -1
- package/dist/index.d.ts +294 -4292
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/node.d.ts +1 -0
- package/dist/interfaces/node.d.ts.map +1 -1
- package/dist/interfaces/node.js +8 -7
- package/dist/interfaces/node.js.map +1 -1
- package/dist/interfaces/transforms/general.d.ts.map +1 -1
- package/dist/interfaces/transforms/general.js +11 -0
- package/dist/interfaces/transforms/general.js.map +1 -1
- package/dist/transforms-node/insert-slot.js +1 -1
- package/dist/transforms-node/lift-nodes.js +1 -1
- package/dist/transforms-node/move-nodes.js +1 -1
- package/dist/transforms-node/set-props.d.ts.map +1 -1
- package/dist/transforms-node/set-props.js +27 -14
- package/dist/transforms-node/set-props.js.map +1 -1
- package/dist/transforms-node/set-selection.js +1 -1
- package/dist/transforms-node/unwrap-nodes.js +1 -1
- package/dist/transforms-node/wrap-nodes.js +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/section-slot-walker.d.ts +51 -0
- package/dist/utils/section-slot-walker.d.ts.map +1 -0
- package/dist/utils/section-slot-walker.js +63 -0
- package/dist/utils/section-slot-walker.js.map +1 -0
- package/dist/utils/spec-compression.d.ts +55 -0
- package/dist/utils/spec-compression.d.ts.map +1 -0
- package/dist/utils/spec-compression.js +99 -0
- package/dist/utils/spec-compression.js.map +1 -0
- package/package.json +8 -6
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,GACxB,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,4 +33,7 @@ export { setProp } from './transforms-node/set-props.js';
|
|
|
33
33
|
export { setClasses } from './transforms-node/set-classes.js';
|
|
34
34
|
export { unsetProp } from './transforms-node/unset-props.js';
|
|
35
35
|
export { CONDITION_OPERATORS } from './constants/condition.js';
|
|
36
|
+
export { ID_LENGTH } from './constants/id.js';
|
|
37
|
+
export { compressSpec, decompressSpec, validateCompression } from './utils/spec-compression.js';
|
|
38
|
+
export { indexSectionSlotContexts } from './utils/section-slot-walker.js';
|
|
36
39
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/interfaces/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/interfaces/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AACF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,QAAQ,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA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kBAAkB,CACzB,CAAC,EAAE,IAAI,EACP,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,UAAU,CAAC"}
|
package/dist/interfaces/node.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
2
|
import { isPlainObject } from '../utils/is-plain-object.js';
|
|
3
|
+
import { ID_LENGTH } from '../constants/id.js';
|
|
3
4
|
import { Path } from './path.js';
|
|
4
5
|
import 'immer';
|
|
5
6
|
|
|
@@ -16,13 +17,10 @@ const Node = {
|
|
|
16
17
|
throw new Error(`The type of the node must be a string`);
|
|
17
18
|
}
|
|
18
19
|
return {
|
|
19
|
-
uid:
|
|
20
|
+
uid: nanoid(ID_LENGTH),
|
|
20
21
|
attrs: {},
|
|
21
22
|
type,
|
|
22
|
-
metadata: {
|
|
23
|
-
visible: true,
|
|
24
|
-
locked: false,
|
|
25
|
-
},
|
|
23
|
+
metadata: {},
|
|
26
24
|
props: {},
|
|
27
25
|
slots: {},
|
|
28
26
|
styles: {},
|
|
@@ -52,7 +50,10 @@ const Node = {
|
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
54
52
|
if (node.props[propPath].type === "slot") {
|
|
55
|
-
|
|
53
|
+
const prop = node.props[propPath];
|
|
54
|
+
if (prop && prop.type === "slot" && prop.slot) {
|
|
55
|
+
delete node.slots[prop.slot];
|
|
56
|
+
}
|
|
56
57
|
}
|
|
57
58
|
// TODO: use the propPath to handle the array and object props
|
|
58
59
|
delete node.props[propPath];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sources":["../../src/interfaces/node.ts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../src/interfaces/node.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AA8NO,MAAM,IAAI,GAAkB;AACjC,IAAA,SAAS,CACP,IAAU,EACV,IAAU,EACV,UAAgC,EAAE,EAAA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B;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC;CACtD;
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/interfaces/transforms/general.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,MAAM,EAAQ,SAAS,EAAQ,MAAM,UAAU,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC;CACtD;AAyID,eAAO,MAAM,iBAAiB,EAAE,iBAoB/B,CAAC"}
|
|
@@ -8,6 +8,17 @@ const applyToDraft = (editor, selection, op) => {
|
|
|
8
8
|
const { path, node } = op;
|
|
9
9
|
const parent = Node.parent(editor, path);
|
|
10
10
|
const [slot, index] = path[path.length - 1];
|
|
11
|
+
// Defensive: lazily create the slot array if the parent doesn't yet
|
|
12
|
+
// declare it. section-composition nodes don't pre-declare their
|
|
13
|
+
// exposed slots in `props.children` — the slot is identified by a
|
|
14
|
+
// section-slot placeholder inside the section's authored UI — so the
|
|
15
|
+
// page-side parent may be missing the slot key on first drop.
|
|
16
|
+
if (!parent.slots) {
|
|
17
|
+
parent.slots = {};
|
|
18
|
+
}
|
|
19
|
+
if (!parent.slots[slot]) {
|
|
20
|
+
parent.slots[slot] = [];
|
|
21
|
+
}
|
|
11
22
|
if (index > parent.slots[slot].length) {
|
|
12
23
|
throw new Error(`Cannot apply an "insert_node" operation at path [${path}] because the destination is past the end of the node.`);
|
|
13
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sources":["../../../src/interfaces/transforms/general.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA,MAAM,YAAY,GAAG,CACnB,MAAc,EACd,SAAsB,EACtB,EAAa,KACX;AACF,IAAA,QAAQ,EAAE,CAAC,IAAI;QACb,KAAK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C5C,gBAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACjB,oBAAA,OAAO,IAAI,CAAC,GAAiB,CAAC;gBAChC;qBAAO;AACL,oBAAA,IAAI,CAAC,GAAiB,CAAC,GAAG,KAAY;gBACxC;YACF;YAEA;QACF;QAEA,KAAK,eAAe,EAAE;AACpB,YAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE;YAEnB,SAAS,GAAG,IAAI;YAChB;QACF;QAEA,KAAK,yBAAyB,EAAE;AAC9B,YAAA,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE;AACnB,YAAA,MAAM,CAAC,iBAAiB,GAAG,IAAI;YAC/B;QACF;;AAMF,IAAA,OAAO,SAAS;AAClB,CAAC;AAEM,MAAM,iBAAiB,GAAsB;IAClD,SAAS,CAAC,MAAc,EAAE,EAAa,EAAA;QACrC,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;AACxC,QAAA,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;AAEjE,QAAA,IAAI;YACF,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QACjD;gBAAU;YACR,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YAExC,IAAI,SAAS,EAAE;AACb,gBAAA,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS;AAClC,sBAAE,WAAW,CAAC,SAAS;sBACrB,SAAS;YACf;iBAAO;AACL,gBAAA,MAAM,CAAC,SAAS,GAAG,IAAI;YACzB;QACF;AACA,QAAA,OAAO,MAAM;IACf,CAAC;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-props.d.ts","sourceRoot":"","sources":["../../src/transforms-node/set-props.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-props.d.ts","sourceRoot":"","sources":["../../src/transforms-node/set-props.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAO/D,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,SAAS,CAuG7C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import 'nanoid';
|
|
2
2
|
import 'lodash-es';
|
|
3
3
|
import { Transforms } from '../interfaces/transforms/index.js';
|
|
4
4
|
|
|
@@ -42,20 +42,33 @@ const setProp = (editor, propKey, prop, nodes, options = {}) => {
|
|
|
42
42
|
prevProp.slot !== nextProp.slot;
|
|
43
43
|
const isNewSlot = isNodeSlotProp(nextProp) && !isNodeSlotProp(prevProp);
|
|
44
44
|
if (hasChangedFromSlot || hasSlotIdChanged || isNewSlot) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const slotsMerge = (prev, _next) => {
|
|
46
|
+
const prevSlots = (prev || {});
|
|
47
|
+
const nextSlots = Object.assign({}, prevSlots);
|
|
48
|
+
if (!isNewSlot) {
|
|
49
|
+
delete nextSlots[prevProp.slot];
|
|
50
|
+
}
|
|
51
|
+
if (hasSlotIdChanged || isNewSlot) {
|
|
52
|
+
nextSlots[nextProp.slot] = nodes;
|
|
53
|
+
}
|
|
54
|
+
return nextSlots;
|
|
55
|
+
};
|
|
56
|
+
Transforms.setNodes(editor, { slots: {} }, { at, allowAllProp: true, merge: slotsMerge });
|
|
57
|
+
// Clean up slot name from metadata when slot is removed or changed
|
|
58
|
+
if (hasChangedFromSlot || hasSlotIdChanged) {
|
|
59
|
+
const slotToRemove = prevProp.slot;
|
|
60
|
+
const metadataMerge = (prev, _next) => {
|
|
61
|
+
const nextMetadata = { ...prev };
|
|
62
|
+
if (nextMetadata.slotNames &&
|
|
63
|
+
nextMetadata.slotNames[slotToRemove]) {
|
|
64
|
+
const nextSlotNames = { ...nextMetadata.slotNames };
|
|
65
|
+
delete nextSlotNames[slotToRemove];
|
|
66
|
+
nextMetadata.slotNames = nextSlotNames;
|
|
52
67
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
});
|
|
68
|
+
return nextMetadata;
|
|
69
|
+
};
|
|
70
|
+
Transforms.setNodes(editor, { metadata: {} }, { at, merge: metadataMerge });
|
|
71
|
+
}
|
|
59
72
|
}
|
|
60
73
|
if (hasChangedFromSlot) {
|
|
61
74
|
//@ts-expect-error deleting slot property
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-props.js","sources":["../../src/transforms-node/set-props.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"set-props.js","sources":["../../src/transforms-node/set-props.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA;AACA,MAAM,cAAc,GAAG,CAAC,IAAuB,KAA+B;AAC5E,IAAA,OAAO,IAAI,EAAE,IAAI,KAAK,MAAM;AAC9B,CAAC;AAEM,MAAM,OAAO,GAA8B,CAChD,MAAM,EACN,OAAO,EACP,IAAI,EACJ,KAAK,EACL,OAAO,GAAG,EAAE,KACV;IACF,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,OAAO;IAEzC,IAAI,CAAC,EAAE,EAAE;QACP;IACF;IAEA,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,0CAAA,CAA4C,CAAC;IAC/D;;;;IAIA,UAAU,CAAC,QAAQ,CACjB,MAAM,EACN,EAAE,KAAK,EAAE,EAAe,EAAE,EAC1B;QACE,EAAE;AACF,QAAA,YAAY,EAAE,IAAI;;AAElB,QAAA,KAAK,EAAE,CAAC,SAAoB,KAAI;AAC9B,YAAA,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAa;AACjD,YAAA,MAAM,QAAQ,GAAG;AACf,gBAAA,G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AAC;gBACD,UAAU,CAAC,QAAQ,CACjB,MAAM,EACN,EAAE,KAAK,EAAE,EAAE,EAAE,EACb,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAC9C;;AAGD,gBAAA,IAAI,kBAAkB,IAAI,gBAAgB,EAAE;AAC1C,oBAAA,MAAM,YAAY,GAAI,QAA8B,CAAC,IAAI;AACzD,oBAAA,MAAM,aAAa,GAAe,CAAC,IAAI,EAAE,KAAK,KAAI;AAChD,wBAAA,MAAM,YAAY,GAAG,EAAE,GAAI,IAAyB,EAAE;wBACtD,IACE,YAAY,CAAC,SAAS;AACtB,4BAAA,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,EACpC;4BACA,MAAM,aAAa,GAAG,EAAE,GAAG,YAAY,CAAC,SAAS,EAAE;AACnD,4BAAA,OAAO,aAAa,CAAC,YAAY,CAAC;AAClC,4BAAA,YAAY,CAAC,SAAS,GAAG,aAAa;wBACxC;AACA,wBAAA,OAAO,YAAY;AACrB,oBAAA,CAAC;AACD,oBAAA,UAAU,CAAC,QAAQ,CACjB,MAAM,EACN,EAAE,QAAQ,EAAE,EAAE,EAAE,EAChB,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAC7B;gBACH;YACF;YAEA,IAAI,kBAAkB,EAAE;;AAEtB,gBAAA,OAAO,QAAQ,CAAC,MAAM,CAAC;YACzB;;YAEA,OAAO;AACL,gBAAA,IAAI,SAAS,IAAI,EAAE,CAAC;gBACpB,CAAC,OAAO,GAAG,QAAQ;aACpB;QACH,CAAC;AACF,KAAA,CACF;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,cAA0B,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGO,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,SAAS;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared section-UI walker for section-slot context resolution.
|
|
3
|
+
*
|
|
4
|
+
* Sections expose `section-slot` placeholders inside their authored UI. When
|
|
5
|
+
* those slots are filled on a page composition, the slot children render
|
|
6
|
+
* inside the section's body — surrounded by whatever Repeater /
|
|
7
|
+
* ConditionBlock chain wraps the matching `section-slot` in the section's
|
|
8
|
+
* authored UI.
|
|
9
|
+
*
|
|
10
|
+
* Three call sites historically each rolled their own walker:
|
|
11
|
+
*
|
|
12
|
+
* - Studio's `findSectionCompositionInstances` (auto-binder) — needs
|
|
13
|
+
* parentRepeaterUid + cumulative schema-path segments for the
|
|
14
|
+
* auto-binder's contextSchemaPath input.
|
|
15
|
+
* - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual
|
|
16
|
+
* Repeater node references for a SPECIFIC slot (to feed the picker's
|
|
17
|
+
* repeater adapters and to surface the section title as the picker
|
|
18
|
+
* header label).
|
|
19
|
+
* - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest
|
|
20
|
+
* ancestor Repeater uid per slot, for the per-instance binding seeder.
|
|
21
|
+
*
|
|
22
|
+
* All three did the same walk with different output shapes. This module
|
|
23
|
+
* does the walk ONCE and exposes the raw ancestor-node chain per slot;
|
|
24
|
+
* each consumer derives the shape it needs. Lives in `studio-internal`
|
|
25
|
+
* because that's the only SDK package both Studio and the SDK packages
|
|
26
|
+
* symlink to.
|
|
27
|
+
*/
|
|
28
|
+
export interface SectionSlotContext {
|
|
29
|
+
/**
|
|
30
|
+
* Root→leaf chain of ancestor `repeater` AND `condition-block` nodes
|
|
31
|
+
* wrapping the slot, interleaved in the order they appear in the
|
|
32
|
+
* section's authored tree. Callers can filter by `node.type` if they
|
|
33
|
+
* only need one kind, or walk in order to derive a cumulative
|
|
34
|
+
* schema-path.
|
|
35
|
+
*/
|
|
36
|
+
ancestorNodes: any[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Walks `sectionUI` and returns, for every `section-slot` encountered, the
|
|
40
|
+
* chain of ancestor Repeater and ConditionBlock nodes wrapping it.
|
|
41
|
+
*
|
|
42
|
+
* The returned arrays preserve root→leaf order so callers can either
|
|
43
|
+
* - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or
|
|
44
|
+
* - join their bindings to derive the cumulative schema path.
|
|
45
|
+
*
|
|
46
|
+
* Returns a map keyed by section-slot uid. If a slot uid is missing from the
|
|
47
|
+
* map the slot isn't wrapped by any Repeater / ConditionBlock in the section
|
|
48
|
+
* (or doesn't exist in this section).
|
|
49
|
+
*/
|
|
50
|
+
export declare function indexSectionSlotContexts(sectionUI: any): Record<string, SectionSlotContext>;
|
|
51
|
+
//# sourceMappingURL=section-slot-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-slot-walker.d.ts","sourceRoot":"","sources":["../../src/utils/section-slot-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,aAAa,EAAE,GAAG,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,GAAG,GACb,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAoBpC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared section-UI walker for section-slot context resolution.
|
|
3
|
+
*
|
|
4
|
+
* Sections expose `section-slot` placeholders inside their authored UI. When
|
|
5
|
+
* those slots are filled on a page composition, the slot children render
|
|
6
|
+
* inside the section's body — surrounded by whatever Repeater /
|
|
7
|
+
* ConditionBlock chain wraps the matching `section-slot` in the section's
|
|
8
|
+
* authored UI.
|
|
9
|
+
*
|
|
10
|
+
* Three call sites historically each rolled their own walker:
|
|
11
|
+
*
|
|
12
|
+
* - Studio's `findSectionCompositionInstances` (auto-binder) — needs
|
|
13
|
+
* parentRepeaterUid + cumulative schema-path segments for the
|
|
14
|
+
* auto-binder's contextSchemaPath input.
|
|
15
|
+
* - Studio's picker `getRepeatersWrappingSectionSlot` — needs the actual
|
|
16
|
+
* Repeater node references for a SPECIFIC slot (to feed the picker's
|
|
17
|
+
* repeater adapters and to surface the section title as the picker
|
|
18
|
+
* header label).
|
|
19
|
+
* - SDK's `indexSectionInternalSlotRepeaters` — needs only the nearest
|
|
20
|
+
* ancestor Repeater uid per slot, for the per-instance binding seeder.
|
|
21
|
+
*
|
|
22
|
+
* All three did the same walk with different output shapes. This module
|
|
23
|
+
* does the walk ONCE and exposes the raw ancestor-node chain per slot;
|
|
24
|
+
* each consumer derives the shape it needs. Lives in `studio-internal`
|
|
25
|
+
* because that's the only SDK package both Studio and the SDK packages
|
|
26
|
+
* symlink to.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Walks `sectionUI` and returns, for every `section-slot` encountered, the
|
|
30
|
+
* chain of ancestor Repeater and ConditionBlock nodes wrapping it.
|
|
31
|
+
*
|
|
32
|
+
* The returned arrays preserve root→leaf order so callers can either
|
|
33
|
+
* - read the LAST entry as the nearest ancestor (e.g. parentRepeaterUid), or
|
|
34
|
+
* - join their bindings to derive the cumulative schema path.
|
|
35
|
+
*
|
|
36
|
+
* Returns a map keyed by section-slot uid. If a slot uid is missing from the
|
|
37
|
+
* map the slot isn't wrapped by any Repeater / ConditionBlock in the section
|
|
38
|
+
* (or doesn't exist in this section).
|
|
39
|
+
*/
|
|
40
|
+
function indexSectionSlotContexts(sectionUI) {
|
|
41
|
+
const out = {};
|
|
42
|
+
const walk = (node, ancestors) => {
|
|
43
|
+
if (!node || typeof node !== "object")
|
|
44
|
+
return;
|
|
45
|
+
if (node.type === "section-slot" && typeof node.uid === "string") {
|
|
46
|
+
out[node.uid] = { ancestorNodes: ancestors };
|
|
47
|
+
}
|
|
48
|
+
const nextAncestors = node.type === "repeater" || node.type === "condition-block"
|
|
49
|
+
? [...ancestors, node]
|
|
50
|
+
: ancestors;
|
|
51
|
+
const slots = node.slots || {};
|
|
52
|
+
for (const slotId of Object.keys(slots)) {
|
|
53
|
+
for (const child of slots[slotId] || []) {
|
|
54
|
+
walk(child, nextAncestors);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
walk(sectionUI, []);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { indexSectionSlotContexts };
|
|
63
|
+
//# sourceMappingURL=section-slot-walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-slot-walker.js","sources":["../../src/utils/section-slot-walker.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AAaH;;;;;;;;;;;AAWG;AACG,SAAU,wBAAwB,CACtC,SAAc,EAAA;IAEd,MAAM,GAAG,GAAuC,EAAE;AAClD,IAAA,MAAM,IAAI,GAAG,CAAC,IAAS,EAAE,SAAgB,KAAI;AAC3C,QAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE;AACvC,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,EAAE;YAChE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE;QAC9C;AACA,QAAA,MAAM,aAAa,GACjB,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK;AACxC,cAAE,CAAC,GAAG,SAAS,EAAE,IAAI;cACnB,SAAS;AACf,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;QAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACvC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE;AACvC,gBAAA,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC;YAC5B;QACF;AACF,IAAA,CAAC;AACD,IAAA,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;AACnB,IAAA,OAAO,GAAG;AACZ;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Node } from "../interfaces/node";
|
|
2
|
+
/**
|
|
3
|
+
* Compress a UI spec using zlib compression for storage.
|
|
4
|
+
*
|
|
5
|
+
* The compressed output is base64-encoded and prefixed with "zlib:" for format detection.
|
|
6
|
+
* This achieves 77-90% size reduction on typical UI specs.
|
|
7
|
+
* Uses fflate library which works in both Node.js and browser environments.
|
|
8
|
+
*
|
|
9
|
+
* @param spec - The UI spec Node to compress
|
|
10
|
+
* @returns Base64-encoded compressed string prefixed with "zlib:"
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const compressed = compressSpec(editor.getUI());
|
|
14
|
+
* // Returns: "zlib:eJzt3Vtv2..."
|
|
15
|
+
*/
|
|
16
|
+
export declare function compressSpec(spec: Node): string;
|
|
17
|
+
/**
|
|
18
|
+
* Decompress a UI spec from storage.
|
|
19
|
+
*
|
|
20
|
+
* Automatically detects and handles both formats:
|
|
21
|
+
* - Compressed format: "zlib:..." (base64-encoded zlib)
|
|
22
|
+
* - Legacy format: Raw JSON string
|
|
23
|
+
*
|
|
24
|
+
* This provides backward compatibility with existing uncompressed specs.
|
|
25
|
+
*
|
|
26
|
+
* @param data - Compressed or legacy JSON string from storage
|
|
27
|
+
* @returns Parsed Node object
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Compressed format
|
|
31
|
+
* const spec = decompressSpec("zlib:eJzt3Vtv2...");
|
|
32
|
+
*
|
|
33
|
+
* // Legacy format (backward compatible)
|
|
34
|
+
* const spec = decompressSpec('{"uid":"abc","type":"page",...}');
|
|
35
|
+
*/
|
|
36
|
+
export declare function decompressSpec(data: string): Node;
|
|
37
|
+
/**
|
|
38
|
+
* Validate compression with round-trip test.
|
|
39
|
+
* Use this during development to ensure data integrity.
|
|
40
|
+
*
|
|
41
|
+
* @param spec - The spec to validate
|
|
42
|
+
* @returns Object with validation results
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const result = validateCompression(editor.getUI());
|
|
46
|
+
* console.log(`Compression: ${result.compressionRatio}%`);
|
|
47
|
+
* console.log(`Integrity: ${result.isIdentical ? 'PASS' : 'FAIL'}`);
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateCompression(spec: Node): {
|
|
50
|
+
originalSize: number;
|
|
51
|
+
compressedSize: number;
|
|
52
|
+
compressionRatio: number;
|
|
53
|
+
isIdentical: boolean;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=spec-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-compression.d.ts","sourceRoot":"","sources":["../../src/utils/spec-compression.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAY/C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAsBjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB,CAyBA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { zlibSync, unzlibSync } from 'fflate';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compress a UI spec using zlib compression for storage.
|
|
5
|
+
*
|
|
6
|
+
* The compressed output is base64-encoded and prefixed with "zlib:" for format detection.
|
|
7
|
+
* This achieves 77-90% size reduction on typical UI specs.
|
|
8
|
+
* Uses fflate library which works in both Node.js and browser environments.
|
|
9
|
+
*
|
|
10
|
+
* @param spec - The UI spec Node to compress
|
|
11
|
+
* @returns Base64-encoded compressed string prefixed with "zlib:"
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const compressed = compressSpec(editor.getUI());
|
|
15
|
+
* // Returns: "zlib:eJzt3Vtv2..."
|
|
16
|
+
*/
|
|
17
|
+
function compressSpec(spec) {
|
|
18
|
+
const json = JSON.stringify(spec);
|
|
19
|
+
const encoder = new TextEncoder();
|
|
20
|
+
const uint8Array = encoder.encode(json);
|
|
21
|
+
// Level 9 = max compression
|
|
22
|
+
const compressed = zlibSync(uint8Array, { level: 9 });
|
|
23
|
+
// Convert to base64
|
|
24
|
+
const base64 = btoa(String.fromCharCode(...compressed));
|
|
25
|
+
return "zlib:" + base64;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Decompress a UI spec from storage.
|
|
29
|
+
*
|
|
30
|
+
* Automatically detects and handles both formats:
|
|
31
|
+
* - Compressed format: "zlib:..." (base64-encoded zlib)
|
|
32
|
+
* - Legacy format: Raw JSON string
|
|
33
|
+
*
|
|
34
|
+
* This provides backward compatibility with existing uncompressed specs.
|
|
35
|
+
*
|
|
36
|
+
* @param data - Compressed or legacy JSON string from storage
|
|
37
|
+
* @returns Parsed Node object
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Compressed format
|
|
41
|
+
* const spec = decompressSpec("zlib:eJzt3Vtv2...");
|
|
42
|
+
*
|
|
43
|
+
* // Legacy format (backward compatible)
|
|
44
|
+
* const spec = decompressSpec('{"uid":"abc","type":"page",...}');
|
|
45
|
+
*/
|
|
46
|
+
function decompressSpec(data) {
|
|
47
|
+
// Detect compressed format
|
|
48
|
+
if (data.startsWith("zlib:")) {
|
|
49
|
+
const base64 = data.slice(5);
|
|
50
|
+
// Decode base64 to Uint8Array
|
|
51
|
+
const binaryString = atob(base64);
|
|
52
|
+
const uint8Array = new Uint8Array(binaryString.length);
|
|
53
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
54
|
+
uint8Array[i] = binaryString.charCodeAt(i);
|
|
55
|
+
}
|
|
56
|
+
// Decompress
|
|
57
|
+
const decompressed = unzlibSync(uint8Array);
|
|
58
|
+
const decoder = new TextDecoder();
|
|
59
|
+
const json = decoder.decode(decompressed);
|
|
60
|
+
return JSON.parse(json);
|
|
61
|
+
}
|
|
62
|
+
// Legacy uncompressed format
|
|
63
|
+
return JSON.parse(data);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validate compression with round-trip test.
|
|
67
|
+
* Use this during development to ensure data integrity.
|
|
68
|
+
*
|
|
69
|
+
* @param spec - The spec to validate
|
|
70
|
+
* @returns Object with validation results
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const result = validateCompression(editor.getUI());
|
|
74
|
+
* console.log(`Compression: ${result.compressionRatio}%`);
|
|
75
|
+
* console.log(`Integrity: ${result.isIdentical ? 'PASS' : 'FAIL'}`);
|
|
76
|
+
*/
|
|
77
|
+
function validateCompression(spec) {
|
|
78
|
+
const original = JSON.stringify(spec);
|
|
79
|
+
const encoder = new TextEncoder();
|
|
80
|
+
const originalSize = encoder.encode(original).length;
|
|
81
|
+
// Compress
|
|
82
|
+
const compressed = compressSpec(spec);
|
|
83
|
+
const compressedSize = encoder.encode(compressed).length;
|
|
84
|
+
// Decompress
|
|
85
|
+
const restored = decompressSpec(compressed);
|
|
86
|
+
const restoredStr = JSON.stringify(restored);
|
|
87
|
+
// Verify integrity
|
|
88
|
+
const isIdentical = original === restoredStr;
|
|
89
|
+
const compressionRatio = parseFloat(((1 - compressedSize / originalSize) * 100).toFixed(2));
|
|
90
|
+
return {
|
|
91
|
+
originalSize,
|
|
92
|
+
compressedSize,
|
|
93
|
+
compressionRatio,
|
|
94
|
+
isIdentical,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { compressSpec, decompressSpec, validateCompression };
|
|
99
|
+
//# sourceMappingURL=spec-compression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-compression.js","sources":["../../src/utils/spec-compression.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;;;;;;;;;;;;AAaG;AACG,SAAU,YAAY,CAAC,IAAU,EAAA;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;AACjC,IAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;;AAGvC,IAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;;AAGrD,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,CAAC;IAEvD,OAAO,OAAO,GAAG,MAAM;AACzB;AAEA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,cAAc,CAAC,IAAY,EAAA;;AAEzC,IAAA,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;AAG5B,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QACjC,MAAM,UAAU,GAAG,IAAI,UA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,WAAW;KACZ;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-internal",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "This is core package which is a flavour of slate js and consist of all editor functionality",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"homepage": "https://github.com/contentstack/composable-studio-sdk/tree/main/packages/studio-internal#readme",
|
|
@@ -31,23 +31,25 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"csstype": "^3.1.3",
|
|
34
|
+
"fflate": "^0.8.2",
|
|
34
35
|
"immer": "^10.1.1",
|
|
35
36
|
"is-plain-object": "^5.0.0",
|
|
36
|
-
"lodash-es": "^4.
|
|
37
|
+
"lodash-es": "^4.18.1",
|
|
38
|
+
"nanoid": "^3.3.11",
|
|
37
39
|
"uuid": "^10.0.0"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"@contentstack/common-config": "^1.1.
|
|
42
|
+
"@contentstack/common-config": "^1.1.7",
|
|
41
43
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
42
44
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
43
|
-
"@rollup/plugin-terser": "^0.
|
|
45
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
44
46
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
45
47
|
"@types/lodash-es": "^4.17.12",
|
|
46
48
|
"@types/uuid": "^10.0.0",
|
|
47
|
-
"happy-dom": "^20.
|
|
49
|
+
"happy-dom": "^20.8.9",
|
|
48
50
|
"rollup-plugin-dts": "^6.2.1",
|
|
49
51
|
"rollup-plugin-node-externals": "^8.0.1",
|
|
50
52
|
"rollup-plugin-preserve-directives": "^0.4.0"
|
|
51
53
|
},
|
|
52
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d4e0a1d80b39a2bfa9ac12baa5d4d4a852f4b326"
|
|
53
55
|
}
|