publ-echo-test 0.0.138 → 0.0.140

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.
@@ -10,34 +10,34 @@ export declare function getBlockSpecificType(block: Block): "ROOT" | "BULK" | "C
10
10
  export type SectionPedigree = RootBlock;
11
11
  export type Block = ComponentBlock | GroupBlock | RootBlock;
12
12
  export type ZOrder = {
13
- [platform in "mobile" | "desktop"]: {
13
+ [platform in 'mobile' | 'desktop']: {
14
14
  [componentBlockId: string]: number;
15
15
  };
16
16
  };
17
17
  export type ComponentBlock = {
18
18
  blockId: string;
19
- type: "COMPONENT_BLOCK";
19
+ type: 'COMPONENT_BLOCK';
20
20
  zOrderDesktopInternal: number | null;
21
21
  zOrderMobileInternal: number | null;
22
22
  componentBlockId: number;
23
23
  };
24
24
  export type GroupBlock = {
25
25
  blockId: string;
26
- type: "GROUP_BLOCK";
26
+ type: 'GROUP_BLOCK';
27
27
  zOrderDesktopInternal: number | null;
28
28
  zOrderMobileInternal: number | null;
29
29
  children: (ComponentBlock | GroupBlock)[];
30
30
  };
31
31
  export type RootBlock = {
32
- blockId: "ROOT";
33
- type: "GROUP_BLOCK";
32
+ blockId: 'ROOT';
33
+ type: 'GROUP_BLOCK';
34
34
  zOrderDesktopInternal: number | null;
35
35
  zOrderMobileInternal: number | null;
36
36
  children: (ComponentBlock | GroupBlock)[];
37
37
  };
38
38
  export type BulkBlockInternal = {
39
- blockId: "BULK";
40
- type: "GROUP_BLOCK";
39
+ blockId: 'BULK';
40
+ type: 'GROUP_BLOCK';
41
41
  zOrderDesktopInternal: number;
42
42
  zOrderMobileInternal: number;
43
43
  children: (ComponentBlock | GroupBlock)[];
@@ -49,6 +49,6 @@ export declare const findAllChildrenBlockIds: (block: Block, targetId: string) =
49
49
  export declare const findDirectChildrenBlockIds: (block: Block, targetId: string) => string[];
50
50
  export declare const findGroupBlocks: (block: Block, targetId: string) => GroupBlock[];
51
51
  export declare const addBulkToTarget: (block: Block, targetId: string, bulkBlockIds: string[]) => Block;
52
- export declare const getBlockWorkDirPath: (block: Block, blockId: string) => string | null;
52
+ export declare function getBlockWorkDirPath(blockStructure: Block, targetBlockId: string): string;
53
53
  export declare function formatBlockIdToCbId(blockId: string): number | null;
54
54
  export declare function formatCbIdToBlockId(cbId: number): string;
@@ -8,12 +8,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
10
  export var zIndexMap = {
11
- 'BULK': 20000,
12
- 'EDITING_GROUP_CHILD': 10000,
13
- 'EDITING_GROUP': 9000,
14
- 'GROUP': 5000,
15
- 'CB': 500,
16
- 'ROOT': 500, //?
11
+ BULK: 20000,
12
+ EDITING_GROUP_CHILD: 10000,
13
+ EDITING_GROUP: 9000,
14
+ GROUP: 5000,
15
+ CB: 500,
16
+ ROOT: 500, //?
17
17
  };
18
18
  export function getBlockSpecificType(block) {
19
19
  if (block.blockId === 'ROOT') {
@@ -119,7 +119,7 @@ export var findGroupBlocks = function (block, targetId) {
119
119
  if (targetBlock.blockId === 'ROOT') {
120
120
  return groupBlocks;
121
121
  }
122
- if (groupInBulk.length > 0) {
122
+ if (groupInBulk && groupInBulk.length > 0) {
123
123
  return [targetBlock].concat(groupBlocks).concat(groupInBulk);
124
124
  }
125
125
  return [targetBlock].concat(groupBlocks);
@@ -174,11 +174,14 @@ export var findGroupBlocks = function (block, targetId) {
174
174
  export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
175
175
  var blockCopy = deepClone(block);
176
176
  var targetBlock = findBlockByBlockId(blockCopy, targetId);
177
- if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
177
+ if (!targetBlock ||
178
+ targetBlock.type !== 'GROUP_BLOCK' ||
179
+ !targetBlock.children) {
178
180
  return block;
179
181
  }
180
182
  var bulkBlocks = targetBlock.children.filter(function (child) {
181
- if (child.type === 'COMPONENT_BLOCK' && bulkBlockIds.includes(child.blockId.toString())) {
183
+ if (child.type === 'COMPONENT_BLOCK' &&
184
+ bulkBlockIds.includes(child.blockId.toString())) {
182
185
  return true;
183
186
  }
184
187
  if (child.type === 'GROUP_BLOCK' && bulkBlockIds.includes(child.blockId)) {
@@ -194,8 +197,12 @@ export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
194
197
  }
195
198
  // Remove bulk blocks from target's children
196
199
  targetBlock.children = targetBlock.children.filter(function (child) { return !bulkBlockIds.includes(child.blockId); });
197
- var zOrdersDesktop = bulkBlocks.map(function (block) { return block.zOrderDesktopInternal; }).filter(function (each) { return each !== null; });
198
- var zOrdersMobile = bulkBlocks.map(function (block) { return block.zOrderMobileInternal; }).filter(function (each) { return each !== null; });
200
+ var zOrdersDesktop = bulkBlocks
201
+ .map(function (block) { return block.zOrderDesktopInternal; })
202
+ .filter(function (each) { return each !== null; });
203
+ var zOrdersMobile = bulkBlocks
204
+ .map(function (block) { return block.zOrderMobileInternal; })
205
+ .filter(function (each) { return each !== null; });
199
206
  var zOrderDesktopInternal = Math.max.apply(Math, zOrdersDesktop);
200
207
  var zOrderMobileInternal = Math.max.apply(Math, zOrdersMobile);
201
208
  // Create the new bulkBlock
@@ -210,29 +217,25 @@ export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
210
217
  targetBlock.children.push(bulkBlock);
211
218
  return blockCopy;
212
219
  };
213
- var findWorkDirPath = function (block, id, path) {
214
- if (block.type === 'COMPONENT_BLOCK') {
215
- return null;
220
+ function findPathHelper(current, targetBlockId) {
221
+ if (current.blockId === targetBlockId) {
222
+ return [current.blockId];
216
223
  }
217
- for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
218
- var child = _a[_i];
219
- var currentPath = child.type === 'COMPONENT_BLOCK' ? path : __spreadArray(__spreadArray([], path, true), [child.blockId], false);
220
- if (child.blockId === id) {
221
- return currentPath;
222
- }
223
- if ('children' in child && child.children) {
224
- var result = findWorkDirPath(child, id, currentPath);
225
- if (result) {
226
- return result;
224
+ if ('children' in current && Array.isArray(current.children)) {
225
+ for (var _i = 0, _a = current.children; _i < _a.length; _i++) {
226
+ var child = _a[_i];
227
+ var result = findPathHelper(child, targetBlockId);
228
+ if (result !== null) {
229
+ return __spreadArray([current.blockId], result, true);
227
230
  }
228
231
  }
229
232
  }
230
233
  return null;
231
- };
232
- export var getBlockWorkDirPath = function (block, blockId) {
233
- var path = findWorkDirPath(block, blockId, ['/ROOT']);
234
- return path ? path.join('/') : null;
235
- };
234
+ }
235
+ export function getBlockWorkDirPath(blockStructure, targetBlockId) {
236
+ var path = findPathHelper(blockStructure, targetBlockId);
237
+ return path ? '/' + path.join('/') : '';
238
+ }
236
239
  export function formatBlockIdToCbId(blockId) {
237
240
  var match = blockId.match(/^CB_(\d+)$/);
238
241
  return match ? parseInt(match[1], 10) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.138",
3
+ "version": "0.0.140",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",