@lv-x-software-house/x_view 1.2.8-dev.4 → 1.2.8-dev.7
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/index.js +156 -60
- package/dist/index.mjs +156 -60
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -16020,7 +16020,7 @@ function XViewScene({
|
|
|
16020
16020
|
obj.material.dispose();
|
|
16021
16021
|
}
|
|
16022
16022
|
}
|
|
16023
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16023
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16024
16024
|
const oldLabel = mesh.getObjectByName("timelineLabel");
|
|
16025
16025
|
if (oldLabel) {
|
|
16026
16026
|
mesh.remove(oldLabel);
|
|
@@ -16044,7 +16044,7 @@ function XViewScene({
|
|
|
16044
16044
|
}
|
|
16045
16045
|
return null;
|
|
16046
16046
|
};
|
|
16047
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16047
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16048
16048
|
const dateProp = mesh.userData.Date;
|
|
16049
16049
|
let nodeInfo = { mesh, type: "point", label: "", isUndated: true };
|
|
16050
16050
|
if (dateProp) {
|
|
@@ -16333,8 +16333,8 @@ function XViewScene({
|
|
|
16333
16333
|
]);
|
|
16334
16334
|
if ((sceneResponse == null ? void 0 : sceneResponse.success) && ((_a2 = sceneResponse.data) == null ? void 0 : _a2.scene) && ((_b2 = sceneResponse.data) == null ? void 0 : _b2.parent)) {
|
|
16335
16335
|
const sceneData = sceneResponse.data.scene;
|
|
16336
|
-
let firestoreQuests = (questResponse == null ? void 0 : questResponse.success) ? questResponse.quests : [];
|
|
16337
|
-
let firestoreLinks = (questResponse == null ? void 0 : questResponse.success) ? questResponse.links : [];
|
|
16336
|
+
let firestoreQuests = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.quests) ? questResponse.quests : [];
|
|
16337
|
+
let firestoreLinks = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.links) ? questResponse.links : [];
|
|
16338
16338
|
if (!sceneData.quests_migrated && firestoreQuests.length === 0) {
|
|
16339
16339
|
const legacyQuests = sceneData.quest_nodes || [];
|
|
16340
16340
|
const legacyLinks = sceneData.quest_links || [];
|
|
@@ -16357,8 +16357,8 @@ function XViewScene({
|
|
|
16357
16357
|
);
|
|
16358
16358
|
if (!targetNode) {
|
|
16359
16359
|
const allParentNodes = Object.values(
|
|
16360
|
-
sceneResponse.data.parent
|
|
16361
|
-
).flatMap((f) => f.nodes || []);
|
|
16360
|
+
sceneResponse.data.parent || {}
|
|
16361
|
+
).flatMap((f) => (f == null ? void 0 : f.nodes) || []);
|
|
16362
16362
|
targetNode = allParentNodes.find(
|
|
16363
16363
|
(n) => String(n.id) === String(focusNodeId)
|
|
16364
16364
|
);
|
|
@@ -16700,7 +16700,7 @@ function XViewScene({
|
|
|
16700
16700
|
positionGroups.get(posKey).push(String(q.id));
|
|
16701
16701
|
});
|
|
16702
16702
|
});
|
|
16703
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16703
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16704
16704
|
const oldLabel = mesh.getObjectByName("questDateLabel") || mesh.getObjectByName("timelineLabel");
|
|
16705
16705
|
if (oldLabel) {
|
|
16706
16706
|
mesh.remove(oldLabel);
|
|
@@ -18049,7 +18049,7 @@ function XViewScene({
|
|
|
18049
18049
|
(questNode) => {
|
|
18050
18050
|
var _a2, _b2, _c2;
|
|
18051
18051
|
if (!questNode || !actionHandlerContext) return;
|
|
18052
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
18052
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
18053
18053
|
(fileData) => fileData.nodes || []
|
|
18054
18054
|
);
|
|
18055
18055
|
const blockCheck = isQuestBlocked(questNode, allParentNodes);
|
|
@@ -18586,7 +18586,7 @@ function XViewScene({
|
|
|
18586
18586
|
if (line.material) line.material.dispose();
|
|
18587
18587
|
});
|
|
18588
18588
|
}
|
|
18589
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
18589
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
18590
18590
|
(fileData) => fileData.nodes
|
|
18591
18591
|
);
|
|
18592
18592
|
const allAncestries = ancestryDataRef.current || [];
|
|
@@ -18974,7 +18974,7 @@ function XViewScene({
|
|
|
18974
18974
|
);
|
|
18975
18975
|
if (!ancestryObject || !ancestryObject.abstraction_tree) return;
|
|
18976
18976
|
const { ancestryGroup, nodeObjects, renderer, renderedAncestries } = stateRef.current;
|
|
18977
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
18977
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
18978
18978
|
(f) => f.nodes
|
|
18979
18979
|
);
|
|
18980
18980
|
let fullTree = buildFullAncestryTree(
|
|
@@ -19062,7 +19062,7 @@ function XViewScene({
|
|
|
19062
19062
|
const allAncestries = ancestryDataRef.current || [];
|
|
19063
19063
|
const fullTree = buildFullAncestryTree(
|
|
19064
19064
|
ancestry.tree,
|
|
19065
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19065
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19066
19066
|
allAncestries
|
|
19067
19067
|
);
|
|
19068
19068
|
if (action === "open") {
|
|
@@ -19244,7 +19244,7 @@ function XViewScene({
|
|
|
19244
19244
|
return null;
|
|
19245
19245
|
const fullTree = buildFullAncestryTree(
|
|
19246
19246
|
readingMode.ancestry.tree,
|
|
19247
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19247
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19248
19248
|
ancestryDataRef.current
|
|
19249
19249
|
);
|
|
19250
19250
|
const findNodeInTree = (tree, targetId) => {
|
|
@@ -19309,7 +19309,7 @@ function XViewScene({
|
|
|
19309
19309
|
}
|
|
19310
19310
|
const fullTree = buildFullAncestryTree(
|
|
19311
19311
|
readingMode.ancestry.tree,
|
|
19312
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19312
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19313
19313
|
ancestryDataRef.current
|
|
19314
19314
|
);
|
|
19315
19315
|
let currentPtr = fullTree;
|
|
@@ -19406,7 +19406,7 @@ function XViewScene({
|
|
|
19406
19406
|
let targetObj = ancestry;
|
|
19407
19407
|
let targetTree = ancestry.tree;
|
|
19408
19408
|
if (branchStack.length > 0) {
|
|
19409
|
-
const allNodes = Object.values(parentDataRef.current).flatMap(
|
|
19409
|
+
const allNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
19410
19410
|
(f) => f.nodes
|
|
19411
19411
|
);
|
|
19412
19412
|
const fullTree = buildFullAncestryTree(
|
|
@@ -19563,7 +19563,7 @@ function XViewScene({
|
|
|
19563
19563
|
stateRef.current.maxAncestryRenderIndex = 0;
|
|
19564
19564
|
const initialSections = /* @__PURE__ */ new Set(["preamble", 0]);
|
|
19565
19565
|
await handleRenderAncestry(ancestryObject, initialSections);
|
|
19566
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
19566
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
19567
19567
|
(fileData) => fileData.nodes
|
|
19568
19568
|
);
|
|
19569
19569
|
const allAncestries = ancestryDataRef.current || [];
|
|
@@ -20028,7 +20028,7 @@ function XViewScene({
|
|
|
20028
20028
|
}, []);
|
|
20029
20029
|
const allAvailableNodes = (0, import_react33.useMemo)(() => {
|
|
20030
20030
|
if (!parentDataRef.current) return [];
|
|
20031
|
-
return Object.values(parentDataRef.current).flatMap(
|
|
20031
|
+
return Object.values(parentDataRef.current || {}).flatMap(
|
|
20032
20032
|
(fileData) => fileData.nodes || []
|
|
20033
20033
|
);
|
|
20034
20034
|
}, [sceneVersion, isInitialized]);
|
|
@@ -20117,7 +20117,7 @@ function XViewScene({
|
|
|
20117
20117
|
if (!parentDataRef.current) {
|
|
20118
20118
|
return [];
|
|
20119
20119
|
}
|
|
20120
|
-
const allTypes = Object.values(parentDataRef.current).flatMap(
|
|
20120
|
+
const allTypes = Object.values(parentDataRef.current || {}).flatMap(
|
|
20121
20121
|
(fileData) => fileData.nodes.flatMap((node) => {
|
|
20122
20122
|
if (Array.isArray(node.type)) return node.type;
|
|
20123
20123
|
return [node.type];
|
|
@@ -20191,7 +20191,7 @@ function XViewScene({
|
|
|
20191
20191
|
return;
|
|
20192
20192
|
}
|
|
20193
20193
|
if (!save_view_data) return;
|
|
20194
|
-
const currentNodes = Object.values(nodeObjects).map((mesh) => {
|
|
20194
|
+
const currentNodes = Object.values(nodeObjects || {}).map((mesh) => {
|
|
20195
20195
|
const {
|
|
20196
20196
|
_baseEmissiveIntensity,
|
|
20197
20197
|
labelObject,
|
|
@@ -20353,7 +20353,7 @@ function XViewScene({
|
|
|
20353
20353
|
} = stateRef.current;
|
|
20354
20354
|
if (graphGroup) {
|
|
20355
20355
|
let ghostPosition = sceneControls.target.clone();
|
|
20356
|
-
const existingNodes = Object.values(nodeObjects);
|
|
20356
|
+
const existingNodes = Object.values(nodeObjects || {});
|
|
20357
20357
|
let isOccupied = true;
|
|
20358
20358
|
let radius = 18;
|
|
20359
20359
|
let angle = 0;
|
|
@@ -21096,20 +21096,35 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21096
21096
|
if (!session || !session.user) {
|
|
21097
21097
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
21098
21098
|
}
|
|
21099
|
-
const membershipCheck = await db_services.check_membership(
|
|
21099
|
+
const membershipCheck = await db_services.check_membership(
|
|
21100
|
+
owner_id,
|
|
21101
|
+
type,
|
|
21102
|
+
scene_config,
|
|
21103
|
+
session.user.id
|
|
21104
|
+
);
|
|
21100
21105
|
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
21101
21106
|
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
21102
|
-
return {
|
|
21107
|
+
return {
|
|
21108
|
+
success: false,
|
|
21109
|
+
error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio."
|
|
21110
|
+
};
|
|
21103
21111
|
}
|
|
21104
|
-
const sceneResponse = await db_services.get_file(
|
|
21112
|
+
const sceneResponse = await db_services.get_file(
|
|
21113
|
+
`x_view_scenes/${owner_id}/${scene_config}`
|
|
21114
|
+
);
|
|
21105
21115
|
if (!sceneResponse || !sceneResponse.success) {
|
|
21106
21116
|
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
21107
|
-
return {
|
|
21117
|
+
return {
|
|
21118
|
+
success: false,
|
|
21119
|
+
error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}`
|
|
21120
|
+
};
|
|
21108
21121
|
}
|
|
21109
21122
|
const sceneData = sceneResponse.data;
|
|
21110
21123
|
const parentDbObjects = sceneData.parent_dbs || [];
|
|
21111
21124
|
if (type && type.toLowerCase().includes("database")) {
|
|
21112
|
-
const selfExists = parentDbObjects.some(
|
|
21125
|
+
const selfExists = parentDbObjects.some(
|
|
21126
|
+
(db) => String(db.db_id) === String(scene_config)
|
|
21127
|
+
);
|
|
21113
21128
|
if (!selfExists) {
|
|
21114
21129
|
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
21115
21130
|
}
|
|
@@ -21118,13 +21133,18 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21118
21133
|
const parentResponsesPromises = parentDbObjects.map(
|
|
21119
21134
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21120
21135
|
);
|
|
21121
|
-
const parentResponsesResults = await Promise.allSettled(
|
|
21136
|
+
const parentResponsesResults = await Promise.allSettled(
|
|
21137
|
+
parentResponsesPromises
|
|
21138
|
+
);
|
|
21122
21139
|
const parentData = {};
|
|
21123
21140
|
let currentQuestNodes = [];
|
|
21124
21141
|
let currentQuestLinks = [];
|
|
21125
21142
|
let currentMilestones = [];
|
|
21126
21143
|
if (isView) {
|
|
21127
|
-
const firestoreQuestsRes = await db_services.get_view_quests_and_links(
|
|
21144
|
+
const firestoreQuestsRes = await db_services.get_view_quests_and_links(
|
|
21145
|
+
owner_id,
|
|
21146
|
+
scene_config
|
|
21147
|
+
);
|
|
21128
21148
|
const isMigrated = sceneData.quests_migrated === true;
|
|
21129
21149
|
if (firestoreQuestsRes.success && (firestoreQuestsRes.data.nodes.length > 0 || isMigrated)) {
|
|
21130
21150
|
currentQuestNodes = firestoreQuestsRes.data.nodes;
|
|
@@ -21132,14 +21152,20 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21132
21152
|
currentMilestones = sceneData.milestones || [];
|
|
21133
21153
|
} else {
|
|
21134
21154
|
console.log(`Iniciando Lazy Migration para View ${scene_config}...`);
|
|
21135
|
-
const legacyQuestsRes = await db_services.get_file(
|
|
21155
|
+
const legacyQuestsRes = await db_services.get_file(
|
|
21156
|
+
`x_view_quests/${owner_id}/${scene_config}`
|
|
21157
|
+
);
|
|
21136
21158
|
if (legacyQuestsRes.success && legacyQuestsRes.data) {
|
|
21137
21159
|
const legacyData = legacyQuestsRes.data;
|
|
21138
21160
|
currentQuestNodes = legacyData.nodes || [];
|
|
21139
21161
|
currentQuestLinks = legacyData.links || [];
|
|
21140
21162
|
currentMilestones = legacyData.milestones || [];
|
|
21141
21163
|
sceneData.milestones = currentMilestones;
|
|
21142
|
-
await db_services.migrate_legacy_quests(
|
|
21164
|
+
await db_services.migrate_legacy_quests(
|
|
21165
|
+
owner_id,
|
|
21166
|
+
scene_config,
|
|
21167
|
+
legacyData
|
|
21168
|
+
);
|
|
21143
21169
|
}
|
|
21144
21170
|
}
|
|
21145
21171
|
}
|
|
@@ -21162,15 +21188,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21162
21188
|
links: currentQuestLinks
|
|
21163
21189
|
};
|
|
21164
21190
|
}
|
|
21165
|
-
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
21166
|
-
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
21167
|
-
const parentNodeMap = new Map(
|
|
21168
|
-
|
|
21191
|
+
const allNodes = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.nodes) || []);
|
|
21192
|
+
const allLinks = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.links) || []);
|
|
21193
|
+
const parentNodeMap = new Map(
|
|
21194
|
+
allNodes.map((node) => [String(node.id), node])
|
|
21195
|
+
);
|
|
21196
|
+
const parentLinkMap = new Map(
|
|
21197
|
+
allLinks.map((link) => [`${link.source}-${link.target}`, link])
|
|
21198
|
+
);
|
|
21169
21199
|
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
21170
21200
|
var _a2, _b2;
|
|
21171
21201
|
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
21172
21202
|
if (nodeTypes.includes("quest")) {
|
|
21173
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21203
|
+
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21204
|
+
(qn) => String(qn.id) === String(sceneNode.id)
|
|
21205
|
+
);
|
|
21174
21206
|
if (dbQuestNode) {
|
|
21175
21207
|
return { ...sceneNode, ...dbQuestNode };
|
|
21176
21208
|
}
|
|
@@ -21182,17 +21214,23 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21182
21214
|
}
|
|
21183
21215
|
return null;
|
|
21184
21216
|
}).filter(Boolean);
|
|
21185
|
-
const validNodeIdsInScene = new Set(
|
|
21217
|
+
const validNodeIdsInScene = new Set(
|
|
21218
|
+
validatedNodes.map((node) => String(node.id))
|
|
21219
|
+
);
|
|
21186
21220
|
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
21187
|
-
const linkExistsInParent = parentLinkMap.has(
|
|
21221
|
+
const linkExistsInParent = parentLinkMap.has(
|
|
21222
|
+
`${sceneLink.source}-${sceneLink.target}`
|
|
21223
|
+
);
|
|
21188
21224
|
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
21189
21225
|
return linkExistsInParent && nodesAreValidForScene;
|
|
21190
|
-
}).map(
|
|
21226
|
+
}).map(
|
|
21227
|
+
(sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`)
|
|
21228
|
+
);
|
|
21191
21229
|
const validatedSceneData = {
|
|
21192
21230
|
...sceneData,
|
|
21193
21231
|
nodes: validatedNodes,
|
|
21194
21232
|
links: validatedLinks,
|
|
21195
|
-
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21233
|
+
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21196
21234
|
// continue acessando as quests sem perceber a separação física
|
|
21197
21235
|
quest_nodes: currentQuestNodes,
|
|
21198
21236
|
quest_links: currentQuestLinks,
|
|
@@ -21213,7 +21251,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21213
21251
|
isSceneFile: false
|
|
21214
21252
|
});
|
|
21215
21253
|
});
|
|
21216
|
-
const ancestryPromises = ancestryFilePaths.map(
|
|
21254
|
+
const ancestryPromises = ancestryFilePaths.map(
|
|
21255
|
+
(file) => db_services.get_file(file.path)
|
|
21256
|
+
);
|
|
21217
21257
|
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
21218
21258
|
const ancestriesFromSceneFile = [];
|
|
21219
21259
|
const ancestriesFromDbFiles = [];
|
|
@@ -21239,15 +21279,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21239
21279
|
}
|
|
21240
21280
|
});
|
|
21241
21281
|
const ancestryMap = /* @__PURE__ */ new Map();
|
|
21242
|
-
ancestriesFromDbFiles.forEach(
|
|
21243
|
-
|
|
21282
|
+
ancestriesFromDbFiles.forEach(
|
|
21283
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21284
|
+
);
|
|
21285
|
+
ancestriesFromSceneFile.forEach(
|
|
21286
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21287
|
+
);
|
|
21244
21288
|
let ancestryData = Array.from(ancestryMap.values());
|
|
21245
21289
|
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
21246
21290
|
ancestryData.forEach((anc) => {
|
|
21247
21291
|
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
21248
21292
|
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
21249
21293
|
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
21250
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21294
|
+
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21295
|
+
(db) => String(db.db_id) === String(targetSourceId)
|
|
21296
|
+
);
|
|
21251
21297
|
if (!isAlreadyLoadedAsParent) {
|
|
21252
21298
|
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
21253
21299
|
externalSourcesToRefresh.set(key, {
|
|
@@ -21288,12 +21334,16 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21288
21334
|
return false;
|
|
21289
21335
|
}
|
|
21290
21336
|
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
21291
|
-
const stillExists = freshAncestryMap.has(
|
|
21337
|
+
const stillExists = freshAncestryMap.has(
|
|
21338
|
+
String(localAnc.ancestry_id)
|
|
21339
|
+
);
|
|
21292
21340
|
return stillExists;
|
|
21293
21341
|
}
|
|
21294
21342
|
return true;
|
|
21295
21343
|
}).map((localAnc) => {
|
|
21296
|
-
const freshVersion = freshAncestryMap.get(
|
|
21344
|
+
const freshVersion = freshAncestryMap.get(
|
|
21345
|
+
String(localAnc.ancestry_id)
|
|
21346
|
+
);
|
|
21297
21347
|
if (freshVersion) {
|
|
21298
21348
|
return {
|
|
21299
21349
|
...freshVersion,
|
|
@@ -21332,7 +21382,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21332
21382
|
parallel_branches: validBranches
|
|
21333
21383
|
};
|
|
21334
21384
|
};
|
|
21335
|
-
const originalAncestryDataString = JSON.stringify(
|
|
21385
|
+
const originalAncestryDataString = JSON.stringify(
|
|
21386
|
+
Array.from(ancestryMap.values())
|
|
21387
|
+
);
|
|
21336
21388
|
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
21337
21389
|
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
21338
21390
|
const cleanedTree = pruneTree(ancestry.tree);
|
|
@@ -21352,7 +21404,10 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21352
21404
|
try {
|
|
21353
21405
|
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
21354
21406
|
} catch (saveError) {
|
|
21355
|
-
console.error(
|
|
21407
|
+
console.error(
|
|
21408
|
+
"Falha ao salvar o arquivo de ancestralidade da cena atualizado:",
|
|
21409
|
+
saveError
|
|
21410
|
+
);
|
|
21356
21411
|
}
|
|
21357
21412
|
}
|
|
21358
21413
|
if (!isFullMember) {
|
|
@@ -21360,7 +21415,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21360
21415
|
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
21361
21416
|
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
21362
21417
|
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
21363
|
-
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21418
|
+
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21419
|
+
(db) => db.nodes || []
|
|
21420
|
+
);
|
|
21364
21421
|
const extractDependenciesFromText = (text) => {
|
|
21365
21422
|
if (!text) return;
|
|
21366
21423
|
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
@@ -21387,9 +21444,12 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21387
21444
|
if (branch.linked_ancestry_id) {
|
|
21388
21445
|
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
21389
21446
|
}
|
|
21390
|
-
if (branch.description)
|
|
21447
|
+
if (branch.description)
|
|
21448
|
+
extractDependenciesFromText(branch.description);
|
|
21391
21449
|
if (branch.description_sections) {
|
|
21392
|
-
branch.description_sections.forEach(
|
|
21450
|
+
branch.description_sections.forEach(
|
|
21451
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21452
|
+
);
|
|
21393
21453
|
}
|
|
21394
21454
|
extractTreeDependencies(branch.tree);
|
|
21395
21455
|
});
|
|
@@ -21403,7 +21463,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21403
21463
|
if (anc && !anc.is_private) {
|
|
21404
21464
|
if (anc.description) extractDependenciesFromText(anc.description);
|
|
21405
21465
|
if (anc.description_sections) {
|
|
21406
|
-
anc.description_sections.forEach(
|
|
21466
|
+
anc.description_sections.forEach(
|
|
21467
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21468
|
+
);
|
|
21407
21469
|
}
|
|
21408
21470
|
extractTreeDependencies(anc.tree);
|
|
21409
21471
|
extractTreeDependencies(anc.abstraction_tree);
|
|
@@ -21414,22 +21476,38 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21414
21476
|
if (node) {
|
|
21415
21477
|
if (node.description) extractDependenciesFromText(node.description);
|
|
21416
21478
|
if (node.description_sections) {
|
|
21417
|
-
node.description_sections.forEach(
|
|
21479
|
+
node.description_sections.forEach(
|
|
21480
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21481
|
+
);
|
|
21418
21482
|
}
|
|
21419
21483
|
}
|
|
21420
21484
|
});
|
|
21421
21485
|
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
21422
|
-
const restrictedSceneData = {
|
|
21486
|
+
const restrictedSceneData = {
|
|
21487
|
+
...validatedSceneData,
|
|
21488
|
+
nodes: [],
|
|
21489
|
+
links: []
|
|
21490
|
+
};
|
|
21423
21491
|
const restrictedParentData = {};
|
|
21424
|
-
const restrictedAncestryData = ancestryData.filter(
|
|
21492
|
+
const restrictedAncestryData = ancestryData.filter(
|
|
21493
|
+
(a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private
|
|
21494
|
+
);
|
|
21425
21495
|
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
21426
|
-
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21496
|
+
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21497
|
+
(n) => requiredNodeIds.has(String(n.id))
|
|
21498
|
+
);
|
|
21427
21499
|
if (filteredNodes.length > 0) {
|
|
21428
|
-
restrictedParentData[dbId] = {
|
|
21500
|
+
restrictedParentData[dbId] = {
|
|
21501
|
+
...dbContent,
|
|
21502
|
+
nodes: filteredNodes,
|
|
21503
|
+
links: []
|
|
21504
|
+
};
|
|
21429
21505
|
}
|
|
21430
21506
|
}
|
|
21431
21507
|
if (focusNodeId) {
|
|
21432
|
-
const mainNode = allNodesFromDb.find(
|
|
21508
|
+
const mainNode = allNodesFromDb.find(
|
|
21509
|
+
(n) => String(n.id) === String(focusNodeId)
|
|
21510
|
+
);
|
|
21433
21511
|
if (mainNode) {
|
|
21434
21512
|
restrictedSceneData.nodes = [mainNode];
|
|
21435
21513
|
}
|
|
@@ -21445,7 +21523,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21445
21523
|
}
|
|
21446
21524
|
return {
|
|
21447
21525
|
success: true,
|
|
21448
|
-
data: {
|
|
21526
|
+
data: {
|
|
21527
|
+
scene: validatedSceneData,
|
|
21528
|
+
parent: parentData,
|
|
21529
|
+
ancestry: ancestryData
|
|
21530
|
+
}
|
|
21449
21531
|
};
|
|
21450
21532
|
} catch (error) {
|
|
21451
21533
|
console.error("Erro em get_scene_view_data_logic:", error);
|
|
@@ -21465,13 +21547,18 @@ async function import_parent_file_modal_get_logic(db_services, session) {
|
|
|
21465
21547
|
}
|
|
21466
21548
|
};
|
|
21467
21549
|
} catch (error) {
|
|
21468
|
-
console.error(
|
|
21550
|
+
console.error(
|
|
21551
|
+
"catch (error) em import_parent_file_modal_get_logic:",
|
|
21552
|
+
error
|
|
21553
|
+
);
|
|
21469
21554
|
return { success: false, error: error.message };
|
|
21470
21555
|
}
|
|
21471
21556
|
}
|
|
21472
21557
|
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
21473
21558
|
try {
|
|
21474
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21559
|
+
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21560
|
+
`x_view_dbs/${session.user.id}/${file_id}`
|
|
21561
|
+
);
|
|
21475
21562
|
return call_GCP_cloud_storage_get_file;
|
|
21476
21563
|
} catch (error) {
|
|
21477
21564
|
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
@@ -21505,7 +21592,13 @@ async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
|
21505
21592
|
async function save_boards_logic(db_services, scene_id, type, boardItems, session, owner_id) {
|
|
21506
21593
|
try {
|
|
21507
21594
|
const targetOwnerId = owner_id || session.user.id;
|
|
21508
|
-
return await db_services.save_boards(
|
|
21595
|
+
return await db_services.save_boards(
|
|
21596
|
+
session,
|
|
21597
|
+
scene_id,
|
|
21598
|
+
type,
|
|
21599
|
+
boardItems,
|
|
21600
|
+
targetOwnerId
|
|
21601
|
+
);
|
|
21509
21602
|
} catch (error) {
|
|
21510
21603
|
console.error("Erro em save_boards_logic:", error);
|
|
21511
21604
|
return { success: false, error: error.message };
|
|
@@ -21534,7 +21627,10 @@ async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
|
21534
21627
|
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
21535
21628
|
try {
|
|
21536
21629
|
if (!db_services.get_view_members) {
|
|
21537
|
-
return {
|
|
21630
|
+
return {
|
|
21631
|
+
success: false,
|
|
21632
|
+
error: "Servi\xE7o de busca de membros n\xE3o configurado."
|
|
21633
|
+
};
|
|
21538
21634
|
}
|
|
21539
21635
|
return await db_services.get_view_members(ownerId, type, itemId);
|
|
21540
21636
|
} catch (error) {
|
package/dist/index.mjs
CHANGED
|
@@ -16083,7 +16083,7 @@ function XViewScene({
|
|
|
16083
16083
|
obj.material.dispose();
|
|
16084
16084
|
}
|
|
16085
16085
|
}
|
|
16086
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16086
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16087
16087
|
const oldLabel = mesh.getObjectByName("timelineLabel");
|
|
16088
16088
|
if (oldLabel) {
|
|
16089
16089
|
mesh.remove(oldLabel);
|
|
@@ -16107,7 +16107,7 @@ function XViewScene({
|
|
|
16107
16107
|
}
|
|
16108
16108
|
return null;
|
|
16109
16109
|
};
|
|
16110
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16110
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16111
16111
|
const dateProp = mesh.userData.Date;
|
|
16112
16112
|
let nodeInfo = { mesh, type: "point", label: "", isUndated: true };
|
|
16113
16113
|
if (dateProp) {
|
|
@@ -16396,8 +16396,8 @@ function XViewScene({
|
|
|
16396
16396
|
]);
|
|
16397
16397
|
if ((sceneResponse == null ? void 0 : sceneResponse.success) && ((_a2 = sceneResponse.data) == null ? void 0 : _a2.scene) && ((_b2 = sceneResponse.data) == null ? void 0 : _b2.parent)) {
|
|
16398
16398
|
const sceneData = sceneResponse.data.scene;
|
|
16399
|
-
let firestoreQuests = (questResponse == null ? void 0 : questResponse.success) ? questResponse.quests : [];
|
|
16400
|
-
let firestoreLinks = (questResponse == null ? void 0 : questResponse.success) ? questResponse.links : [];
|
|
16399
|
+
let firestoreQuests = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.quests) ? questResponse.quests : [];
|
|
16400
|
+
let firestoreLinks = (questResponse == null ? void 0 : questResponse.success) && Array.isArray(questResponse.links) ? questResponse.links : [];
|
|
16401
16401
|
if (!sceneData.quests_migrated && firestoreQuests.length === 0) {
|
|
16402
16402
|
const legacyQuests = sceneData.quest_nodes || [];
|
|
16403
16403
|
const legacyLinks = sceneData.quest_links || [];
|
|
@@ -16420,8 +16420,8 @@ function XViewScene({
|
|
|
16420
16420
|
);
|
|
16421
16421
|
if (!targetNode) {
|
|
16422
16422
|
const allParentNodes = Object.values(
|
|
16423
|
-
sceneResponse.data.parent
|
|
16424
|
-
).flatMap((f) => f.nodes || []);
|
|
16423
|
+
sceneResponse.data.parent || {}
|
|
16424
|
+
).flatMap((f) => (f == null ? void 0 : f.nodes) || []);
|
|
16425
16425
|
targetNode = allParentNodes.find(
|
|
16426
16426
|
(n) => String(n.id) === String(focusNodeId)
|
|
16427
16427
|
);
|
|
@@ -16763,7 +16763,7 @@ function XViewScene({
|
|
|
16763
16763
|
positionGroups.get(posKey).push(String(q.id));
|
|
16764
16764
|
});
|
|
16765
16765
|
});
|
|
16766
|
-
Object.values(nodeObjects).forEach((mesh) => {
|
|
16766
|
+
Object.values(nodeObjects || {}).forEach((mesh) => {
|
|
16767
16767
|
const oldLabel = mesh.getObjectByName("questDateLabel") || mesh.getObjectByName("timelineLabel");
|
|
16768
16768
|
if (oldLabel) {
|
|
16769
16769
|
mesh.remove(oldLabel);
|
|
@@ -18112,7 +18112,7 @@ function XViewScene({
|
|
|
18112
18112
|
(questNode) => {
|
|
18113
18113
|
var _a2, _b2, _c2;
|
|
18114
18114
|
if (!questNode || !actionHandlerContext) return;
|
|
18115
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
18115
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
18116
18116
|
(fileData) => fileData.nodes || []
|
|
18117
18117
|
);
|
|
18118
18118
|
const blockCheck = isQuestBlocked(questNode, allParentNodes);
|
|
@@ -18649,7 +18649,7 @@ function XViewScene({
|
|
|
18649
18649
|
if (line.material) line.material.dispose();
|
|
18650
18650
|
});
|
|
18651
18651
|
}
|
|
18652
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
18652
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
18653
18653
|
(fileData) => fileData.nodes
|
|
18654
18654
|
);
|
|
18655
18655
|
const allAncestries = ancestryDataRef.current || [];
|
|
@@ -19037,7 +19037,7 @@ function XViewScene({
|
|
|
19037
19037
|
);
|
|
19038
19038
|
if (!ancestryObject || !ancestryObject.abstraction_tree) return;
|
|
19039
19039
|
const { ancestryGroup, nodeObjects, renderer, renderedAncestries } = stateRef.current;
|
|
19040
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
19040
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
19041
19041
|
(f) => f.nodes
|
|
19042
19042
|
);
|
|
19043
19043
|
let fullTree = buildFullAncestryTree(
|
|
@@ -19125,7 +19125,7 @@ function XViewScene({
|
|
|
19125
19125
|
const allAncestries = ancestryDataRef.current || [];
|
|
19126
19126
|
const fullTree = buildFullAncestryTree(
|
|
19127
19127
|
ancestry.tree,
|
|
19128
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19128
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19129
19129
|
allAncestries
|
|
19130
19130
|
);
|
|
19131
19131
|
if (action === "open") {
|
|
@@ -19307,7 +19307,7 @@ function XViewScene({
|
|
|
19307
19307
|
return null;
|
|
19308
19308
|
const fullTree = buildFullAncestryTree(
|
|
19309
19309
|
readingMode.ancestry.tree,
|
|
19310
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19310
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19311
19311
|
ancestryDataRef.current
|
|
19312
19312
|
);
|
|
19313
19313
|
const findNodeInTree = (tree, targetId) => {
|
|
@@ -19372,7 +19372,7 @@ function XViewScene({
|
|
|
19372
19372
|
}
|
|
19373
19373
|
const fullTree = buildFullAncestryTree(
|
|
19374
19374
|
readingMode.ancestry.tree,
|
|
19375
|
-
Object.values(parentDataRef.current).flatMap((f) => f.nodes),
|
|
19375
|
+
Object.values(parentDataRef.current || {}).flatMap((f) => f.nodes),
|
|
19376
19376
|
ancestryDataRef.current
|
|
19377
19377
|
);
|
|
19378
19378
|
let currentPtr = fullTree;
|
|
@@ -19469,7 +19469,7 @@ function XViewScene({
|
|
|
19469
19469
|
let targetObj = ancestry;
|
|
19470
19470
|
let targetTree = ancestry.tree;
|
|
19471
19471
|
if (branchStack.length > 0) {
|
|
19472
|
-
const allNodes = Object.values(parentDataRef.current).flatMap(
|
|
19472
|
+
const allNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
19473
19473
|
(f) => f.nodes
|
|
19474
19474
|
);
|
|
19475
19475
|
const fullTree = buildFullAncestryTree(
|
|
@@ -19626,7 +19626,7 @@ function XViewScene({
|
|
|
19626
19626
|
stateRef.current.maxAncestryRenderIndex = 0;
|
|
19627
19627
|
const initialSections = /* @__PURE__ */ new Set(["preamble", 0]);
|
|
19628
19628
|
await handleRenderAncestry(ancestryObject, initialSections);
|
|
19629
|
-
const allParentNodes = Object.values(parentDataRef.current).flatMap(
|
|
19629
|
+
const allParentNodes = Object.values(parentDataRef.current || {}).flatMap(
|
|
19630
19630
|
(fileData) => fileData.nodes
|
|
19631
19631
|
);
|
|
19632
19632
|
const allAncestries = ancestryDataRef.current || [];
|
|
@@ -20091,7 +20091,7 @@ function XViewScene({
|
|
|
20091
20091
|
}, []);
|
|
20092
20092
|
const allAvailableNodes = useMemo14(() => {
|
|
20093
20093
|
if (!parentDataRef.current) return [];
|
|
20094
|
-
return Object.values(parentDataRef.current).flatMap(
|
|
20094
|
+
return Object.values(parentDataRef.current || {}).flatMap(
|
|
20095
20095
|
(fileData) => fileData.nodes || []
|
|
20096
20096
|
);
|
|
20097
20097
|
}, [sceneVersion, isInitialized]);
|
|
@@ -20180,7 +20180,7 @@ function XViewScene({
|
|
|
20180
20180
|
if (!parentDataRef.current) {
|
|
20181
20181
|
return [];
|
|
20182
20182
|
}
|
|
20183
|
-
const allTypes = Object.values(parentDataRef.current).flatMap(
|
|
20183
|
+
const allTypes = Object.values(parentDataRef.current || {}).flatMap(
|
|
20184
20184
|
(fileData) => fileData.nodes.flatMap((node) => {
|
|
20185
20185
|
if (Array.isArray(node.type)) return node.type;
|
|
20186
20186
|
return [node.type];
|
|
@@ -20254,7 +20254,7 @@ function XViewScene({
|
|
|
20254
20254
|
return;
|
|
20255
20255
|
}
|
|
20256
20256
|
if (!save_view_data) return;
|
|
20257
|
-
const currentNodes = Object.values(nodeObjects).map((mesh) => {
|
|
20257
|
+
const currentNodes = Object.values(nodeObjects || {}).map((mesh) => {
|
|
20258
20258
|
const {
|
|
20259
20259
|
_baseEmissiveIntensity,
|
|
20260
20260
|
labelObject,
|
|
@@ -20416,7 +20416,7 @@ function XViewScene({
|
|
|
20416
20416
|
} = stateRef.current;
|
|
20417
20417
|
if (graphGroup) {
|
|
20418
20418
|
let ghostPosition = sceneControls.target.clone();
|
|
20419
|
-
const existingNodes = Object.values(nodeObjects);
|
|
20419
|
+
const existingNodes = Object.values(nodeObjects || {});
|
|
20420
20420
|
let isOccupied = true;
|
|
20421
20421
|
let radius = 18;
|
|
20422
20422
|
let angle = 0;
|
|
@@ -21159,20 +21159,35 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21159
21159
|
if (!session || !session.user) {
|
|
21160
21160
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
21161
21161
|
}
|
|
21162
|
-
const membershipCheck = await db_services.check_membership(
|
|
21162
|
+
const membershipCheck = await db_services.check_membership(
|
|
21163
|
+
owner_id,
|
|
21164
|
+
type,
|
|
21165
|
+
scene_config,
|
|
21166
|
+
session.user.id
|
|
21167
|
+
);
|
|
21163
21168
|
const isFullMember = membershipCheck.success && membershipCheck.isValidMember;
|
|
21164
21169
|
if (!isFullMember && !focusNodeId && !focusAncestryId) {
|
|
21165
|
-
return {
|
|
21170
|
+
return {
|
|
21171
|
+
success: false,
|
|
21172
|
+
error: "Acesso Negado: Voc\xEA n\xE3o possui permiss\xE3o para acessar este cen\xE1rio."
|
|
21173
|
+
};
|
|
21166
21174
|
}
|
|
21167
|
-
const sceneResponse = await db_services.get_file(
|
|
21175
|
+
const sceneResponse = await db_services.get_file(
|
|
21176
|
+
`x_view_scenes/${owner_id}/${scene_config}`
|
|
21177
|
+
);
|
|
21168
21178
|
if (!sceneResponse || !sceneResponse.success) {
|
|
21169
21179
|
console.error("Falha ao buscar dados da cena:", sceneResponse == null ? void 0 : sceneResponse.error);
|
|
21170
|
-
return {
|
|
21180
|
+
return {
|
|
21181
|
+
success: false,
|
|
21182
|
+
error: `N\xE3o foi poss\xEDvel carregar o arquivo da cena: ${scene_config}`
|
|
21183
|
+
};
|
|
21171
21184
|
}
|
|
21172
21185
|
const sceneData = sceneResponse.data;
|
|
21173
21186
|
const parentDbObjects = sceneData.parent_dbs || [];
|
|
21174
21187
|
if (type && type.toLowerCase().includes("database")) {
|
|
21175
|
-
const selfExists = parentDbObjects.some(
|
|
21188
|
+
const selfExists = parentDbObjects.some(
|
|
21189
|
+
(db) => String(db.db_id) === String(scene_config)
|
|
21190
|
+
);
|
|
21176
21191
|
if (!selfExists) {
|
|
21177
21192
|
parentDbObjects.push({ db_id: scene_config, owner_id });
|
|
21178
21193
|
}
|
|
@@ -21181,13 +21196,18 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21181
21196
|
const parentResponsesPromises = parentDbObjects.map(
|
|
21182
21197
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21183
21198
|
);
|
|
21184
|
-
const parentResponsesResults = await Promise.allSettled(
|
|
21199
|
+
const parentResponsesResults = await Promise.allSettled(
|
|
21200
|
+
parentResponsesPromises
|
|
21201
|
+
);
|
|
21185
21202
|
const parentData = {};
|
|
21186
21203
|
let currentQuestNodes = [];
|
|
21187
21204
|
let currentQuestLinks = [];
|
|
21188
21205
|
let currentMilestones = [];
|
|
21189
21206
|
if (isView) {
|
|
21190
|
-
const firestoreQuestsRes = await db_services.get_view_quests_and_links(
|
|
21207
|
+
const firestoreQuestsRes = await db_services.get_view_quests_and_links(
|
|
21208
|
+
owner_id,
|
|
21209
|
+
scene_config
|
|
21210
|
+
);
|
|
21191
21211
|
const isMigrated = sceneData.quests_migrated === true;
|
|
21192
21212
|
if (firestoreQuestsRes.success && (firestoreQuestsRes.data.nodes.length > 0 || isMigrated)) {
|
|
21193
21213
|
currentQuestNodes = firestoreQuestsRes.data.nodes;
|
|
@@ -21195,14 +21215,20 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21195
21215
|
currentMilestones = sceneData.milestones || [];
|
|
21196
21216
|
} else {
|
|
21197
21217
|
console.log(`Iniciando Lazy Migration para View ${scene_config}...`);
|
|
21198
|
-
const legacyQuestsRes = await db_services.get_file(
|
|
21218
|
+
const legacyQuestsRes = await db_services.get_file(
|
|
21219
|
+
`x_view_quests/${owner_id}/${scene_config}`
|
|
21220
|
+
);
|
|
21199
21221
|
if (legacyQuestsRes.success && legacyQuestsRes.data) {
|
|
21200
21222
|
const legacyData = legacyQuestsRes.data;
|
|
21201
21223
|
currentQuestNodes = legacyData.nodes || [];
|
|
21202
21224
|
currentQuestLinks = legacyData.links || [];
|
|
21203
21225
|
currentMilestones = legacyData.milestones || [];
|
|
21204
21226
|
sceneData.milestones = currentMilestones;
|
|
21205
|
-
await db_services.migrate_legacy_quests(
|
|
21227
|
+
await db_services.migrate_legacy_quests(
|
|
21228
|
+
owner_id,
|
|
21229
|
+
scene_config,
|
|
21230
|
+
legacyData
|
|
21231
|
+
);
|
|
21206
21232
|
}
|
|
21207
21233
|
}
|
|
21208
21234
|
}
|
|
@@ -21225,15 +21251,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21225
21251
|
links: currentQuestLinks
|
|
21226
21252
|
};
|
|
21227
21253
|
}
|
|
21228
|
-
const allNodes = Object.values(parentData).flatMap((db) => db.nodes || []);
|
|
21229
|
-
const allLinks = Object.values(parentData).flatMap((db) => db.links || []);
|
|
21230
|
-
const parentNodeMap = new Map(
|
|
21231
|
-
|
|
21254
|
+
const allNodes = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.nodes) || []);
|
|
21255
|
+
const allLinks = Object.values(parentData).flatMap((db) => (db == null ? void 0 : db.links) || []);
|
|
21256
|
+
const parentNodeMap = new Map(
|
|
21257
|
+
allNodes.map((node) => [String(node.id), node])
|
|
21258
|
+
);
|
|
21259
|
+
const parentLinkMap = new Map(
|
|
21260
|
+
allLinks.map((link) => [`${link.source}-${link.target}`, link])
|
|
21261
|
+
);
|
|
21232
21262
|
const validatedNodes = (sceneData.nodes || []).map((sceneNode) => {
|
|
21233
21263
|
var _a2, _b2;
|
|
21234
21264
|
const nodeTypes = Array.isArray(sceneNode.type) ? sceneNode.type : [sceneNode.type];
|
|
21235
21265
|
if (nodeTypes.includes("quest")) {
|
|
21236
|
-
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21266
|
+
const dbQuestNode = (_b2 = (_a2 = parentData[scene_config]) == null ? void 0 : _a2.nodes) == null ? void 0 : _b2.find(
|
|
21267
|
+
(qn) => String(qn.id) === String(sceneNode.id)
|
|
21268
|
+
);
|
|
21237
21269
|
if (dbQuestNode) {
|
|
21238
21270
|
return { ...sceneNode, ...dbQuestNode };
|
|
21239
21271
|
}
|
|
@@ -21245,17 +21277,23 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21245
21277
|
}
|
|
21246
21278
|
return null;
|
|
21247
21279
|
}).filter(Boolean);
|
|
21248
|
-
const validNodeIdsInScene = new Set(
|
|
21280
|
+
const validNodeIdsInScene = new Set(
|
|
21281
|
+
validatedNodes.map((node) => String(node.id))
|
|
21282
|
+
);
|
|
21249
21283
|
const validatedLinks = (sceneData.links || []).filter((sceneLink) => {
|
|
21250
|
-
const linkExistsInParent = parentLinkMap.has(
|
|
21284
|
+
const linkExistsInParent = parentLinkMap.has(
|
|
21285
|
+
`${sceneLink.source}-${sceneLink.target}`
|
|
21286
|
+
);
|
|
21251
21287
|
const nodesAreValidForScene = validNodeIdsInScene.has(String(sceneLink.source)) && validNodeIdsInScene.has(String(sceneLink.target));
|
|
21252
21288
|
return linkExistsInParent && nodesAreValidForScene;
|
|
21253
|
-
}).map(
|
|
21289
|
+
}).map(
|
|
21290
|
+
(sceneLink) => parentLinkMap.get(`${sceneLink.source}-${sceneLink.target}`)
|
|
21291
|
+
);
|
|
21254
21292
|
const validatedSceneData = {
|
|
21255
21293
|
...sceneData,
|
|
21256
21294
|
nodes: validatedNodes,
|
|
21257
21295
|
links: validatedLinks,
|
|
21258
|
-
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21296
|
+
// Re-injetando no validated para que o restante do sistema (e.g. XViewScene local state)
|
|
21259
21297
|
// continue acessando as quests sem perceber a separação física
|
|
21260
21298
|
quest_nodes: currentQuestNodes,
|
|
21261
21299
|
quest_links: currentQuestLinks,
|
|
@@ -21276,7 +21314,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21276
21314
|
isSceneFile: false
|
|
21277
21315
|
});
|
|
21278
21316
|
});
|
|
21279
|
-
const ancestryPromises = ancestryFilePaths.map(
|
|
21317
|
+
const ancestryPromises = ancestryFilePaths.map(
|
|
21318
|
+
(file) => db_services.get_file(file.path)
|
|
21319
|
+
);
|
|
21280
21320
|
const ancestryResults = await Promise.allSettled(ancestryPromises);
|
|
21281
21321
|
const ancestriesFromSceneFile = [];
|
|
21282
21322
|
const ancestriesFromDbFiles = [];
|
|
@@ -21302,15 +21342,21 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21302
21342
|
}
|
|
21303
21343
|
});
|
|
21304
21344
|
const ancestryMap = /* @__PURE__ */ new Map();
|
|
21305
|
-
ancestriesFromDbFiles.forEach(
|
|
21306
|
-
|
|
21345
|
+
ancestriesFromDbFiles.forEach(
|
|
21346
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21347
|
+
);
|
|
21348
|
+
ancestriesFromSceneFile.forEach(
|
|
21349
|
+
(anc) => ancestryMap.set(anc.ancestry_id, anc)
|
|
21350
|
+
);
|
|
21307
21351
|
let ancestryData = Array.from(ancestryMap.values());
|
|
21308
21352
|
const externalSourcesToRefresh = /* @__PURE__ */ new Map();
|
|
21309
21353
|
ancestryData.forEach((anc) => {
|
|
21310
21354
|
const targetSourceId = anc._source_file_id || anc._imported_from_view_id;
|
|
21311
21355
|
const targetOwnerId = anc._source_owner_id || anc._imported_from_view_owner_id;
|
|
21312
21356
|
if (targetSourceId && targetSourceId !== scene_config && targetOwnerId) {
|
|
21313
|
-
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21357
|
+
const isAlreadyLoadedAsParent = parentDbObjects.some(
|
|
21358
|
+
(db) => String(db.db_id) === String(targetSourceId)
|
|
21359
|
+
);
|
|
21314
21360
|
if (!isAlreadyLoadedAsParent) {
|
|
21315
21361
|
const key = `${targetOwnerId}/${targetSourceId}`;
|
|
21316
21362
|
externalSourcesToRefresh.set(key, {
|
|
@@ -21351,12 +21397,16 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21351
21397
|
return false;
|
|
21352
21398
|
}
|
|
21353
21399
|
if (externalSourcesToRefresh.has(key) && successfullyFetchedSources.has(key)) {
|
|
21354
|
-
const stillExists = freshAncestryMap.has(
|
|
21400
|
+
const stillExists = freshAncestryMap.has(
|
|
21401
|
+
String(localAnc.ancestry_id)
|
|
21402
|
+
);
|
|
21355
21403
|
return stillExists;
|
|
21356
21404
|
}
|
|
21357
21405
|
return true;
|
|
21358
21406
|
}).map((localAnc) => {
|
|
21359
|
-
const freshVersion = freshAncestryMap.get(
|
|
21407
|
+
const freshVersion = freshAncestryMap.get(
|
|
21408
|
+
String(localAnc.ancestry_id)
|
|
21409
|
+
);
|
|
21360
21410
|
if (freshVersion) {
|
|
21361
21411
|
return {
|
|
21362
21412
|
...freshVersion,
|
|
@@ -21395,7 +21445,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21395
21445
|
parallel_branches: validBranches
|
|
21396
21446
|
};
|
|
21397
21447
|
};
|
|
21398
|
-
const originalAncestryDataString = JSON.stringify(
|
|
21448
|
+
const originalAncestryDataString = JSON.stringify(
|
|
21449
|
+
Array.from(ancestryMap.values())
|
|
21450
|
+
);
|
|
21399
21451
|
const cleanedAncestryData = ancestryData.map((ancestry) => {
|
|
21400
21452
|
if (!parentNodeIds.has(String(ancestry.ancestral_node))) return null;
|
|
21401
21453
|
const cleanedTree = pruneTree(ancestry.tree);
|
|
@@ -21415,7 +21467,10 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21415
21467
|
try {
|
|
21416
21468
|
await db_services.save_file(ancestryFilePath, ancestryData);
|
|
21417
21469
|
} catch (saveError) {
|
|
21418
|
-
console.error(
|
|
21470
|
+
console.error(
|
|
21471
|
+
"Falha ao salvar o arquivo de ancestralidade da cena atualizado:",
|
|
21472
|
+
saveError
|
|
21473
|
+
);
|
|
21419
21474
|
}
|
|
21420
21475
|
}
|
|
21421
21476
|
if (!isFullMember) {
|
|
@@ -21423,7 +21478,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21423
21478
|
const requiredAncestryIds = /* @__PURE__ */ new Set();
|
|
21424
21479
|
if (focusNodeId) requiredNodeIds.add(String(focusNodeId));
|
|
21425
21480
|
if (focusAncestryId) requiredAncestryIds.add(String(focusAncestryId));
|
|
21426
|
-
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21481
|
+
const allNodesFromDb = Object.values(parentData).flatMap(
|
|
21482
|
+
(db) => db.nodes || []
|
|
21483
|
+
);
|
|
21427
21484
|
const extractDependenciesFromText = (text) => {
|
|
21428
21485
|
if (!text) return;
|
|
21429
21486
|
const mentionRegex = /\[\[MENTION:node:([a-zA-Z0-9\-_]+)\]\]/g;
|
|
@@ -21450,9 +21507,12 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21450
21507
|
if (branch.linked_ancestry_id) {
|
|
21451
21508
|
requiredAncestryIds.add(String(branch.linked_ancestry_id));
|
|
21452
21509
|
}
|
|
21453
|
-
if (branch.description)
|
|
21510
|
+
if (branch.description)
|
|
21511
|
+
extractDependenciesFromText(branch.description);
|
|
21454
21512
|
if (branch.description_sections) {
|
|
21455
|
-
branch.description_sections.forEach(
|
|
21513
|
+
branch.description_sections.forEach(
|
|
21514
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21515
|
+
);
|
|
21456
21516
|
}
|
|
21457
21517
|
extractTreeDependencies(branch.tree);
|
|
21458
21518
|
});
|
|
@@ -21466,7 +21526,9 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21466
21526
|
if (anc && !anc.is_private) {
|
|
21467
21527
|
if (anc.description) extractDependenciesFromText(anc.description);
|
|
21468
21528
|
if (anc.description_sections) {
|
|
21469
|
-
anc.description_sections.forEach(
|
|
21529
|
+
anc.description_sections.forEach(
|
|
21530
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21531
|
+
);
|
|
21470
21532
|
}
|
|
21471
21533
|
extractTreeDependencies(anc.tree);
|
|
21472
21534
|
extractTreeDependencies(anc.abstraction_tree);
|
|
@@ -21477,22 +21539,38 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21477
21539
|
if (node) {
|
|
21478
21540
|
if (node.description) extractDependenciesFromText(node.description);
|
|
21479
21541
|
if (node.description_sections) {
|
|
21480
|
-
node.description_sections.forEach(
|
|
21542
|
+
node.description_sections.forEach(
|
|
21543
|
+
(s) => extractDependenciesFromText(s.content)
|
|
21544
|
+
);
|
|
21481
21545
|
}
|
|
21482
21546
|
}
|
|
21483
21547
|
});
|
|
21484
21548
|
} while (requiredNodeIds.size + requiredAncestryIds.size > previousSize);
|
|
21485
|
-
const restrictedSceneData = {
|
|
21549
|
+
const restrictedSceneData = {
|
|
21550
|
+
...validatedSceneData,
|
|
21551
|
+
nodes: [],
|
|
21552
|
+
links: []
|
|
21553
|
+
};
|
|
21486
21554
|
const restrictedParentData = {};
|
|
21487
|
-
const restrictedAncestryData = ancestryData.filter(
|
|
21555
|
+
const restrictedAncestryData = ancestryData.filter(
|
|
21556
|
+
(a) => requiredAncestryIds.has(String(a.ancestry_id)) && !a.is_private
|
|
21557
|
+
);
|
|
21488
21558
|
for (const [dbId, dbContent] of Object.entries(parentData)) {
|
|
21489
|
-
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21559
|
+
const filteredNodes = (dbContent.nodes || []).filter(
|
|
21560
|
+
(n) => requiredNodeIds.has(String(n.id))
|
|
21561
|
+
);
|
|
21490
21562
|
if (filteredNodes.length > 0) {
|
|
21491
|
-
restrictedParentData[dbId] = {
|
|
21563
|
+
restrictedParentData[dbId] = {
|
|
21564
|
+
...dbContent,
|
|
21565
|
+
nodes: filteredNodes,
|
|
21566
|
+
links: []
|
|
21567
|
+
};
|
|
21492
21568
|
}
|
|
21493
21569
|
}
|
|
21494
21570
|
if (focusNodeId) {
|
|
21495
|
-
const mainNode = allNodesFromDb.find(
|
|
21571
|
+
const mainNode = allNodesFromDb.find(
|
|
21572
|
+
(n) => String(n.id) === String(focusNodeId)
|
|
21573
|
+
);
|
|
21496
21574
|
if (mainNode) {
|
|
21497
21575
|
restrictedSceneData.nodes = [mainNode];
|
|
21498
21576
|
}
|
|
@@ -21508,7 +21586,11 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21508
21586
|
}
|
|
21509
21587
|
return {
|
|
21510
21588
|
success: true,
|
|
21511
|
-
data: {
|
|
21589
|
+
data: {
|
|
21590
|
+
scene: validatedSceneData,
|
|
21591
|
+
parent: parentData,
|
|
21592
|
+
ancestry: ancestryData
|
|
21593
|
+
}
|
|
21512
21594
|
};
|
|
21513
21595
|
} catch (error) {
|
|
21514
21596
|
console.error("Erro em get_scene_view_data_logic:", error);
|
|
@@ -21528,13 +21610,18 @@ async function import_parent_file_modal_get_logic(db_services, session) {
|
|
|
21528
21610
|
}
|
|
21529
21611
|
};
|
|
21530
21612
|
} catch (error) {
|
|
21531
|
-
console.error(
|
|
21613
|
+
console.error(
|
|
21614
|
+
"catch (error) em import_parent_file_modal_get_logic:",
|
|
21615
|
+
error
|
|
21616
|
+
);
|
|
21532
21617
|
return { success: false, error: error.message };
|
|
21533
21618
|
}
|
|
21534
21619
|
}
|
|
21535
21620
|
async function get_single_parent_file_logic(db_services, file_id, session) {
|
|
21536
21621
|
try {
|
|
21537
|
-
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21622
|
+
const call_GCP_cloud_storage_get_file = await db_services.get_file(
|
|
21623
|
+
`x_view_dbs/${session.user.id}/${file_id}`
|
|
21624
|
+
);
|
|
21538
21625
|
return call_GCP_cloud_storage_get_file;
|
|
21539
21626
|
} catch (error) {
|
|
21540
21627
|
console.error("catch (error) em get_single_parent_file_logic:", error);
|
|
@@ -21568,7 +21655,13 @@ async function get_ancestry_file_logic(db_services, file_id, owner_id) {
|
|
|
21568
21655
|
async function save_boards_logic(db_services, scene_id, type, boardItems, session, owner_id) {
|
|
21569
21656
|
try {
|
|
21570
21657
|
const targetOwnerId = owner_id || session.user.id;
|
|
21571
|
-
return await db_services.save_boards(
|
|
21658
|
+
return await db_services.save_boards(
|
|
21659
|
+
session,
|
|
21660
|
+
scene_id,
|
|
21661
|
+
type,
|
|
21662
|
+
boardItems,
|
|
21663
|
+
targetOwnerId
|
|
21664
|
+
);
|
|
21572
21665
|
} catch (error) {
|
|
21573
21666
|
console.error("Erro em save_boards_logic:", error);
|
|
21574
21667
|
return { success: false, error: error.message };
|
|
@@ -21597,7 +21690,10 @@ async function delete_uploaded_file_logic(db_services, fileUrl) {
|
|
|
21597
21690
|
async function get_view_members_logic(db_services, ownerId, type, itemId) {
|
|
21598
21691
|
try {
|
|
21599
21692
|
if (!db_services.get_view_members) {
|
|
21600
|
-
return {
|
|
21693
|
+
return {
|
|
21694
|
+
success: false,
|
|
21695
|
+
error: "Servi\xE7o de busca de membros n\xE3o configurado."
|
|
21696
|
+
};
|
|
21601
21697
|
}
|
|
21602
21698
|
return await db_services.get_view_members(ownerId, type, itemId);
|
|
21603
21699
|
} catch (error) {
|
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.
|
|
3
|
+
"version": "1.2.8-dev.7",
|
|
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",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"react-colorful": "^5.6.1",
|
|
53
53
|
"uuid": "^13.0.0"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|