@patch-adams/core 1.4.5 → 1.4.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/cli.cjs +122 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +122 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +122 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +122 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1945,7 +1945,7 @@ function generateLrsBridgeCode(options) {
|
|
|
1945
1945
|
} catch (e) {}
|
|
1946
1946
|
|
|
1947
1947
|
for (var j = 0; j < urlsToCheck.length; j++) {
|
|
1948
|
-
var match = urlsToCheck[j].match(/(https
|
|
1948
|
+
var match = urlsToCheck[j].match(/(https?:\\/\\/core-[a-zA-Z0-9_-]+\\.bravais\\.com)/);
|
|
1949
1949
|
if (match) {
|
|
1950
1950
|
return match[1];
|
|
1951
1951
|
}
|
|
@@ -1995,7 +1995,12 @@ function generateLrsBridgeCode(options) {
|
|
|
1995
1995
|
callback(null);
|
|
1996
1996
|
}
|
|
1997
1997
|
} else {
|
|
1998
|
-
|
|
1998
|
+
// 401/403 is expected - API requires auth that may not be available from iframe
|
|
1999
|
+
if (xhr.status === 401 || xhr.status === 403) {
|
|
2000
|
+
log('Shared link API requires auth (expected), will use fallback');
|
|
2001
|
+
} else {
|
|
2002
|
+
log('Shared link fetch failed. Status:', xhr.status);
|
|
2003
|
+
}
|
|
1999
2004
|
callback(null);
|
|
2000
2005
|
}
|
|
2001
2006
|
}
|
|
@@ -2070,7 +2075,12 @@ function generateLrsBridgeCode(options) {
|
|
|
2070
2075
|
callback(null);
|
|
2071
2076
|
}
|
|
2072
2077
|
} else {
|
|
2073
|
-
|
|
2078
|
+
// 401/403 is expected - API requires auth that may not be available from iframe
|
|
2079
|
+
if (xhr.status === 401 || xhr.status === 403) {
|
|
2080
|
+
log('Document API requires auth (expected), will use fallback');
|
|
2081
|
+
} else {
|
|
2082
|
+
log('Document metadata fetch failed. Status:', xhr.status);
|
|
2083
|
+
}
|
|
2074
2084
|
callback(null);
|
|
2075
2085
|
}
|
|
2076
2086
|
}
|
|
@@ -2233,6 +2243,95 @@ function generateLrsBridgeCode(options) {
|
|
|
2233
2243
|
return null;
|
|
2234
2244
|
}
|
|
2235
2245
|
|
|
2246
|
+
/**
|
|
2247
|
+
* Try to extract document data from Xyleme Cloud Player's internal state
|
|
2248
|
+
* The Cloud Player stores this after fetching /api/shared/{token}/documents
|
|
2249
|
+
*/
|
|
2250
|
+
function extractFromXylemeCloudPlayer() {
|
|
2251
|
+
try {
|
|
2252
|
+
var win = window;
|
|
2253
|
+
for (var level = 0; level < 10; level++) {
|
|
2254
|
+
try {
|
|
2255
|
+
// Check for Xyleme Cloud Player's document data in various locations
|
|
2256
|
+
// The player stores data in multiple places depending on version
|
|
2257
|
+
|
|
2258
|
+
// Check for CdsDataService data
|
|
2259
|
+
if (win._cdsDataService && win._cdsDataService.documentData) {
|
|
2260
|
+
var docData = win._cdsDataService.documentData;
|
|
2261
|
+
log('Found document data in _cdsDataService at level', level);
|
|
2262
|
+
return extractGuidsFromDocumentData(docData);
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// Check for window.documentData
|
|
2266
|
+
if (win.documentData && win.documentData.guid) {
|
|
2267
|
+
log('Found document data in window.documentData at level', level);
|
|
2268
|
+
return extractGuidsFromDocumentData(win.documentData);
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
// Check for PlayerIntegration's internal data
|
|
2272
|
+
if (win.playerIntegration && win.playerIntegration._documentData) {
|
|
2273
|
+
log('Found document data in playerIntegration at level', level);
|
|
2274
|
+
return extractGuidsFromDocumentData(win.playerIntegration._documentData);
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
// Check for __xyleme_data
|
|
2278
|
+
if (win.__xyleme_data && win.__xyleme_data.document) {
|
|
2279
|
+
log('Found document data in __xyleme_data at level', level);
|
|
2280
|
+
return extractGuidsFromDocumentData(win.__xyleme_data.document);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
// Check for documentVersionData which has the versionGuid
|
|
2284
|
+
if (win.documentVersionData) {
|
|
2285
|
+
log('Found documentVersionData at level', level);
|
|
2286
|
+
return {
|
|
2287
|
+
versionGuid: win.documentVersionData.guid || win.documentVersionData.versionGuid,
|
|
2288
|
+
documentId: win.documentVersionData.documentId
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
} catch (e) {}
|
|
2293
|
+
|
|
2294
|
+
if (win.parent && win.parent !== win) {
|
|
2295
|
+
win = win.parent;
|
|
2296
|
+
} else {
|
|
2297
|
+
break;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
} catch (e) {}
|
|
2301
|
+
return null;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
function extractGuidsFromDocumentData(data) {
|
|
2305
|
+
if (!data) return null;
|
|
2306
|
+
|
|
2307
|
+
var result = {};
|
|
2308
|
+
|
|
2309
|
+
// Document GUID
|
|
2310
|
+
if (data.guid) result.guid = data.guid;
|
|
2311
|
+
if (data.documentGuid) result.guid = data.documentGuid;
|
|
2312
|
+
|
|
2313
|
+
// Version GUID - usually in latestVersion or currentVersion
|
|
2314
|
+
if (data.latestVersion && data.latestVersion.guid) {
|
|
2315
|
+
result.versionGuid = data.latestVersion.guid;
|
|
2316
|
+
}
|
|
2317
|
+
if (data.currentVersion && data.currentVersion.guid) {
|
|
2318
|
+
result.versionGuid = data.currentVersion.guid;
|
|
2319
|
+
}
|
|
2320
|
+
if (data.versionGuid) result.versionGuid = data.versionGuid;
|
|
2321
|
+
|
|
2322
|
+
// Numeric IDs
|
|
2323
|
+
if (data.id) result.documentId = data.id;
|
|
2324
|
+
if (data.documentId) result.documentId = data.documentId;
|
|
2325
|
+
if (data.cdsId) result.documentId = data.cdsId;
|
|
2326
|
+
|
|
2327
|
+
// Title
|
|
2328
|
+
if (data.name) result.title = data.name;
|
|
2329
|
+
if (data.title) result.title = data.title;
|
|
2330
|
+
|
|
2331
|
+
log('Extracted GUIDs from Cloud Player:', result);
|
|
2332
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2236
2335
|
function extractCourseInfo() {
|
|
2237
2336
|
var info = {
|
|
2238
2337
|
// Xyleme IRI format: http://xyleme.com/bravais/document/{guid}
|
|
@@ -2288,6 +2387,23 @@ function generateLrsBridgeCode(options) {
|
|
|
2288
2387
|
info.sharedLinkName = launchInfo.sharedLinkName || info.sharedLinkName;
|
|
2289
2388
|
}
|
|
2290
2389
|
|
|
2390
|
+
// 3b. Try to extract GUIDs from Xyleme Cloud Player's internal data
|
|
2391
|
+
// This is more reliable than API calls which may fail with 401
|
|
2392
|
+
if (!info.guid || !info.versionGuid) {
|
|
2393
|
+
var cloudPlayerData = extractFromXylemeCloudPlayer();
|
|
2394
|
+
if (cloudPlayerData) {
|
|
2395
|
+
info.guid = cloudPlayerData.guid || info.guid;
|
|
2396
|
+
info.versionGuid = cloudPlayerData.versionGuid || info.versionGuid;
|
|
2397
|
+
info.documentId = cloudPlayerData.documentId || info.documentId;
|
|
2398
|
+
info.title = cloudPlayerData.title || info.title;
|
|
2399
|
+
log('Updated course info from Cloud Player:', {
|
|
2400
|
+
guid: info.guid,
|
|
2401
|
+
versionGuid: info.versionGuid,
|
|
2402
|
+
documentId: info.documentId
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2291
2407
|
// 4. Try getCourseTitle() from preloadIntegrity.js
|
|
2292
2408
|
var preloadTitle = extractCourseTitleFromPreload();
|
|
2293
2409
|
if (preloadTitle) {
|
|
@@ -2461,14 +2577,14 @@ function generateLrsBridgeCode(options) {
|
|
|
2461
2577
|
|
|
2462
2578
|
// 5. Clean up - remove any "Home" or generic names if we're on a real lesson
|
|
2463
2579
|
if (lessonInfo.name) {
|
|
2464
|
-
lessonInfo.name = lessonInfo.name.replace(
|
|
2580
|
+
lessonInfo.name = lessonInfo.name.replace(/^\\\\d+\\\\.\\\\s*/, ''); // Remove leading numbers "1. "
|
|
2465
2581
|
if (lessonInfo.name.length > 200) {
|
|
2466
2582
|
lessonInfo.name = lessonInfo.name.substring(0, 200) + '...';
|
|
2467
2583
|
}
|
|
2468
2584
|
}
|
|
2469
2585
|
|
|
2470
2586
|
if (lessonInfo.sectionName) {
|
|
2471
|
-
lessonInfo.sectionName = lessonInfo.sectionName.replace(
|
|
2587
|
+
lessonInfo.sectionName = lessonInfo.sectionName.replace(/^\\\\d+\\\\.\\\\s*/, '');
|
|
2472
2588
|
if (lessonInfo.sectionName.length > 200) {
|
|
2473
2589
|
lessonInfo.sectionName = lessonInfo.sectionName.substring(0, 200) + '...';
|
|
2474
2590
|
}
|
|
@@ -3793,7 +3909,7 @@ function generateLrsBridgeCode(options) {
|
|
|
3793
3909
|
// ========================================================================
|
|
3794
3910
|
|
|
3795
3911
|
function init() {
|
|
3796
|
-
log('Initializing LRS bridge v2.
|
|
3912
|
+
log('Initializing LRS bridge v2.6.0...');
|
|
3797
3913
|
|
|
3798
3914
|
// Extract course info early
|
|
3799
3915
|
extractCourseInfo();
|