@lv-x-software-house/x_view 1.2.8-dev.12 → 1.2.8-dev.14

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.
Files changed (3) hide show
  1. package/dist/index.js +82 -115
  2. package/dist/index.mjs +82 -115
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1282,8 +1282,8 @@ var userActionHandlers = {
1282
1282
  specificParentData.nodes.push(newNode);
1283
1283
  specificParentData.links.push(newLink);
1284
1284
  try {
1285
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1286
- if (isView && parentFileId === context.sceneConfigId) {
1285
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1286
+ if (isView2 && parentFileId === context.sceneConfigId) {
1287
1287
  const viewFilePayload = {
1288
1288
  parent_dbs: sceneDataRef.current.parent_dbs,
1289
1289
  nodes: sceneDataRef.current.nodes,
@@ -1312,7 +1312,7 @@ var userActionHandlers = {
1312
1312
  );
1313
1313
  }
1314
1314
  graphDataRef.current[parentFileId] = specificParentData;
1315
- if (isView && parentFileId === context.sceneConfigId) {
1315
+ if (isView2 && parentFileId === context.sceneConfigId) {
1316
1316
  sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
1317
1317
  }
1318
1318
  const finalPosition = stateRef.current.ghostElements.node.position.clone();
@@ -1530,10 +1530,16 @@ var userActionHandlers = {
1530
1530
  context.sceneConfigId,
1531
1531
  context.ownerId
1532
1532
  );
1533
- if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1533
+ const targetParentInfo = getParentFileInfoForNode(
1534
+ graphDataRef.current,
1535
+ sceneDataRef.current,
1536
+ targetNodeData.id,
1537
+ context.sceneConfigId,
1538
+ context.ownerId
1539
+ );
1540
+ if (!sourceParentInfo || !sourceParentInfo.ownerId || !targetParentInfo) {
1534
1541
  console.error(
1535
- "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o Node de origem:",
1536
- sourceNodeData.id
1542
+ "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para os Nodes da conex\xE3o."
1537
1543
  );
1538
1544
  alert(
1539
1545
  "Ocorreu um erro ao identificar o arquivo pai ou seu propriet\xE1rio."
@@ -1541,17 +1547,21 @@ var userActionHandlers = {
1541
1547
  userActionHandlers.handleCancelConnection(context);
1542
1548
  return;
1543
1549
  }
1544
- const { parentFileId: sourceParentFileId, ownerId: sourceOwnerId } = sourceParentInfo;
1545
- const parentFileIdToSave = sourceParentFileId;
1546
- const ownerIdToSave = sourceOwnerId;
1550
+ let parentInfoToSave = sourceParentInfo;
1551
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1552
+ const isTargetQuest = targetParentInfo.parentFileId === context.sceneConfigId;
1553
+ if (isSourceQuest || isTargetQuest) {
1554
+ parentInfoToSave = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1555
+ }
1556
+ const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
1547
1557
  const newLink = {
1548
1558
  id: `link_${import_short_uuid.default.generate()}`,
1549
1559
  source: sourceNodeData.id,
1550
1560
  target: targetNodeData.id
1551
1561
  };
1552
1562
  try {
1553
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1554
- if (isView && parentFileIdToSave === context.sceneConfigId) {
1563
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1564
+ if (isView2 && parentFileIdToSave === context.sceneConfigId) {
1555
1565
  const specificParentData = graphDataRef.current[context.sceneConfigId];
1556
1566
  specificParentData.links.push(newLink);
1557
1567
  const viewFilePayload = {
@@ -1713,8 +1723,8 @@ var userActionHandlers = {
1713
1723
  };
1714
1724
  const saveParentData = async (fileId, fileOwnerId, data) => {
1715
1725
  var _a;
1716
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1717
- if (isView && fileId === context.sceneConfigId) {
1726
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1727
+ if (isView2 && fileId === context.sceneConfigId) {
1718
1728
  const viewFilePayload = {
1719
1729
  parent_dbs: sceneDataRef.current.parent_dbs,
1720
1730
  nodes: sceneDataRef.current.nodes,
@@ -1834,14 +1844,21 @@ var userActionHandlers = {
1834
1844
  );
1835
1845
  return;
1836
1846
  }
1837
- const parentInfo = getParentFileInfoForNode(
1847
+ const sourceParentInfo = getParentFileInfoForNode(
1838
1848
  graphDataRef.current,
1839
1849
  sceneDataRef.current,
1840
1850
  linkObject.userData.source,
1841
1851
  context.sceneConfigId,
1842
1852
  context.ownerId
1843
1853
  );
1844
- if (!parentInfo || !parentInfo.ownerId) {
1854
+ const targetParentInfo = getParentFileInfoForNode(
1855
+ graphDataRef.current,
1856
+ sceneDataRef.current,
1857
+ linkObject.userData.target,
1858
+ context.sceneConfigId,
1859
+ context.ownerId
1860
+ );
1861
+ if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1845
1862
  console.error(
1846
1863
  "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o link:",
1847
1864
  linkIdToDelete
@@ -1851,6 +1868,12 @@ var userActionHandlers = {
1851
1868
  );
1852
1869
  return;
1853
1870
  }
1871
+ let parentInfo = sourceParentInfo;
1872
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1873
+ const isTargetQuest = (targetParentInfo == null ? void 0 : targetParentInfo.parentFileId) === context.sceneConfigId;
1874
+ if (isSourceQuest || isTargetQuest) {
1875
+ parentInfo = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1876
+ }
1854
1877
  const { parentFileId, ownerId } = parentInfo;
1855
1878
  const srcName = ((_c = (_b = (_a = linkObject.userData) == null ? void 0 : _a.sourceNode) == null ? void 0 : _b.userData) == null ? void 0 : _c.name) ?? linkObject.userData.source;
1856
1879
  const tgtName = ((_f = (_e = (_d = linkObject.userData) == null ? void 0 : _d.targetNode) == null ? void 0 : _e.userData) == null ? void 0 : _f.name) ?? linkObject.userData.target;
@@ -1863,8 +1886,8 @@ var userActionHandlers = {
1863
1886
  specificParentData.links = newLinks;
1864
1887
  let filenameToSave;
1865
1888
  let payloadToSave;
1866
- const isView = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
1867
- if (isView && parentFileId === context.sceneConfigId) {
1889
+ const isView2 = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
1890
+ if (isView2 && parentFileId === context.sceneConfigId) {
1868
1891
  filenameToSave = context.sceneSaveUrl;
1869
1892
  sceneDataRef.current.links = sceneDataRef.current.links.filter(
1870
1893
  (l) => String(l.id) !== String(linkIdToDelete)
@@ -1880,7 +1903,7 @@ var userActionHandlers = {
1880
1903
  }
1881
1904
  try {
1882
1905
  await context.actions.save_view_data(filenameToSave, payloadToSave);
1883
- if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1906
+ if (isView2 && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1884
1907
  await context.actions.delete_quest_link_firestore(
1885
1908
  context.ownerId,
1886
1909
  context.sceneConfigId,
@@ -2100,8 +2123,8 @@ var userActionHandlers = {
2100
2123
  );
2101
2124
  let filenameToSave;
2102
2125
  let payloadToSave;
2103
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2104
- if (isView && parentFileId === context.sceneConfigId) {
2126
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2127
+ if (isView2 && parentFileId === context.sceneConfigId) {
2105
2128
  filenameToSave = context.sceneSaveUrl;
2106
2129
  const strNodesToDelete = Array.from(nodesToDelete).map(String);
2107
2130
  const strLinksToDelete = Array.from(linksToDelete).map(String);
@@ -2215,8 +2238,8 @@ var userActionHandlers = {
2215
2238
  specificParentData.links = newLinks;
2216
2239
  let filenameToSave;
2217
2240
  let payloadToSave;
2218
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2219
- if (isView && parentFileId === context.sceneConfigId) {
2241
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2242
+ if (isView2 && parentFileId === context.sceneConfigId) {
2220
2243
  filenameToSave = context.sceneSaveUrl;
2221
2244
  const newVisualNodes = sceneDataRef.current.nodes.filter(
2222
2245
  (n) => String(n.id) !== strNodeId
@@ -2279,7 +2302,7 @@ var userActionHandlers = {
2279
2302
  }
2280
2303
  },
2281
2304
  handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
2282
- var _a, _b, _c;
2305
+ var _a, _b, _c, _d;
2283
2306
  const { graphDataRef, sceneDataRef, stateRef, setters } = context;
2284
2307
  if (!graphDataRef.current || !sceneDataRef.current) return;
2285
2308
  const {
@@ -2379,16 +2402,38 @@ var userActionHandlers = {
2379
2402
  })),
2380
2403
  recurrence_config: nextRecurrenceConfig
2381
2404
  };
2405
+ const rootId = ((_c = nodeToSave.version_node) == null ? void 0 : _c.parent_node) || nodeToSave.id;
2406
+ const nextQuestLink = {
2407
+ id: `link_${import_short_uuid.default.generate()}`,
2408
+ source: rootId,
2409
+ target: nextQuestNode.id
2410
+ };
2382
2411
  await context.actions.upsert_quest_firestore(
2383
2412
  context.ownerId,
2384
2413
  context.sceneConfigId,
2385
2414
  nextQuestNode
2386
2415
  );
2416
+ await context.actions.upsert_quest_link_firestore(
2417
+ context.ownerId,
2418
+ context.sceneConfigId,
2419
+ nextQuestLink
2420
+ );
2387
2421
  await context.actions.update_view_counter(
2388
2422
  context.ownerId,
2389
2423
  context.sceneConfigId,
2390
2424
  nextCounter
2391
2425
  );
2426
+ if (specificParentData.links) {
2427
+ specificParentData.links.push(nextQuestLink);
2428
+ }
2429
+ if (specificParentData.nodes) {
2430
+ specificParentData.nodes.push(nextQuestNode);
2431
+ }
2432
+ if (isView && parentFileId === context.sceneConfigId) {
2433
+ if (!sceneDataRef.current.links) sceneDataRef.current.links = [];
2434
+ sceneDataRef.current.links.push(nextQuestLink);
2435
+ sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2436
+ }
2392
2437
  if (stateRef.current.nodeObjects[String(nodeToSave.id)]) {
2393
2438
  const oldMeshPosition = stateRef.current.nodeObjects[String(nodeToSave.id)].position.clone();
2394
2439
  setTimeout(() => {
@@ -2407,8 +2452,8 @@ var userActionHandlers = {
2407
2452
  }
2408
2453
  }
2409
2454
  try {
2410
- const isView = ((_c = context.viewType) == null ? void 0 : _c.toLowerCase()) === "view";
2411
- if (isView && parentFileId === context.sceneConfigId) {
2455
+ const isView2 = ((_d = context.viewType) == null ? void 0 : _d.toLowerCase()) === "view";
2456
+ if (isView2 && parentFileId === context.sceneConfigId) {
2412
2457
  const visualNodeIndex = sceneDataRef.current.nodes.findIndex(
2413
2458
  (n) => String(n.id) === String(nodeToSave.id)
2414
2459
  );
@@ -2447,7 +2492,7 @@ var userActionHandlers = {
2447
2492
  );
2448
2493
  }
2449
2494
  graphDataRef.current[parentFileId] = specificParentData;
2450
- if (isView && parentFileId === context.sceneConfigId) {
2495
+ if (isView2 && parentFileId === context.sceneConfigId) {
2451
2496
  sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2452
2497
  }
2453
2498
  updateExistingNodeVisuals(stateRef.current, nodeToSave);
@@ -2500,8 +2545,8 @@ var userActionHandlers = {
2500
2545
  return;
2501
2546
  }
2502
2547
  try {
2503
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2504
- if (isView && parentFileId === context.sceneConfigId) {
2548
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2549
+ if (isView2 && parentFileId === context.sceneConfigId) {
2505
2550
  const viewFilePayload = {
2506
2551
  parent_dbs: sceneDataRef.current.parent_dbs,
2507
2552
  nodes: sceneDataRef.current.nodes,
@@ -18436,84 +18481,6 @@ function XViewScene({
18436
18481
  alert("Ocorreu um erro ao criar a Quest.");
18437
18482
  }
18438
18483
  };
18439
- userActionHandlers.handleCompleteConnection = async (context, targetNodeData) => {
18440
- const {
18441
- stateRef: stateRef2,
18442
- graphDataRef: graphDataRef2,
18443
- sceneDataRef: sceneDataRef2,
18444
- sceneConfigId: sceneConfigId2,
18445
- sceneSaveUrl: sceneSaveUrl2,
18446
- ownerId: ownerId2
18447
- } = context;
18448
- const { sourceNodeData } = stateRef2.current.connection;
18449
- if (!graphDataRef2.current || !sceneDataRef2.current || !sourceNodeData || !targetNodeData) {
18450
- userActionHandlers.handleCancelConnection(context);
18451
- return;
18452
- }
18453
- const sourceParentInfo = getParentFileInfoForNode(
18454
- graphDataRef2.current,
18455
- sceneDataRef2.current,
18456
- sourceNodeData.id,
18457
- sceneConfigId2,
18458
- ownerId2
18459
- );
18460
- const targetParentInfo = getParentFileInfoForNode(
18461
- graphDataRef2.current,
18462
- sceneDataRef2.current,
18463
- targetNodeData.id,
18464
- sceneConfigId2,
18465
- ownerId2
18466
- );
18467
- let parentInfoToSave = sourceParentInfo;
18468
- const isSourceQuest = sourceParentInfo.parentFileId === sceneConfigId2;
18469
- const isTargetQuest = targetParentInfo.parentFileId === sceneConfigId2;
18470
- if (isSourceQuest || isTargetQuest) {
18471
- parentInfoToSave = { parentFileId: sceneConfigId2, ownerId: ownerId2 };
18472
- }
18473
- const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
18474
- const newLink = {
18475
- id: `link_${import_short_uuid2.default.generate()}`,
18476
- source: sourceNodeData.id,
18477
- target: targetNodeData.id
18478
- };
18479
- try {
18480
- if (parentFileIdToSave === sceneConfigId2) {
18481
- const specificParentData = graphDataRef2.current[sceneConfigId2];
18482
- specificParentData.links.push(newLink);
18483
- const viewFilePayload = {
18484
- ...sceneDataRef2.current,
18485
- quest_counter: sceneDataRef2.current.quest_counter || 1
18486
- };
18487
- const questFilePayload = {
18488
- nodes: specificParentData.nodes,
18489
- links: specificParentData.links,
18490
- milestones: sceneDataRef2.current.milestones || []
18491
- };
18492
- await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18493
- const questSaveUrl = sceneSaveUrl2.replace(
18494
- "x_view_scenes",
18495
- "x_view_quests"
18496
- );
18497
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
18498
- } else {
18499
- const specificParentData = JSON.parse(
18500
- JSON.stringify(graphDataRef2.current[parentFileIdToSave])
18501
- );
18502
- specificParentData.links.push(newLink);
18503
- const filenameForSpecificParent = `x_view_dbs/${ownerIdToSave}/${parentFileIdToSave}`;
18504
- await context.actions.save_view_data(
18505
- filenameForSpecificParent,
18506
- specificParentData
18507
- );
18508
- graphDataRef2.current[parentFileIdToSave] = specificParentData;
18509
- }
18510
- addNewLinkToScene(stateRef2.current, newLink);
18511
- } catch (error) {
18512
- console.error("Falha ao salvar a nova conex\xE3o:", error);
18513
- alert("Ocorreu um erro ao salvar a nova conex\xE3o.");
18514
- }
18515
- userActionHandlers.handleCancelConnection(context);
18516
- };
18517
18484
  const handleClearAncestryVisuals = (0, import_react33.useCallback)((ancestryId) => {
18518
18485
  const { renderedAncestries, ancestryGroup } = stateRef.current;
18519
18486
  const renderIndex = renderedAncestries.findIndex(
@@ -20214,8 +20181,8 @@ function XViewScene({
20214
20181
  if (!sceneDataRef.current) return;
20215
20182
  sceneDataRef.current.milestones = newMilestones;
20216
20183
  setSceneVersion((v) => v + 1);
20217
- const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20218
- if (!isView || !save_view_data || !sceneSaveUrl) return;
20184
+ const isView2 = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20185
+ if (!isView2 || !save_view_data || !sceneSaveUrl) return;
20219
20186
  const questFileData = {
20220
20187
  nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20221
20188
  links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
@@ -20262,7 +20229,7 @@ function XViewScene({
20262
20229
  });
20263
20230
  sceneDataRef.current.nodes = currentNodes;
20264
20231
  sceneDataRef.current.links = currentLinks;
20265
- const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20232
+ const isView2 = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20266
20233
  const sceneFileData = {
20267
20234
  ...sceneDataRef.current,
20268
20235
  nodes: currentNodes,
@@ -20384,8 +20351,8 @@ function XViewScene({
20384
20351
  if (event.key.toLowerCase() === "q") {
20385
20352
  const isUiClear = !stateRef.current.creation.isActive && !stateRef.current.connection.isActive && !stateRef.current.relink.isActive && !stateRef.current.ancestry.isActive && !((_b2 = context.versionMode) == null ? void 0 : _b2.isActive) && !contextMenu.visible && !multiContextMenu.visible && !relationshipMenu.visible && !readingMode.isActive && !isImportModalOpen && !isBoardsOpen && !isSidebarOpen && !isMilestoneManagerOpen && !detailsNode && !detailsLink && !ancestryLinkDetails && !imageViewer.visible && !editingAncestryRel.visible && !questMode.isActive;
20386
20353
  if (isUiClear) {
20387
- const isView = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
20388
- if (!isView) return;
20354
+ const isView2 = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
20355
+ if (!isView2) return;
20389
20356
  const {
20390
20357
  graphGroup,
20391
20358
  glowTexture,
@@ -21170,11 +21137,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21170
21137
  parentDbObjects.push({ db_id: scene_config, owner_id });
21171
21138
  }
21172
21139
  }
21173
- const isView = type && type.toLowerCase() === "view";
21140
+ const isView2 = type && type.toLowerCase() === "view";
21174
21141
  const parentResponsesPromises = parentDbObjects.map(
21175
21142
  (db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
21176
21143
  );
21177
- if (isView) {
21144
+ if (isView2) {
21178
21145
  const questFetchWithMigrationPromise = (async () => {
21179
21146
  try {
21180
21147
  const questsResponse = await db_services.get_view_quests_firestore(
@@ -21216,7 +21183,7 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21216
21183
  let questDataObj = null;
21217
21184
  for (let i = 0; i < parentResponsesResults.length; i++) {
21218
21185
  const result = parentResponsesResults[i];
21219
- if (isView && i === parentResponsesResults.length - 1) {
21186
+ if (isView2 && i === parentResponsesResults.length - 1) {
21220
21187
  if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
21221
21188
  questDataObj = result.value.data;
21222
21189
  if (result.value.quest_counter !== void 0) {
@@ -21238,7 +21205,7 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21238
21205
  const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
21239
21206
  const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
21240
21207
  const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
21241
- if (isView) {
21208
+ if (isView2) {
21242
21209
  parentData[scene_config] = {
21243
21210
  dataset_name: "Quests Internas (View)",
21244
21211
  nodes: currentQuestNodes,
package/dist/index.mjs CHANGED
@@ -1243,8 +1243,8 @@ var userActionHandlers = {
1243
1243
  specificParentData.nodes.push(newNode);
1244
1244
  specificParentData.links.push(newLink);
1245
1245
  try {
1246
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1247
- if (isView && parentFileId === context.sceneConfigId) {
1246
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1247
+ if (isView2 && parentFileId === context.sceneConfigId) {
1248
1248
  const viewFilePayload = {
1249
1249
  parent_dbs: sceneDataRef.current.parent_dbs,
1250
1250
  nodes: sceneDataRef.current.nodes,
@@ -1273,7 +1273,7 @@ var userActionHandlers = {
1273
1273
  );
1274
1274
  }
1275
1275
  graphDataRef.current[parentFileId] = specificParentData;
1276
- if (isView && parentFileId === context.sceneConfigId) {
1276
+ if (isView2 && parentFileId === context.sceneConfigId) {
1277
1277
  sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
1278
1278
  }
1279
1279
  const finalPosition = stateRef.current.ghostElements.node.position.clone();
@@ -1491,10 +1491,16 @@ var userActionHandlers = {
1491
1491
  context.sceneConfigId,
1492
1492
  context.ownerId
1493
1493
  );
1494
- if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1494
+ const targetParentInfo = getParentFileInfoForNode(
1495
+ graphDataRef.current,
1496
+ sceneDataRef.current,
1497
+ targetNodeData.id,
1498
+ context.sceneConfigId,
1499
+ context.ownerId
1500
+ );
1501
+ if (!sourceParentInfo || !sourceParentInfo.ownerId || !targetParentInfo) {
1495
1502
  console.error(
1496
- "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o Node de origem:",
1497
- sourceNodeData.id
1503
+ "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para os Nodes da conex\xE3o."
1498
1504
  );
1499
1505
  alert(
1500
1506
  "Ocorreu um erro ao identificar o arquivo pai ou seu propriet\xE1rio."
@@ -1502,17 +1508,21 @@ var userActionHandlers = {
1502
1508
  userActionHandlers.handleCancelConnection(context);
1503
1509
  return;
1504
1510
  }
1505
- const { parentFileId: sourceParentFileId, ownerId: sourceOwnerId } = sourceParentInfo;
1506
- const parentFileIdToSave = sourceParentFileId;
1507
- const ownerIdToSave = sourceOwnerId;
1511
+ let parentInfoToSave = sourceParentInfo;
1512
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1513
+ const isTargetQuest = targetParentInfo.parentFileId === context.sceneConfigId;
1514
+ if (isSourceQuest || isTargetQuest) {
1515
+ parentInfoToSave = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1516
+ }
1517
+ const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
1508
1518
  const newLink = {
1509
1519
  id: `link_${short.generate()}`,
1510
1520
  source: sourceNodeData.id,
1511
1521
  target: targetNodeData.id
1512
1522
  };
1513
1523
  try {
1514
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1515
- if (isView && parentFileIdToSave === context.sceneConfigId) {
1524
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1525
+ if (isView2 && parentFileIdToSave === context.sceneConfigId) {
1516
1526
  const specificParentData = graphDataRef.current[context.sceneConfigId];
1517
1527
  specificParentData.links.push(newLink);
1518
1528
  const viewFilePayload = {
@@ -1674,8 +1684,8 @@ var userActionHandlers = {
1674
1684
  };
1675
1685
  const saveParentData = async (fileId, fileOwnerId, data) => {
1676
1686
  var _a;
1677
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1678
- if (isView && fileId === context.sceneConfigId) {
1687
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
1688
+ if (isView2 && fileId === context.sceneConfigId) {
1679
1689
  const viewFilePayload = {
1680
1690
  parent_dbs: sceneDataRef.current.parent_dbs,
1681
1691
  nodes: sceneDataRef.current.nodes,
@@ -1795,14 +1805,21 @@ var userActionHandlers = {
1795
1805
  );
1796
1806
  return;
1797
1807
  }
1798
- const parentInfo = getParentFileInfoForNode(
1808
+ const sourceParentInfo = getParentFileInfoForNode(
1799
1809
  graphDataRef.current,
1800
1810
  sceneDataRef.current,
1801
1811
  linkObject.userData.source,
1802
1812
  context.sceneConfigId,
1803
1813
  context.ownerId
1804
1814
  );
1805
- if (!parentInfo || !parentInfo.ownerId) {
1815
+ const targetParentInfo = getParentFileInfoForNode(
1816
+ graphDataRef.current,
1817
+ sceneDataRef.current,
1818
+ linkObject.userData.target,
1819
+ context.sceneConfigId,
1820
+ context.ownerId
1821
+ );
1822
+ if (!sourceParentInfo || !sourceParentInfo.ownerId) {
1806
1823
  console.error(
1807
1824
  "N\xE3o foi poss\xEDvel encontrar as informa\xE7\xF5es do arquivo pai (ou ownerId) para o link:",
1808
1825
  linkIdToDelete
@@ -1812,6 +1829,12 @@ var userActionHandlers = {
1812
1829
  );
1813
1830
  return;
1814
1831
  }
1832
+ let parentInfo = sourceParentInfo;
1833
+ const isSourceQuest = sourceParentInfo.parentFileId === context.sceneConfigId;
1834
+ const isTargetQuest = (targetParentInfo == null ? void 0 : targetParentInfo.parentFileId) === context.sceneConfigId;
1835
+ if (isSourceQuest || isTargetQuest) {
1836
+ parentInfo = { parentFileId: context.sceneConfigId, ownerId: context.ownerId };
1837
+ }
1815
1838
  const { parentFileId, ownerId } = parentInfo;
1816
1839
  const srcName = ((_c = (_b = (_a = linkObject.userData) == null ? void 0 : _a.sourceNode) == null ? void 0 : _b.userData) == null ? void 0 : _c.name) ?? linkObject.userData.source;
1817
1840
  const tgtName = ((_f = (_e = (_d = linkObject.userData) == null ? void 0 : _d.targetNode) == null ? void 0 : _e.userData) == null ? void 0 : _f.name) ?? linkObject.userData.target;
@@ -1824,8 +1847,8 @@ var userActionHandlers = {
1824
1847
  specificParentData.links = newLinks;
1825
1848
  let filenameToSave;
1826
1849
  let payloadToSave;
1827
- const isView = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
1828
- if (isView && parentFileId === context.sceneConfigId) {
1850
+ const isView2 = ((_g = context.viewType) == null ? void 0 : _g.toLowerCase()) === "view";
1851
+ if (isView2 && parentFileId === context.sceneConfigId) {
1829
1852
  filenameToSave = context.sceneSaveUrl;
1830
1853
  sceneDataRef.current.links = sceneDataRef.current.links.filter(
1831
1854
  (l) => String(l.id) !== String(linkIdToDelete)
@@ -1841,7 +1864,7 @@ var userActionHandlers = {
1841
1864
  }
1842
1865
  try {
1843
1866
  await context.actions.save_view_data(filenameToSave, payloadToSave);
1844
- if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1867
+ if (isView2 && parentFileId === context.sceneConfigId && context.actions.delete_quest_link_firestore) {
1845
1868
  await context.actions.delete_quest_link_firestore(
1846
1869
  context.ownerId,
1847
1870
  context.sceneConfigId,
@@ -2061,8 +2084,8 @@ var userActionHandlers = {
2061
2084
  );
2062
2085
  let filenameToSave;
2063
2086
  let payloadToSave;
2064
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2065
- if (isView && parentFileId === context.sceneConfigId) {
2087
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2088
+ if (isView2 && parentFileId === context.sceneConfigId) {
2066
2089
  filenameToSave = context.sceneSaveUrl;
2067
2090
  const strNodesToDelete = Array.from(nodesToDelete).map(String);
2068
2091
  const strLinksToDelete = Array.from(linksToDelete).map(String);
@@ -2176,8 +2199,8 @@ var userActionHandlers = {
2176
2199
  specificParentData.links = newLinks;
2177
2200
  let filenameToSave;
2178
2201
  let payloadToSave;
2179
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2180
- if (isView && parentFileId === context.sceneConfigId) {
2202
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2203
+ if (isView2 && parentFileId === context.sceneConfigId) {
2181
2204
  filenameToSave = context.sceneSaveUrl;
2182
2205
  const newVisualNodes = sceneDataRef.current.nodes.filter(
2183
2206
  (n) => String(n.id) !== strNodeId
@@ -2240,7 +2263,7 @@ var userActionHandlers = {
2240
2263
  }
2241
2264
  },
2242
2265
  handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
2243
- var _a, _b, _c;
2266
+ var _a, _b, _c, _d;
2244
2267
  const { graphDataRef, sceneDataRef, stateRef, setters } = context;
2245
2268
  if (!graphDataRef.current || !sceneDataRef.current) return;
2246
2269
  const {
@@ -2340,16 +2363,38 @@ var userActionHandlers = {
2340
2363
  })),
2341
2364
  recurrence_config: nextRecurrenceConfig
2342
2365
  };
2366
+ const rootId = ((_c = nodeToSave.version_node) == null ? void 0 : _c.parent_node) || nodeToSave.id;
2367
+ const nextQuestLink = {
2368
+ id: `link_${short.generate()}`,
2369
+ source: rootId,
2370
+ target: nextQuestNode.id
2371
+ };
2343
2372
  await context.actions.upsert_quest_firestore(
2344
2373
  context.ownerId,
2345
2374
  context.sceneConfigId,
2346
2375
  nextQuestNode
2347
2376
  );
2377
+ await context.actions.upsert_quest_link_firestore(
2378
+ context.ownerId,
2379
+ context.sceneConfigId,
2380
+ nextQuestLink
2381
+ );
2348
2382
  await context.actions.update_view_counter(
2349
2383
  context.ownerId,
2350
2384
  context.sceneConfigId,
2351
2385
  nextCounter
2352
2386
  );
2387
+ if (specificParentData.links) {
2388
+ specificParentData.links.push(nextQuestLink);
2389
+ }
2390
+ if (specificParentData.nodes) {
2391
+ specificParentData.nodes.push(nextQuestNode);
2392
+ }
2393
+ if (isView && parentFileId === context.sceneConfigId) {
2394
+ if (!sceneDataRef.current.links) sceneDataRef.current.links = [];
2395
+ sceneDataRef.current.links.push(nextQuestLink);
2396
+ sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2397
+ }
2353
2398
  if (stateRef.current.nodeObjects[String(nodeToSave.id)]) {
2354
2399
  const oldMeshPosition = stateRef.current.nodeObjects[String(nodeToSave.id)].position.clone();
2355
2400
  setTimeout(() => {
@@ -2368,8 +2413,8 @@ var userActionHandlers = {
2368
2413
  }
2369
2414
  }
2370
2415
  try {
2371
- const isView = ((_c = context.viewType) == null ? void 0 : _c.toLowerCase()) === "view";
2372
- if (isView && parentFileId === context.sceneConfigId) {
2416
+ const isView2 = ((_d = context.viewType) == null ? void 0 : _d.toLowerCase()) === "view";
2417
+ if (isView2 && parentFileId === context.sceneConfigId) {
2373
2418
  const visualNodeIndex = sceneDataRef.current.nodes.findIndex(
2374
2419
  (n) => String(n.id) === String(nodeToSave.id)
2375
2420
  );
@@ -2408,7 +2453,7 @@ var userActionHandlers = {
2408
2453
  );
2409
2454
  }
2410
2455
  graphDataRef.current[parentFileId] = specificParentData;
2411
- if (isView && parentFileId === context.sceneConfigId) {
2456
+ if (isView2 && parentFileId === context.sceneConfigId) {
2412
2457
  sceneDataRef.current.quest_nodes = [...specificParentData.nodes];
2413
2458
  }
2414
2459
  updateExistingNodeVisuals(stateRef.current, nodeToSave);
@@ -2461,8 +2506,8 @@ var userActionHandlers = {
2461
2506
  return;
2462
2507
  }
2463
2508
  try {
2464
- const isView = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2465
- if (isView && parentFileId === context.sceneConfigId) {
2509
+ const isView2 = ((_a = context.viewType) == null ? void 0 : _a.toLowerCase()) === "view";
2510
+ if (isView2 && parentFileId === context.sceneConfigId) {
2466
2511
  const viewFilePayload = {
2467
2512
  parent_dbs: sceneDataRef.current.parent_dbs,
2468
2513
  nodes: sceneDataRef.current.nodes,
@@ -18499,84 +18544,6 @@ function XViewScene({
18499
18544
  alert("Ocorreu um erro ao criar a Quest.");
18500
18545
  }
18501
18546
  };
18502
- userActionHandlers.handleCompleteConnection = async (context, targetNodeData) => {
18503
- const {
18504
- stateRef: stateRef2,
18505
- graphDataRef: graphDataRef2,
18506
- sceneDataRef: sceneDataRef2,
18507
- sceneConfigId: sceneConfigId2,
18508
- sceneSaveUrl: sceneSaveUrl2,
18509
- ownerId: ownerId2
18510
- } = context;
18511
- const { sourceNodeData } = stateRef2.current.connection;
18512
- if (!graphDataRef2.current || !sceneDataRef2.current || !sourceNodeData || !targetNodeData) {
18513
- userActionHandlers.handleCancelConnection(context);
18514
- return;
18515
- }
18516
- const sourceParentInfo = getParentFileInfoForNode(
18517
- graphDataRef2.current,
18518
- sceneDataRef2.current,
18519
- sourceNodeData.id,
18520
- sceneConfigId2,
18521
- ownerId2
18522
- );
18523
- const targetParentInfo = getParentFileInfoForNode(
18524
- graphDataRef2.current,
18525
- sceneDataRef2.current,
18526
- targetNodeData.id,
18527
- sceneConfigId2,
18528
- ownerId2
18529
- );
18530
- let parentInfoToSave = sourceParentInfo;
18531
- const isSourceQuest = sourceParentInfo.parentFileId === sceneConfigId2;
18532
- const isTargetQuest = targetParentInfo.parentFileId === sceneConfigId2;
18533
- if (isSourceQuest || isTargetQuest) {
18534
- parentInfoToSave = { parentFileId: sceneConfigId2, ownerId: ownerId2 };
18535
- }
18536
- const { parentFileId: parentFileIdToSave, ownerId: ownerIdToSave } = parentInfoToSave;
18537
- const newLink = {
18538
- id: `link_${short2.generate()}`,
18539
- source: sourceNodeData.id,
18540
- target: targetNodeData.id
18541
- };
18542
- try {
18543
- if (parentFileIdToSave === sceneConfigId2) {
18544
- const specificParentData = graphDataRef2.current[sceneConfigId2];
18545
- specificParentData.links.push(newLink);
18546
- const viewFilePayload = {
18547
- ...sceneDataRef2.current,
18548
- quest_counter: sceneDataRef2.current.quest_counter || 1
18549
- };
18550
- const questFilePayload = {
18551
- nodes: specificParentData.nodes,
18552
- links: specificParentData.links,
18553
- milestones: sceneDataRef2.current.milestones || []
18554
- };
18555
- await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18556
- const questSaveUrl = sceneSaveUrl2.replace(
18557
- "x_view_scenes",
18558
- "x_view_quests"
18559
- );
18560
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
18561
- } else {
18562
- const specificParentData = JSON.parse(
18563
- JSON.stringify(graphDataRef2.current[parentFileIdToSave])
18564
- );
18565
- specificParentData.links.push(newLink);
18566
- const filenameForSpecificParent = `x_view_dbs/${ownerIdToSave}/${parentFileIdToSave}`;
18567
- await context.actions.save_view_data(
18568
- filenameForSpecificParent,
18569
- specificParentData
18570
- );
18571
- graphDataRef2.current[parentFileIdToSave] = specificParentData;
18572
- }
18573
- addNewLinkToScene(stateRef2.current, newLink);
18574
- } catch (error) {
18575
- console.error("Falha ao salvar a nova conex\xE3o:", error);
18576
- alert("Ocorreu um erro ao salvar a nova conex\xE3o.");
18577
- }
18578
- userActionHandlers.handleCancelConnection(context);
18579
- };
18580
18547
  const handleClearAncestryVisuals = useCallback7((ancestryId) => {
18581
18548
  const { renderedAncestries, ancestryGroup } = stateRef.current;
18582
18549
  const renderIndex = renderedAncestries.findIndex(
@@ -20277,8 +20244,8 @@ function XViewScene({
20277
20244
  if (!sceneDataRef.current) return;
20278
20245
  sceneDataRef.current.milestones = newMilestones;
20279
20246
  setSceneVersion((v) => v + 1);
20280
- const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20281
- if (!isView || !save_view_data || !sceneSaveUrl) return;
20247
+ const isView2 = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20248
+ if (!isView2 || !save_view_data || !sceneSaveUrl) return;
20282
20249
  const questFileData = {
20283
20250
  nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20284
20251
  links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
@@ -20325,7 +20292,7 @@ function XViewScene({
20325
20292
  });
20326
20293
  sceneDataRef.current.nodes = currentNodes;
20327
20294
  sceneDataRef.current.links = currentLinks;
20328
- const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20295
+ const isView2 = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20329
20296
  const sceneFileData = {
20330
20297
  ...sceneDataRef.current,
20331
20298
  nodes: currentNodes,
@@ -20447,8 +20414,8 @@ function XViewScene({
20447
20414
  if (event.key.toLowerCase() === "q") {
20448
20415
  const isUiClear = !stateRef.current.creation.isActive && !stateRef.current.connection.isActive && !stateRef.current.relink.isActive && !stateRef.current.ancestry.isActive && !((_b2 = context.versionMode) == null ? void 0 : _b2.isActive) && !contextMenu.visible && !multiContextMenu.visible && !relationshipMenu.visible && !readingMode.isActive && !isImportModalOpen && !isBoardsOpen && !isSidebarOpen && !isMilestoneManagerOpen && !detailsNode && !detailsLink && !ancestryLinkDetails && !imageViewer.visible && !editingAncestryRel.visible && !questMode.isActive;
20449
20416
  if (isUiClear) {
20450
- const isView = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
20451
- if (!isView) return;
20417
+ const isView2 = ((_c2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _c2.toLowerCase()) === "view";
20418
+ if (!isView2) return;
20452
20419
  const {
20453
20420
  graphGroup,
20454
20421
  glowTexture,
@@ -21233,11 +21200,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21233
21200
  parentDbObjects.push({ db_id: scene_config, owner_id });
21234
21201
  }
21235
21202
  }
21236
- const isView = type && type.toLowerCase() === "view";
21203
+ const isView2 = type && type.toLowerCase() === "view";
21237
21204
  const parentResponsesPromises = parentDbObjects.map(
21238
21205
  (db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
21239
21206
  );
21240
- if (isView) {
21207
+ if (isView2) {
21241
21208
  const questFetchWithMigrationPromise = (async () => {
21242
21209
  try {
21243
21210
  const questsResponse = await db_services.get_view_quests_firestore(
@@ -21279,7 +21246,7 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21279
21246
  let questDataObj = null;
21280
21247
  for (let i = 0; i < parentResponsesResults.length; i++) {
21281
21248
  const result = parentResponsesResults[i];
21282
- if (isView && i === parentResponsesResults.length - 1) {
21249
+ if (isView2 && i === parentResponsesResults.length - 1) {
21283
21250
  if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
21284
21251
  questDataObj = result.value.data;
21285
21252
  if (result.value.quest_counter !== void 0) {
@@ -21301,7 +21268,7 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21301
21268
  const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
21302
21269
  const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
21303
21270
  const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
21304
- if (isView) {
21271
+ if (isView2) {
21305
21272
  parentData[scene_config] = {
21306
21273
  dataset_name: "Quests Internas (View)",
21307
21274
  nodes: currentQuestNodes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lv-x-software-house/x_view",
3
- "version": "1.2.8-dev.12",
3
+ "version": "1.2.8-dev.14",
4
4
  "description": "Pacote privado contendo os componentes e lógica de renderização 3D do X View.",
5
5
  "author": "iv.x - Engenharia de Software - ivxsoftwarehouse@gmail.com",
6
6
  "license": "UNLICENSED",