publ-echo-test 0.0.109 → 0.0.110

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.
@@ -49,5 +49,10 @@ export declare const findGroupBlocks: (block: RootBlock, targetId: string) => Gr
49
49
  export declare const findAllComponentBlockIds: (block: RootBlock) => number[];
50
50
  export declare const findParentGroupByGroupId: (block: RootBlock, targetId: string) => string | null;
51
51
  export declare const addBlockToRoot: (block: RootBlock, newBlock: Block) => RootBlock;
52
+ export declare const getBlockWorkDirPath: (blockStructure: RootBlock, blockId: string) => string | null;
53
+ export declare const mapComponentBlockIdsToBlockIds: (blockStructure: RootBlock) => {
54
+ CB_ID: Record<number, string>;
55
+ BLOCK_ID: Record<string, number>;
56
+ };
52
57
  export declare const getBlockIdByComponentId: (block: RootBlock, componentId: number) => string | null;
53
58
  export declare const addBulkToTarget: (block: RootBlock, targetId: string, bulkIds: string[]) => RootBlock;
@@ -181,10 +181,48 @@ export var findParentGroupByGroupId = function (block, targetId) {
181
181
  export var addBlockToRoot = function (block, newBlock) {
182
182
  return __assign(__assign({}, block), { children: __spreadArray(__spreadArray([], block.children, true), [newBlock], false) });
183
183
  };
184
+ export var getBlockWorkDirPath = function (blockStructure, blockId) {
185
+ var findPath = function (blocks, id, path) {
186
+ for (var _i = 0, blocks_4 = blocks; _i < blocks_4.length; _i++) {
187
+ var block = blocks_4[_i];
188
+ var currentPath = __spreadArray(__spreadArray([], path, true), [block.blockId], false);
189
+ if (block.blockId === id) {
190
+ return currentPath;
191
+ }
192
+ if ('children' in block && block.children) {
193
+ var result = findPath(block.children, id, currentPath);
194
+ if (result) {
195
+ return result;
196
+ }
197
+ }
198
+ }
199
+ return null;
200
+ };
201
+ var path = findPath(blockStructure.children, blockId, ['']);
202
+ return path ? path.join('/') : null;
203
+ };
204
+ export var mapComponentBlockIdsToBlockIds = function (blockStructure) {
205
+ var cbToBlockMap = {};
206
+ var blockToCbMap = {};
207
+ var traverse = function (blocks) {
208
+ for (var _i = 0, blocks_5 = blocks; _i < blocks_5.length; _i++) {
209
+ var block = blocks_5[_i];
210
+ if (block.type === 'COMPONENT_BLOCK') {
211
+ cbToBlockMap[block.componentBlockId] = block.blockId;
212
+ blockToCbMap[block.blockId] = block.componentBlockId;
213
+ }
214
+ if ('children' in block && block.children) {
215
+ traverse(block.children);
216
+ }
217
+ }
218
+ };
219
+ traverse(blockStructure.children);
220
+ return { CB_ID: cbToBlockMap, BLOCK_ID: blockToCbMap };
221
+ };
184
222
  export var getBlockIdByComponentId = function (block, componentId) {
185
223
  var findBlock = function (blocks) {
186
- for (var _i = 0, blocks_4 = blocks; _i < blocks_4.length; _i++) {
187
- var block_4 = blocks_4[_i];
224
+ for (var _i = 0, blocks_6 = blocks; _i < blocks_6.length; _i++) {
225
+ var block_4 = blocks_6[_i];
188
226
  if (block_4.type === 'COMPONENT_BLOCK' && block_4.componentBlockId === componentId) {
189
227
  return block_4.blockId;
190
228
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.109",
3
+ "version": "0.0.110",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",