@patch-adams/core 1.6.0 → 1.6.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.
- package/dist/cli.cjs +99 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +99 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +99 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +99 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -601,7 +601,20 @@ interface CourseStructure {
|
|
|
601
601
|
/** Lessons in the course */
|
|
602
602
|
lessons: CourseStructureLesson[];
|
|
603
603
|
}
|
|
604
|
-
/**
|
|
604
|
+
/** A group of adjacent blocks within a lesson wrapped in a container div */
|
|
605
|
+
interface BlockGroup {
|
|
606
|
+
/** Unique identifier for this group */
|
|
607
|
+
id: string;
|
|
608
|
+
/** Lesson ID this group belongs to */
|
|
609
|
+
lessonId: string;
|
|
610
|
+
/** Ordered list of adjacent block IDs (min 2) */
|
|
611
|
+
blockIds: string[];
|
|
612
|
+
/** Space-separated CSS class names for the wrapper div */
|
|
613
|
+
className: string;
|
|
614
|
+
/** Optional human-readable label for the group */
|
|
615
|
+
label?: string;
|
|
616
|
+
}
|
|
617
|
+
/** User-assigned class mappings at course, lesson, block, and group levels */
|
|
605
618
|
interface CourseClassMappings {
|
|
606
619
|
/** Space-separated class names for the <html> element (course level) */
|
|
607
620
|
course?: string;
|
|
@@ -609,6 +622,8 @@ interface CourseClassMappings {
|
|
|
609
622
|
lessons?: Record<string, string>;
|
|
610
623
|
/** Block ID -> space-separated class names */
|
|
611
624
|
blocks?: Record<string, string>;
|
|
625
|
+
/** Block groups: adjacent blocks wrapped in container divs at runtime */
|
|
626
|
+
blockGroups?: BlockGroup[];
|
|
612
627
|
}
|
|
613
628
|
|
|
614
629
|
/**
|
|
@@ -1285,4 +1300,4 @@ declare class PluginRegistry {
|
|
|
1285
1300
|
*/
|
|
1286
1301
|
declare const pluginRegistry: PluginRegistry;
|
|
1287
1302
|
|
|
1288
|
-
export { type AsyncAssetConfig, AsyncAssetConfigSchema, type AuthoringTool, AuthoringToolDetector, type AuthoringToolInfo, type BlockingAssetConfig, BlockingAssetConfigSchema, type CourseClassMappings, type CourseFingerprint, type CourseMetadata, type CourseStructure, type CourseStructureBlock, type CourseStructureLesson, type CssAfterOptions, type CssBeforeOptions, DEFAULT_LRS_OPTIONS, FormatDetector, type GeneratedPluginAssets, HtmlInjector, type JsAfterOptions, type JsBeforeOptions, type LocalFoldersConfig, LocalFoldersConfigSchema, type LogLevel, Logger, type LrsBridgeConfig, LrsBridgeConfigSchema, type LrsBridgeOptions, type ManifestPaths, ManifestUpdater, type PackageFormat, type PatchAdamsConfig, PatchAdamsConfigSchema, type PatchAdamsPlugin, type PatchOptions, type PatchResult, Patcher, type PluginAssets, type PluginConfig, PluginRegistry, type PluginsConfig, StorylineHtmlInjector, buildCssAfterOptions, buildCssBeforeOptions, buildJsAfterOptions, buildJsBeforeOptions, defaultConfig, extractCourseFingerprint, extractCourseMetadata, extractCourseStructure, generateClassMappingsScript, generateConfigTemplate, generateCssAfterLoader, generateCssBeforeLoader, generateJsAfterLoader, generateJsBeforeLoader, generateLrsBridgeCode, hasClassMappings, loadConfig, mergeWithDefaults, pluginRegistry };
|
|
1303
|
+
export { type AsyncAssetConfig, AsyncAssetConfigSchema, type AuthoringTool, AuthoringToolDetector, type AuthoringToolInfo, type BlockGroup, type BlockingAssetConfig, BlockingAssetConfigSchema, type CourseClassMappings, type CourseFingerprint, type CourseMetadata, type CourseStructure, type CourseStructureBlock, type CourseStructureLesson, type CssAfterOptions, type CssBeforeOptions, DEFAULT_LRS_OPTIONS, FormatDetector, type GeneratedPluginAssets, HtmlInjector, type JsAfterOptions, type JsBeforeOptions, type LocalFoldersConfig, LocalFoldersConfigSchema, type LogLevel, Logger, type LrsBridgeConfig, LrsBridgeConfigSchema, type LrsBridgeOptions, type ManifestPaths, ManifestUpdater, type PackageFormat, type PatchAdamsConfig, PatchAdamsConfigSchema, type PatchAdamsPlugin, type PatchOptions, type PatchResult, Patcher, type PluginAssets, type PluginConfig, PluginRegistry, type PluginsConfig, StorylineHtmlInjector, buildCssAfterOptions, buildCssBeforeOptions, buildJsAfterOptions, buildJsBeforeOptions, defaultConfig, extractCourseFingerprint, extractCourseMetadata, extractCourseStructure, generateClassMappingsScript, generateConfigTemplate, generateCssAfterLoader, generateCssBeforeLoader, generateJsAfterLoader, generateJsBeforeLoader, generateLrsBridgeCode, hasClassMappings, loadConfig, mergeWithDefaults, pluginRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -601,7 +601,20 @@ interface CourseStructure {
|
|
|
601
601
|
/** Lessons in the course */
|
|
602
602
|
lessons: CourseStructureLesson[];
|
|
603
603
|
}
|
|
604
|
-
/**
|
|
604
|
+
/** A group of adjacent blocks within a lesson wrapped in a container div */
|
|
605
|
+
interface BlockGroup {
|
|
606
|
+
/** Unique identifier for this group */
|
|
607
|
+
id: string;
|
|
608
|
+
/** Lesson ID this group belongs to */
|
|
609
|
+
lessonId: string;
|
|
610
|
+
/** Ordered list of adjacent block IDs (min 2) */
|
|
611
|
+
blockIds: string[];
|
|
612
|
+
/** Space-separated CSS class names for the wrapper div */
|
|
613
|
+
className: string;
|
|
614
|
+
/** Optional human-readable label for the group */
|
|
615
|
+
label?: string;
|
|
616
|
+
}
|
|
617
|
+
/** User-assigned class mappings at course, lesson, block, and group levels */
|
|
605
618
|
interface CourseClassMappings {
|
|
606
619
|
/** Space-separated class names for the <html> element (course level) */
|
|
607
620
|
course?: string;
|
|
@@ -609,6 +622,8 @@ interface CourseClassMappings {
|
|
|
609
622
|
lessons?: Record<string, string>;
|
|
610
623
|
/** Block ID -> space-separated class names */
|
|
611
624
|
blocks?: Record<string, string>;
|
|
625
|
+
/** Block groups: adjacent blocks wrapped in container divs at runtime */
|
|
626
|
+
blockGroups?: BlockGroup[];
|
|
612
627
|
}
|
|
613
628
|
|
|
614
629
|
/**
|
|
@@ -1285,4 +1300,4 @@ declare class PluginRegistry {
|
|
|
1285
1300
|
*/
|
|
1286
1301
|
declare const pluginRegistry: PluginRegistry;
|
|
1287
1302
|
|
|
1288
|
-
export { type AsyncAssetConfig, AsyncAssetConfigSchema, type AuthoringTool, AuthoringToolDetector, type AuthoringToolInfo, type BlockingAssetConfig, BlockingAssetConfigSchema, type CourseClassMappings, type CourseFingerprint, type CourseMetadata, type CourseStructure, type CourseStructureBlock, type CourseStructureLesson, type CssAfterOptions, type CssBeforeOptions, DEFAULT_LRS_OPTIONS, FormatDetector, type GeneratedPluginAssets, HtmlInjector, type JsAfterOptions, type JsBeforeOptions, type LocalFoldersConfig, LocalFoldersConfigSchema, type LogLevel, Logger, type LrsBridgeConfig, LrsBridgeConfigSchema, type LrsBridgeOptions, type ManifestPaths, ManifestUpdater, type PackageFormat, type PatchAdamsConfig, PatchAdamsConfigSchema, type PatchAdamsPlugin, type PatchOptions, type PatchResult, Patcher, type PluginAssets, type PluginConfig, PluginRegistry, type PluginsConfig, StorylineHtmlInjector, buildCssAfterOptions, buildCssBeforeOptions, buildJsAfterOptions, buildJsBeforeOptions, defaultConfig, extractCourseFingerprint, extractCourseMetadata, extractCourseStructure, generateClassMappingsScript, generateConfigTemplate, generateCssAfterLoader, generateCssBeforeLoader, generateJsAfterLoader, generateJsBeforeLoader, generateLrsBridgeCode, hasClassMappings, loadConfig, mergeWithDefaults, pluginRegistry };
|
|
1303
|
+
export { type AsyncAssetConfig, AsyncAssetConfigSchema, type AuthoringTool, AuthoringToolDetector, type AuthoringToolInfo, type BlockGroup, type BlockingAssetConfig, BlockingAssetConfigSchema, type CourseClassMappings, type CourseFingerprint, type CourseMetadata, type CourseStructure, type CourseStructureBlock, type CourseStructureLesson, type CssAfterOptions, type CssBeforeOptions, DEFAULT_LRS_OPTIONS, FormatDetector, type GeneratedPluginAssets, HtmlInjector, type JsAfterOptions, type JsBeforeOptions, type LocalFoldersConfig, LocalFoldersConfigSchema, type LogLevel, Logger, type LrsBridgeConfig, LrsBridgeConfigSchema, type LrsBridgeOptions, type ManifestPaths, ManifestUpdater, type PackageFormat, type PatchAdamsConfig, PatchAdamsConfigSchema, type PatchAdamsPlugin, type PatchOptions, type PatchResult, Patcher, type PluginAssets, type PluginConfig, PluginRegistry, type PluginsConfig, StorylineHtmlInjector, buildCssAfterOptions, buildCssBeforeOptions, buildJsAfterOptions, buildJsBeforeOptions, defaultConfig, extractCourseFingerprint, extractCourseMetadata, extractCourseStructure, generateClassMappingsScript, generateConfigTemplate, generateCssAfterLoader, generateCssBeforeLoader, generateJsAfterLoader, generateJsBeforeLoader, generateLrsBridgeCode, hasClassMappings, loadConfig, mergeWithDefaults, pluginRegistry };
|
package/dist/index.js
CHANGED
|
@@ -5693,6 +5693,7 @@ function hasClassMappings(mappings) {
|
|
|
5693
5693
|
if (mappings.course?.trim()) return true;
|
|
5694
5694
|
if (mappings.lessons && Object.values(mappings.lessons).some((v) => v?.trim())) return true;
|
|
5695
5695
|
if (mappings.blocks && Object.values(mappings.blocks).some((v) => v?.trim())) return true;
|
|
5696
|
+
if (mappings.blockGroups && mappings.blockGroups.length > 0) return true;
|
|
5696
5697
|
return false;
|
|
5697
5698
|
}
|
|
5698
5699
|
function generateClassMappingsScript(mappings) {
|
|
@@ -5714,6 +5715,10 @@ function generateClassMappingsScript(mappings) {
|
|
|
5714
5715
|
}
|
|
5715
5716
|
const hasBlocks = Object.keys(blockMap).length > 0;
|
|
5716
5717
|
const hasLessons = Object.keys(lessonMap).length > 0;
|
|
5718
|
+
const blockGroups = (mappings.blockGroups || []).filter(
|
|
5719
|
+
(g) => g.blockIds.length >= 2 && g.className.trim() && g.lessonId
|
|
5720
|
+
);
|
|
5721
|
+
const hasGroups = blockGroups.length > 0;
|
|
5717
5722
|
const parts = [];
|
|
5718
5723
|
parts.push(`// PA-Patcher: Custom Class Mappings`);
|
|
5719
5724
|
parts.push(`(function() {`);
|
|
@@ -5779,33 +5784,117 @@ function generateClassMappingsScript(mappings) {
|
|
|
5779
5784
|
parts.push(` }`);
|
|
5780
5785
|
parts.push(``);
|
|
5781
5786
|
}
|
|
5787
|
+
if (hasGroups) {
|
|
5788
|
+
const groupData = blockGroups.map((g) => ({
|
|
5789
|
+
id: g.id,
|
|
5790
|
+
lessonId: g.lessonId,
|
|
5791
|
+
blockIds: g.blockIds,
|
|
5792
|
+
className: g.className.trim()
|
|
5793
|
+
}));
|
|
5794
|
+
parts.push(` // Block groups (adjacent blocks wrapped in container divs)`);
|
|
5795
|
+
parts.push(` var groupMap = ${JSON.stringify(groupData)};`);
|
|
5796
|
+
parts.push(``);
|
|
5797
|
+
parts.push(` function applyBlockGroups() {`);
|
|
5798
|
+
parts.push(` var hash = window.location.hash || '';`);
|
|
5799
|
+
parts.push(` var match = hash.match(/#\\/lessons\\/([^/]+)/);`);
|
|
5800
|
+
parts.push(` var currentLesson = match ? match[1] : null;`);
|
|
5801
|
+
parts.push(` for (var g = 0; g < groupMap.length; g++) {`);
|
|
5802
|
+
parts.push(` var group = groupMap[g];`);
|
|
5803
|
+
parts.push(` if (group.lessonId !== currentLesson) continue;`);
|
|
5804
|
+
parts.push(` if (document.querySelector('[data-pa-group-id="' + group.id + '"]')) continue;`);
|
|
5805
|
+
parts.push(` var blocks = [];`);
|
|
5806
|
+
parts.push(` var allPresent = true;`);
|
|
5807
|
+
parts.push(` for (var b = 0; b < group.blockIds.length; b++) {`);
|
|
5808
|
+
parts.push(` var el = document.querySelector('[data-block-id="' + group.blockIds[b] + '"]');`);
|
|
5809
|
+
parts.push(` if (!el) { allPresent = false; break; }`);
|
|
5810
|
+
parts.push(` blocks.push(el);`);
|
|
5811
|
+
parts.push(` }`);
|
|
5812
|
+
parts.push(` if (!allPresent) continue;`);
|
|
5813
|
+
parts.push(` var parent = blocks[0].parentNode;`);
|
|
5814
|
+
parts.push(` var sameParent = true;`);
|
|
5815
|
+
parts.push(` for (var s = 1; s < blocks.length; s++) {`);
|
|
5816
|
+
parts.push(` if (blocks[s].parentNode !== parent) { sameParent = false; break; }`);
|
|
5817
|
+
parts.push(` }`);
|
|
5818
|
+
parts.push(` if (!sameParent) continue;`);
|
|
5819
|
+
parts.push(` var wrapper = document.createElement('div');`);
|
|
5820
|
+
parts.push(` wrapper.setAttribute('data-pa-group-id', group.id);`);
|
|
5821
|
+
parts.push(` var cls = group.className.split(' ');`);
|
|
5822
|
+
parts.push(` for (var c = 0; c < cls.length; c++) {`);
|
|
5823
|
+
parts.push(` if (cls[c]) wrapper.classList.add(cls[c]);`);
|
|
5824
|
+
parts.push(` }`);
|
|
5825
|
+
parts.push(` parent.insertBefore(wrapper, blocks[0]);`);
|
|
5826
|
+
parts.push(` for (var m = 0; m < blocks.length; m++) {`);
|
|
5827
|
+
parts.push(` wrapper.appendChild(blocks[m]);`);
|
|
5828
|
+
parts.push(` }`);
|
|
5829
|
+
parts.push(` }`);
|
|
5830
|
+
parts.push(` }`);
|
|
5831
|
+
parts.push(``);
|
|
5832
|
+
parts.push(` function teardownBlockGroups() {`);
|
|
5833
|
+
parts.push(` var wrappers = document.querySelectorAll('[data-pa-group-id]');`);
|
|
5834
|
+
parts.push(` for (var w = 0; w < wrappers.length; w++) {`);
|
|
5835
|
+
parts.push(` var wr = wrappers[w];`);
|
|
5836
|
+
parts.push(` var par = wr.parentNode;`);
|
|
5837
|
+
parts.push(` while (wr.firstChild) {`);
|
|
5838
|
+
parts.push(` par.insertBefore(wr.firstChild, wr);`);
|
|
5839
|
+
parts.push(` }`);
|
|
5840
|
+
parts.push(` par.removeChild(wr);`);
|
|
5841
|
+
parts.push(` }`);
|
|
5842
|
+
parts.push(` }`);
|
|
5843
|
+
parts.push(``);
|
|
5844
|
+
}
|
|
5782
5845
|
parts.push(` // Initialization`);
|
|
5783
5846
|
parts.push(` function init() {`);
|
|
5784
5847
|
if (hasBlocks) {
|
|
5785
5848
|
parts.push(` applyBlockClasses();`);
|
|
5786
5849
|
}
|
|
5850
|
+
if (hasGroups) {
|
|
5851
|
+
parts.push(` applyBlockGroups();`);
|
|
5852
|
+
}
|
|
5787
5853
|
if (hasLessons) {
|
|
5788
5854
|
parts.push(` applyLessonClasses();`);
|
|
5855
|
+
}
|
|
5856
|
+
if (hasLessons || hasGroups) {
|
|
5789
5857
|
parts.push(``);
|
|
5790
5858
|
parts.push(` // Watch for Rise SPA navigation`);
|
|
5791
5859
|
parts.push(` window.addEventListener('hashchange', function() {`);
|
|
5792
|
-
|
|
5860
|
+
if (hasGroups) {
|
|
5861
|
+
parts.push(` teardownBlockGroups();`);
|
|
5862
|
+
}
|
|
5863
|
+
if (hasLessons) {
|
|
5864
|
+
parts.push(` applyLessonClasses();`);
|
|
5865
|
+
}
|
|
5793
5866
|
if (hasBlocks) {
|
|
5794
5867
|
parts.push(` setTimeout(applyBlockClasses, 200);`);
|
|
5795
5868
|
}
|
|
5869
|
+
if (hasGroups) {
|
|
5870
|
+
parts.push(` setTimeout(applyBlockGroups, 300);`);
|
|
5871
|
+
}
|
|
5796
5872
|
parts.push(` });`);
|
|
5797
5873
|
}
|
|
5798
|
-
if (hasBlocks) {
|
|
5874
|
+
if (hasBlocks || hasGroups) {
|
|
5799
5875
|
parts.push(``);
|
|
5800
5876
|
parts.push(` // MutationObserver for lazily-rendered Rise blocks`);
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5877
|
+
if (hasGroups) {
|
|
5878
|
+
parts.push(` var debounceTimer = null;`);
|
|
5879
|
+
parts.push(` var observer = new MutationObserver(function() {`);
|
|
5880
|
+
parts.push(` if (debounceTimer) clearTimeout(debounceTimer);`);
|
|
5881
|
+
parts.push(` debounceTimer = setTimeout(function() {`);
|
|
5882
|
+
if (hasBlocks) {
|
|
5883
|
+
parts.push(` applyBlockClasses();`);
|
|
5884
|
+
}
|
|
5885
|
+
parts.push(` applyBlockGroups();`);
|
|
5886
|
+
parts.push(` }, 100);`);
|
|
5887
|
+
parts.push(` });`);
|
|
5888
|
+
} else {
|
|
5889
|
+
parts.push(` var observer = new MutationObserver(function(mutations) {`);
|
|
5890
|
+
parts.push(` for (var i = 0; i < mutations.length; i++) {`);
|
|
5891
|
+
parts.push(` if (mutations[i].addedNodes.length > 0) {`);
|
|
5892
|
+
parts.push(` applyBlockClasses();`);
|
|
5893
|
+
parts.push(` return;`);
|
|
5894
|
+
parts.push(` }`);
|
|
5895
|
+
parts.push(` }`);
|
|
5896
|
+
parts.push(` });`);
|
|
5897
|
+
}
|
|
5809
5898
|
parts.push(` var container = document.querySelector('#app') || document.body;`);
|
|
5810
5899
|
parts.push(` observer.observe(container, { childList: true, subtree: true });`);
|
|
5811
5900
|
}
|