@lowdefy/build 4.0.0-rc.10 → 4.0.0-rc.12

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.
@@ -14,15 +14,45 @@
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
16
  import makeId from '../utils/makeId.js';
17
- function recAddKeys(object, key, keyMap, parentId) {
18
- const id = makeId();
19
- keyMap[id] = {
17
+ function recArray({ array, nextKey, key, keyMap, keyMapId }) {
18
+ array.forEach((item, index)=>{
19
+ if (type.isObject(item)) {
20
+ let path = `${key}.${nextKey}[${index}]`;
21
+ // TODO: Convert all artifacts to not modify id.
22
+ const id = item.blockId ?? item.menuId ?? item.menuItemId ?? item.requestId ?? item.connectionId ?? item.connectionId ?? item.id;
23
+ if (id) {
24
+ path = `${path.slice(0, -1)}:${id}]`;
25
+ }
26
+ if (item.type) {
27
+ path = `${path.slice(0, -1)}:${item.type}]`;
28
+ }
29
+ recAddKeys({
30
+ object: item,
31
+ key: path,
32
+ keyMap: keyMap,
33
+ parentKeyMapId: keyMapId
34
+ });
35
+ }
36
+ if (type.isArray(item)) {
37
+ recArray({
38
+ array: item,
39
+ nextKey,
40
+ key,
41
+ keyMap,
42
+ keyMapId
43
+ });
44
+ }
45
+ });
46
+ }
47
+ function recAddKeys({ object, key, keyMap, parentKeyMapId }) {
48
+ const keyMapId = makeId();
49
+ keyMap[keyMapId] = {
20
50
  key,
21
51
  '~r': object['~r'],
22
- '~k_parent': parentId
52
+ '~k_parent': parentKeyMapId
23
53
  };
24
54
  Object.defineProperty(object, '~k', {
25
- value: id,
55
+ value: keyMapId,
26
56
  enumerable: false,
27
57
  writable: true,
28
58
  configurable: true
@@ -30,19 +60,31 @@ function recAddKeys(object, key, keyMap, parentId) {
30
60
  delete object['~r'];
31
61
  Object.keys(object).forEach((nextKey)=>{
32
62
  if (type.isObject(object[nextKey])) {
33
- recAddKeys(object[nextKey], `${key}.${nextKey}`, keyMap, id);
63
+ recAddKeys({
64
+ object: object[nextKey],
65
+ key: `${key}.${nextKey}`,
66
+ keyMap: keyMap,
67
+ parentKeyMapId: keyMapId
68
+ });
34
69
  }
35
70
  if (type.isArray(object[nextKey])) {
36
- object[nextKey].forEach((item, index)=>{
37
- if (type.isObject(item)) {
38
- recAddKeys(item, `${key}.${nextKey}[${index}:${item.blockId ?? item.menuId ?? item.menuItemId ?? item.requestId ?? item.connectionId ?? item.connectionId ?? item.id}:${item.type}]`, keyMap, id);
39
- }
71
+ recArray({
72
+ array: object[nextKey],
73
+ nextKey,
74
+ key,
75
+ keyMap,
76
+ keyMapId
40
77
  });
41
78
  }
42
79
  });
43
80
  }
44
81
  function addKeys({ components, context }) {
45
- const id = makeId();
46
- recAddKeys(components, 'root', context.keyMap, id);
82
+ const keyMapId = makeId(true);
83
+ recAddKeys({
84
+ object: components,
85
+ key: 'root',
86
+ keyMap: context.keyMap,
87
+ parentKeyMapId: keyMapId
88
+ });
47
89
  }
48
90
  export default addKeys;
@@ -29,6 +29,7 @@
29
29
  'react-icons/im': /"(Im[A-Z0-9]\w*)"/gm,
30
30
  'react-icons/io': /"(IoIos[A-Z0-9]\w*)"/gm,
31
31
  'react-icons/io5': /"(Io[A-Z0-9]\w*)"/gm,
32
+ 'react-icons/lu': /"(Lu[A-Z0-9]\w*)"/gm,
32
33
  'react-icons/md': /"(Md[A-Z0-9]\w*)"/gm,
33
34
  'react-icons/ri': /"(Ri[A-Z0-9]\w*)"/gm,
34
35
  'react-icons/rx': /"(Rx[A-Z0-9]\w*)"/gm,
@@ -14,8 +14,6 @@
14
14
  limitations under the License.
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writeApp({ components, context }) {
17
- await context.writeBuildArtifact('app.json', serializer.serializeToString(components.app ?? {}, {
18
- space: 2
19
- }));
17
+ await context.writeBuildArtifact('app.json', serializer.serializeToString(components.app ?? {}));
20
18
  }
21
19
  export default writeApp;
@@ -14,8 +14,6 @@
14
14
  limitations under the License.
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writeAuth({ components, context }) {
17
- await context.writeBuildArtifact('auth.json', serializer.serializeToString(components.auth ?? {}, {
18
- space: 2
19
- }));
17
+ await context.writeBuildArtifact('auth.json', serializer.serializeToString(components.auth ?? {}));
20
18
  }
21
19
  export default writeAuth;
@@ -14,8 +14,6 @@
14
14
  limitations under the License.
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writeConfig({ components, context }) {
17
- await context.writeBuildArtifact('config.json', serializer.serializeToString(components.config ?? {}, {
18
- space: 2
19
- }));
17
+ await context.writeBuildArtifact('config.json', serializer.serializeToString(components.config ?? {}));
20
18
  }
21
19
  export default writeConfig;
@@ -19,9 +19,7 @@ async function writeConnections({ components, context }) {
19
19
  throw new Error(`Connections is not an array.`);
20
20
  }
21
21
  const writePromises = components.connections.map(async (connection)=>{
22
- await context.writeBuildArtifact(`connections/${connection.connectionId}.json`, serializer.serializeToString(connection, {
23
- space: 2
24
- }));
22
+ await context.writeBuildArtifact(`connections/${connection.connectionId}.json`, serializer.serializeToString(connection));
25
23
  });
26
24
  return Promise.all(writePromises);
27
25
  }
@@ -20,8 +20,6 @@ async function writeGlobal({ components, context }) {
20
20
  if (!type.isObject(components.global)) {
21
21
  throw new Error('Global is not an object.');
22
22
  }
23
- await context.writeBuildArtifact('global.json', serializer.serializeToString(components.global, {
24
- space: 2
25
- }));
23
+ await context.writeBuildArtifact('global.json', serializer.serializeToString(components.global));
26
24
  }
27
25
  export default writeGlobal;
@@ -20,11 +20,7 @@ async function writeMaps({ context }) {
20
20
  if (!type.isObject(context.refMap)) {
21
21
  throw new Error('refMap is not an object.');
22
22
  }
23
- await context.writeBuildArtifact('keyMap.json', serializer.serializeToString(context.keyMap, {
24
- space: 0
25
- }));
26
- await context.writeBuildArtifact('refMap.json', serializer.serializeToString(context.refMap, {
27
- space: 0
28
- }));
23
+ await context.writeBuildArtifact('keyMap.json', serializer.serializeToString(context.keyMap));
24
+ await context.writeBuildArtifact('refMap.json', serializer.serializeToString(context.refMap));
29
25
  }
30
26
  export default writeMaps;
@@ -17,8 +17,6 @@ async function writeMenus({ components, context }) {
17
17
  if (!type.isArray(components.menus)) {
18
18
  throw new Error('Menus is not an array.');
19
19
  }
20
- await context.writeBuildArtifact('menus.json', serializer.serializeToString(components.menus, {
21
- space: 2
22
- }));
20
+ await context.writeBuildArtifact('menus.json', serializer.serializeToString(components.menus));
23
21
  }
24
22
  export default writeMenus;
@@ -14,9 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writePage({ page, context }) {
17
- await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, serializer.serializeToString(page ?? {}, {
18
- space: 2
19
- }));
17
+ await context.writeBuildArtifact(`pages/${page.pageId}/${page.pageId}.json`, serializer.serializeToString(page ?? {}));
20
18
  }
21
19
  async function writePages({ components, context }) {
22
20
  const writePromises = components.pages.map((page)=>writePage({
@@ -15,9 +15,7 @@
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writeRequestsOnPage({ page, context }) {
17
17
  return Promise.all(page.requests.map(async (request)=>{
18
- await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, serializer.serializeToString(request ?? {}, {
19
- space: 2
20
- }));
18
+ await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, serializer.serializeToString(request ?? {}));
21
19
  delete request.properties;
22
20
  delete request.type;
23
21
  delete request.connectionId;
@@ -14,8 +14,6 @@
14
14
  limitations under the License.
15
15
  */ import { serializer } from '@lowdefy/helpers';
16
16
  async function writeTypes({ components, context }) {
17
- await context.writeBuildArtifact('types.json', serializer.serializeToString(components.types ?? {}, {
18
- space: 2
19
- }));
17
+ await context.writeBuildArtifact('types.json', serializer.serializeToString(components.types ?? {}));
20
18
  }
21
19
  export default writeTypes;