coursecode 0.1.1 → 0.1.2

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.
@@ -130,18 +130,17 @@ The ZIP never includes preview/stub player assets. Preview is a separate concern
130
130
 
131
131
  #### Re-Stamping for Different Formats
132
132
 
133
- `lib/build-packaging.js` exports `stampFormatInHtml(htmlPath, format)` for re-stamping the meta tag:
133
+ `lib/build-packaging.js` exports `stampFormat(html, format)` for re-stamping the meta tag:
134
134
 
135
135
  ```javascript
136
- import { stampFormatInHtml } from 'coursecode/build-packaging';
136
+ import { stampFormat } from 'coursecode/build-packaging';
137
137
  import { generateManifest } from 'coursecode/manifest';
138
138
 
139
- // Re-stamp dist/index.html for a different format
140
- stampFormatInHtml('/path/to/dist/index.html', 'scorm2004');
139
+ // Re-stamp HTML string for a different format (no filesystem needed)
140
+ const stampedHtml = stampFormat(indexHtml, 'scorm2004');
141
141
 
142
142
  // Generate the format-specific manifest
143
143
  const { filename, content } = generateManifest('scorm2004', config, files, options);
144
- fs.writeFileSync(`/path/to/dist/${filename}`, content);
145
144
  ```
146
145
 
147
146
  Both are pure Node utilities
@@ -152,7 +151,7 @@ Both are pure Node utilities
152
151
  |------|---------|
153
152
  | `framework/js/state/lms-connection.js` | `getLMSFormat()` — runtime priority chain (meta → env → default) |
154
153
  | `framework/js/drivers/driver-factory.js` | Dynamic `import()` switch — loads one driver at runtime |
155
- | `lib/build-packaging.js` | `stampFormatInHtml()` — meta tag re-stamping utility |
154
+ | `lib/build-packaging.js` | `stampFormat()` — pure string meta tag re-stamping; `stampFormatInHtml()` — file-based wrapper |
156
155
  | `lib/manifest/manifest-factory.js` | `generateManifest()` — generates format-specific manifests |
157
156
  | Both `vite.config.js` files | Post-build `closeBundle` hook stamps meta tag into `dist/index.html` |
158
157
 
@@ -586,7 +585,7 @@ User: coursecode build → uploads dist/
586
585
  └────────────┘
587
586
  ```
588
587
 
589
- **Cloud dependencies:** The cloud app imports `stampFormatInHtml` and `generateManifest` directly from the `coursecode` npm package. These are pure Node utilities — no Vite, no dynamic imports of user code, no `eval`. All inputs (title, version, file list) come from scanning the uploaded `dist/` or the cloud's own database.
588
+ **Cloud dependencies:** The cloud app imports `stampFormat` and `generateManifest` directly from the `coursecode` npm package. These are pure functions — no filesystem, no Vite, no dynamic imports of user code, no `eval`. All inputs (title, version, file list) come from scanning the uploaded `dist/` or the cloud's own database.
590
589
 
591
590
  **Security boundary:** The cloud never executes `course-config.js` or any user-authored JavaScript. The meta tag and manifest are the only format-specific artifacts, and both are generated from trusted framework source code.
592
591
  ---
@@ -1,3 +1,4 @@
1
+ export function stampFormat(html: string, format: string): string
1
2
  export function stampFormatInHtml(htmlPath: string, format: string): void
2
3
 
3
4
  export function validateExternalHostingConfig(config: Record<string, unknown>): void
@@ -61,24 +61,31 @@ export function validateExternalHostingConfig(config) {
61
61
  }
62
62
 
63
63
  /**
64
- * Re-stamp the lms-format meta tag in an index.html file.
65
- * Used when creating format-specific ZIPs from a universal dist/.
66
- * @param {string} htmlPath - Absolute path to the index.html to modify
64
+ * Re-stamp the lms-format meta tag in an HTML string.
65
+ * Pure string transform no filesystem access. Use this in cloud/serverless environments.
66
+ * @param {string} html - The HTML string to modify
67
67
  * @param {string} format - The LMS format to stamp (e.g., 'scorm2004', 'cmi5')
68
+ * @returns {string} The modified HTML string
68
69
  */
69
- export function stampFormatInHtml(htmlPath, format) {
70
- let html = fs.readFileSync(htmlPath, 'utf-8');
71
- // Replace existing meta tag or insert after charset
70
+ export function stampFormat(html, format) {
72
71
  const existingMeta = /<meta\s+name="lms-format"\s+content="[^"]*"\s*\/?>/;
73
72
  if (existingMeta.test(html)) {
74
- html = html.replace(existingMeta, `<meta name="lms-format" content="${format}" />`);
75
- } else {
76
- html = html.replace(
77
- '<meta charset="UTF-8" />',
78
- `<meta charset="UTF-8" />\n <meta name="lms-format" content="${format}" />`
79
- );
73
+ return html.replace(existingMeta, `<meta name="lms-format" content="${format}" />`);
80
74
  }
81
- fs.writeFileSync(htmlPath, html, 'utf-8');
75
+ return html.replace(
76
+ '<meta charset="UTF-8" />',
77
+ `<meta charset="UTF-8" />\n <meta name="lms-format" content="${format}" />`
78
+ );
79
+ }
80
+
81
+ /**
82
+ * Re-stamp the lms-format meta tag in an index.html file on disk.
83
+ * @param {string} htmlPath - Absolute path to the index.html to modify
84
+ * @param {string} format - The LMS format to stamp (e.g., 'scorm2004', 'cmi5')
85
+ */
86
+ export function stampFormatInHtml(htmlPath, format) {
87
+ const html = fs.readFileSync(htmlPath, 'utf-8');
88
+ fs.writeFileSync(htmlPath, stampFormat(html, format), 'utf-8');
82
89
  }
83
90
 
84
91
  export async function createStandardPackage({ rootDir, distDir, config, outputDir }) {
package/lib/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export function resolveElementByPath(elements: Record<string, unknown>[], target
25
25
  export function build(options?: Record<string, unknown>): Promise<void>
26
26
 
27
27
  // Build Packaging
28
+ export function stampFormat(html: string, format: string): string
28
29
  export function stampFormatInHtml(htmlPath: string, format: string): void
29
30
  export function validateExternalHostingConfig(config: Record<string, unknown>): void
30
31
  export function createStandardPackage(options: Record<string, unknown>): Promise<string>
package/lib/index.js CHANGED
@@ -24,6 +24,7 @@ export {
24
24
  // Build utilities
25
25
  export { build } from './build.js';
26
26
  export {
27
+ stampFormat,
27
28
  createStandardPackage,
28
29
  createProxyPackage,
29
30
  createRemotePackage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coursecode",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Multi-format course authoring framework with CLI tools (SCORM 2004, SCORM 1.2, cmi5, LTI 1.3)",
5
5
  "type": "module",
6
6
  "bin": {