cocos2d-cli 2.1.3 → 2.2.1
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.
|
@@ -116,7 +116,87 @@ export function deleteNode(node) {
|
|
|
116
116
|
return removeFromParent(node);
|
|
117
117
|
}
|
|
118
118
|
export function buildTree(data, scriptMap, startIndex) {
|
|
119
|
-
|
|
119
|
+
const root = data[startIndex];
|
|
120
|
+
if (!root)
|
|
121
|
+
return '';
|
|
122
|
+
if (root.__type__ === 'cc.Prefab') {
|
|
123
|
+
const prefabNode = data[1];
|
|
124
|
+
if (!prefabNode)
|
|
125
|
+
return '';
|
|
126
|
+
const prefabActive = prefabNode._active !== false ? '●' : '○';
|
|
127
|
+
let result = prefabActive + ' ' + (prefabNode._name || 'Root');
|
|
128
|
+
result += buildComponentInfo(data, prefabNode, scriptMap);
|
|
129
|
+
result += '\n';
|
|
130
|
+
if (prefabNode._children && prefabNode._children.length > 0) {
|
|
131
|
+
prefabNode._children.forEach((childRef, idx) => {
|
|
132
|
+
const childIsLast = idx === prefabNode._children.length - 1;
|
|
133
|
+
result += buildTreeNode(data, scriptMap, childRef.__id__, '', childIsLast, false);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
const sceneRoot = root;
|
|
139
|
+
if (sceneRoot.__type__ === 'cc.Scene') {
|
|
140
|
+
let result = '[Scene]\n';
|
|
141
|
+
if (sceneRoot._children && sceneRoot._children.length > 0) {
|
|
142
|
+
sceneRoot._children.forEach((childRef, idx) => {
|
|
143
|
+
const childIsLast = idx === sceneRoot._children.length - 1;
|
|
144
|
+
result += buildTreeNode(data, scriptMap, childRef.__id__, '', childIsLast, false);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
return buildTreeNode(data, scriptMap, startIndex, '', true, true);
|
|
150
|
+
}
|
|
151
|
+
function buildComponentInfo(data, node, scriptMap) {
|
|
152
|
+
if (!node._components || node._components.length === 0)
|
|
153
|
+
return '';
|
|
154
|
+
const uuidRegex = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
155
|
+
const comps = node._components.map((c) => {
|
|
156
|
+
const comp = data[c.__id__];
|
|
157
|
+
if (!comp)
|
|
158
|
+
return '?';
|
|
159
|
+
const typeName = comp.__type__;
|
|
160
|
+
let displayName;
|
|
161
|
+
if (uuidRegex.test(typeName)) {
|
|
162
|
+
const scriptInfo = scriptMap[typeName];
|
|
163
|
+
if (scriptInfo) {
|
|
164
|
+
displayName = scriptInfo;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
displayName = '[MissingScript]';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (typeName === 'MissingScript') {
|
|
171
|
+
displayName = '[MissingScript]';
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
displayName = typeName.replace('cc.', '');
|
|
175
|
+
}
|
|
176
|
+
return displayName;
|
|
177
|
+
}).join(', ');
|
|
178
|
+
return ` (${comps})`;
|
|
179
|
+
}
|
|
180
|
+
function buildTreeNode(data, scriptMap, nodeIndex, prefix = '', isLast = true, isRoot = true) {
|
|
181
|
+
const node = data[nodeIndex];
|
|
182
|
+
if (!node)
|
|
183
|
+
return '';
|
|
184
|
+
const nodeName = node._name || '(unnamed)';
|
|
185
|
+
const active = node._active !== false ? '●' : '○';
|
|
186
|
+
const uuidRegex = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
187
|
+
let result = '';
|
|
188
|
+
const connector = isRoot ? '' : (isLast ? '└── ' : '├── ');
|
|
189
|
+
result = prefix + connector + (isRoot ? '' : active + ' ') + nodeName;
|
|
190
|
+
result += buildComponentInfo(data, node, scriptMap);
|
|
191
|
+
result += '\n';
|
|
192
|
+
if (node._children && node._children.length > 0) {
|
|
193
|
+
const childPrefix = prefix + (isRoot ? '' : (isLast ? ' ' : '│ '));
|
|
194
|
+
node._children.forEach((childRef, idx) => {
|
|
195
|
+
const childIsLast = idx === node._children.length - 1;
|
|
196
|
+
result += buildTreeNode(data, scriptMap, childRef.__id__, childPrefix, childIsLast, false);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
120
200
|
}
|
|
121
201
|
export function detectItemType(item) {
|
|
122
202
|
if (!item)
|
|
@@ -188,9 +188,13 @@ export async function takeScreenshot(userConfig = {}) {
|
|
|
188
188
|
addLog('requestfailed', request.url(), { error: errorText });
|
|
189
189
|
});
|
|
190
190
|
addLog('info', 'Loading Page');
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
const baseUrl = `${serverUrl}/index.html`;
|
|
192
|
+
const searchParams = new URLSearchParams();
|
|
193
|
+
searchParams.set('width', config.viewport.width.toString());
|
|
194
|
+
if (config.debugBounds) {
|
|
195
|
+
searchParams.set('debugBounds', 'true');
|
|
196
|
+
}
|
|
197
|
+
const pageUrl = `${baseUrl}?${searchParams.toString()}`;
|
|
194
198
|
await page.goto(pageUrl, {
|
|
195
199
|
waitUntil: 'networkidle',
|
|
196
200
|
timeout: config.timeout
|