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.
- package/framework/docs/FRAMEWORK_GUIDE.md +6 -7
- package/lib/build-packaging.d.ts +1 -0
- package/lib/build-packaging.js +20 -13
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
|
@@ -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 `
|
|
133
|
+
`lib/build-packaging.js` exports `stampFormat(html, format)` for re-stamping the meta tag:
|
|
134
134
|
|
|
135
135
|
```javascript
|
|
136
|
-
import {
|
|
136
|
+
import { stampFormat } from 'coursecode/build-packaging';
|
|
137
137
|
import { generateManifest } from 'coursecode/manifest';
|
|
138
138
|
|
|
139
|
-
// Re-stamp
|
|
140
|
-
|
|
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` | `
|
|
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 `
|
|
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
|
---
|
package/lib/build-packaging.d.ts
CHANGED
package/lib/build-packaging.js
CHANGED
|
@@ -61,24 +61,31 @@ export function validateExternalHostingConfig(config) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Re-stamp the lms-format meta tag in an
|
|
65
|
-
*
|
|
66
|
-
* @param {string}
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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