@signalsafe/learning-core 0.1.0 → 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/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # @signalsafe/learning-core
1
+ # learning-core TypeScript
2
2
 
3
- Unpublished 0.1.0 candidate. Public modules are explicit export subpaths; hosts own routing, HTTP and product-specific policy.
3
+ Version 0.1.1 is the verified maintenance candidate. The prior version 0.1.0 is publicly available on npm; publication of this new version uses the existing immutable `ts-v0.1.1` tag workflow after the combined checks and review. See [usage and boundaries](docs/README.md) and [current reconciliation](../docs/release-reconciliation-2026-11-15.md).
4
4
 
5
- Release preparation on 2026-10-21 preserves the existing public exports. Version 0.1.0 is approved for first publication on 2026-10-21. See [release gates](docs/release-candidate-2026-10-21.md); local application archives do not establish registry publication.
5
+ Public exports and compatibility ranges remain unchanged. Hosts own their state, transport, permissions and product rules.
@@ -4,13 +4,8 @@ const LESSON_SIMULATION_CHANNELS = new Set(['email', 'sms', 'browser']);
4
4
  * Used by the lesson form to block save on errors and show warnings.
5
5
  */
6
6
  import { isEmptyMarkdownHeading, isH1MarkdownLine, isMarkdownHeadingWithTrailingSpace, isNumericRunId, isSafeLessonId, lineHasTrailingWhitespace, parseClosedDynamicBlock, parseQuotedAttributes, startsDynamicBlockLine, stripHtmlTags, } from './markdown.js';
7
- const ALLOWED_BLOCK_TYPES = new Set(['checkpoint', 'sim_ref', 'scenario_ref']);
8
- function validateCheckpointLine(trimmed) {
9
- const block = parseClosedDynamicBlock(trimmed);
10
- if (block?.type !== 'checkpoint') {
11
- return null;
12
- }
13
- const attrs = parseQuotedAttributes(block.attrsRaw, new Set(['id', 'question', 'options', 'answer']));
7
+ function validateCheckpointLine(attrsRaw) {
8
+ const attrs = parseQuotedAttributes(attrsRaw, new Set(['id', 'question', 'options', 'answer']));
14
9
  const question = (attrs['question'] ?? '').trim();
15
10
  const optionsRaw = (attrs['options'] ?? '').trim();
16
11
  const answer = (attrs['answer'] ?? '').trim();
@@ -33,12 +28,8 @@ function validateCheckpointLine(trimmed) {
33
28
  return 'Checkpoint id must be alphanumeric, dashes, or underscores only.';
34
29
  return null;
35
30
  }
36
- function validateSimRefLine(trimmed) {
37
- const block = parseClosedDynamicBlock(trimmed);
38
- if (block?.type !== 'sim_ref') {
39
- return null;
40
- }
41
- const attrs = parseQuotedAttributes(block.attrsRaw, new Set(['channel', 'run_id', 'label']));
31
+ function validateSimRefLine(attrsRaw) {
32
+ const attrs = parseQuotedAttributes(attrsRaw, new Set(['channel', 'run_id', 'label']));
42
33
  const channel = (attrs['channel'] ?? '').toLowerCase().trim();
43
34
  const run_id = (attrs['run_id'] ?? '').trim();
44
35
  if (!LESSON_SIMULATION_CHANNELS.has(channel))
@@ -47,12 +38,8 @@ function validateSimRefLine(trimmed) {
47
38
  return 'sim_ref run_id must be a numeric run id.';
48
39
  return null;
49
40
  }
50
- function validateScenarioRefLine(trimmed) {
51
- const block = parseClosedDynamicBlock(trimmed);
52
- if (block?.type !== 'scenario_ref') {
53
- return null;
54
- }
55
- const attrs = parseQuotedAttributes(block.attrsRaw, new Set(['scenario_id', 'scenario_version_id', 'label']));
41
+ function validateScenarioRefLine(attrsRaw) {
42
+ const attrs = parseQuotedAttributes(attrsRaw, new Set(['scenario_id', 'scenario_version_id', 'label']));
56
43
  const scenario_id = (attrs['scenario_id'] ?? '').trim();
57
44
  const label = (attrs['label'] ?? '').trim();
58
45
  if (!scenario_id)
@@ -63,12 +50,8 @@ function validateScenarioRefLine(trimmed) {
63
50
  return 'scenario_ref must have label="...".';
64
51
  return null;
65
52
  }
66
- function getCheckpointId(trimmed) {
67
- const block = parseClosedDynamicBlock(trimmed);
68
- if (block?.type !== 'checkpoint') {
69
- return null;
70
- }
71
- const attrs = parseQuotedAttributes(block.attrsRaw, new Set(['id', 'question', 'options', 'answer']));
53
+ function getCheckpointId(attrsRaw) {
54
+ const attrs = parseQuotedAttributes(attrsRaw, new Set(['id', 'question', 'options', 'answer']));
72
55
  const id = (attrs['id'] ?? '').trim();
73
56
  return id || null;
74
57
  }
@@ -82,32 +65,28 @@ function validateDynamicBlockLine(trimmed, lineNum, state) {
82
65
  return true;
83
66
  }
84
67
  const blockType = blockMatch.type;
85
- if (!ALLOWED_BLOCK_TYPES.has(blockType)) {
86
- state.errors.push(`Line ${lineNum}: Unknown dynamic block type "${blockType}". Use :::checkpoint, :::sim_ref, or :::scenario_ref.`);
87
- return true;
88
- }
89
- const validationError = getDynamicBlockValidationError(blockType, trimmed);
68
+ const validationError = getDynamicBlockValidationError(blockType, blockMatch.attrsRaw);
90
69
  if (validationError) {
91
70
  state.errors.push(`Line ${lineNum}: ${validationError}`);
92
71
  return true;
93
72
  }
94
73
  if (blockType === 'checkpoint') {
95
- const id = getCheckpointId(trimmed);
74
+ const id = getCheckpointId(blockMatch.attrsRaw);
96
75
  if (id)
97
76
  state.checkpointIds.push({ line: lineNum, id });
98
77
  }
99
78
  return true;
100
79
  }
101
- function getDynamicBlockValidationError(blockType, trimmed) {
80
+ function getDynamicBlockValidationError(blockType, attrsRaw) {
102
81
  switch (blockType) {
103
82
  case 'checkpoint':
104
- return validateCheckpointLine(trimmed);
83
+ return validateCheckpointLine(attrsRaw);
105
84
  case 'sim_ref':
106
- return validateSimRefLine(trimmed);
85
+ return validateSimRefLine(attrsRaw);
107
86
  case 'scenario_ref':
108
- return validateScenarioRefLine(trimmed);
87
+ return validateScenarioRefLine(attrsRaw);
109
88
  default:
110
- return null;
89
+ return `Unknown dynamic block type "${blockType}". Use :::checkpoint, :::sim_ref, or :::scenario_ref.`;
111
90
  }
112
91
  }
113
92
  function addMarkdownLintWarnings(line, lineNum, state) {
@@ -149,15 +128,6 @@ function addTrailingWhitespaceWarnings(lines, state) {
149
128
  ? `Trailing whitespace on line(s) ${trailingLines.join(', ')}.`
150
129
  : `Trailing whitespace on ${trailingLines.length} lines (e.g. ${trailingLines.slice(0, 2).join(', ')}).`);
151
130
  }
152
- function dedupeWarnings(warnings) {
153
- const seenWarn = new Set();
154
- return warnings.filter((warning) => {
155
- if (seenWarn.has(warning))
156
- return false;
157
- seenWarn.add(warning);
158
- return true;
159
- });
160
- }
161
131
  export function validateLessonContent(md) {
162
132
  const raw = stripHtmlTags(md ?? '');
163
133
  const lines = raw.split(/\r?\n/);
@@ -167,8 +137,7 @@ export function validateLessonContent(md) {
167
137
  checkpointIds: [],
168
138
  h1Count: 0,
169
139
  };
170
- for (let i = 0; i < lines.length; i++) {
171
- const line = lines[i] ?? '';
140
+ for (const [i, line] of lines.entries()) {
172
141
  const trimmed = line.trim();
173
142
  const lineNum = i + 1;
174
143
  if (validateDynamicBlockLine(trimmed, lineNum, state))
@@ -180,5 +149,5 @@ export function validateLessonContent(md) {
180
149
  state.warnings.push(`Multiple H1 headings (${state.h1Count}). Consider using a single H1 for the title.`);
181
150
  }
182
151
  addTrailingWhitespaceWarnings(lines, state);
183
- return { errors: state.errors, warnings: dedupeWarnings(state.warnings) };
152
+ return { errors: state.errors, warnings: state.warnings };
184
153
  }
package/dist/markdown.js CHANGED
@@ -35,7 +35,7 @@ function skipAttrSpaces(raw, i) {
35
35
  }
36
36
  function readAttrKey(raw, i) {
37
37
  const keyStart = i;
38
- while (i < raw.length && isAttrNameChar(raw[i] ?? '')) {
38
+ while (i < raw.length && isAttrNameChar(raw.charAt(i))) {
39
39
  i++;
40
40
  }
41
41
  if (i === keyStart) {
@@ -53,7 +53,7 @@ function readQuotedAttrValue(raw, i) {
53
53
  i++;
54
54
  }
55
55
  const value = raw.slice(valStart, i).trim();
56
- if (i < raw.length && raw[i] === '"') {
56
+ if (i < raw.length) {
57
57
  i++;
58
58
  }
59
59
  return { value, i };
@@ -109,7 +109,7 @@ export function startsDynamicBlockLine(trimmed) {
109
109
  while (i < trimmed.length && trimmed[i] === ' ') {
110
110
  i++;
111
111
  }
112
- return i < trimmed.length && isWordChar(trimmed[i] ?? '');
112
+ return i < trimmed.length && isWordChar(trimmed.charAt(i));
113
113
  }
114
114
  /**
115
115
  * Parse a single-line `:::type attr="..." :::` block.
@@ -126,11 +126,8 @@ export function parseClosedDynamicBlock(trimmed) {
126
126
  }
127
127
  const inner = line.slice(3, closeAt).trim();
128
128
  let i = 0;
129
- while (i < inner.length && inner[i] === ' ') {
130
- i++;
131
- }
132
129
  const typeStart = i;
133
- while (i < inner.length && isWordChar(inner[i] ?? '')) {
130
+ while (i < inner.length && isWordChar(inner.charAt(i))) {
134
131
  i++;
135
132
  }
136
133
  if (i === typeStart) {
@@ -180,7 +177,7 @@ export function isMarkdownHeadingWithTrailingSpace(line) {
180
177
  while (i < line.length && line[i] === '#') {
181
178
  i++;
182
179
  }
183
- return i > 0 && i <= 6 && (line[i] ?? '') === ' ' && line.endsWith(' ');
180
+ return i <= 6 && (line[i] ?? '') === ' ' && line.endsWith(' ');
184
181
  }
185
182
  export function parseBulletListItem(line) {
186
183
  const trimmed = line.trimStart();
@@ -199,8 +196,8 @@ export function parseOrderedListItem(line) {
199
196
  }
200
197
  const numStart = i;
201
198
  while (i < line.length) {
202
- const ch = line[i];
203
- if (ch === undefined || ch < '0' || ch > '9') {
199
+ const ch = line.charAt(i);
200
+ if (ch < '0' || ch > '9') {
204
201
  break;
205
202
  }
206
203
  i++;
@@ -213,7 +210,7 @@ export function parseOrderedListItem(line) {
213
210
  }
214
211
  export function isCodeFenceLine(line) {
215
212
  const t = line.trim();
216
- return t === '```' || (t.startsWith('```') && t.slice(3).trim() === '');
213
+ return t === '```';
217
214
  }
218
215
  export function lineHasTrailingWhitespace(line) {
219
216
  return line.length > 0 && (line.endsWith(' ') || line.endsWith('\t'));
package/docs/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  This guide documents the current TypeScript candidate. See [current release gates](release-candidate-2026-10-21.md) for publication and adoption status.
4
4
 
5
- Version 0.1.0 is the coordinated release approved on 2026-10-21. Framework-independent Markdown parsing and lesson content validation. No dependency on platform-core or React.
5
+ Version 0.1.1 is the maintenance release candidate prepared on 2026-11-15. Framework-independent Markdown parsing and lesson content validation. No dependency on platform-core or React.
6
6
 
7
7
  Hosts own permissions, HTTP contracts, validation policy, navigation and persistence. React components accept controlled values, feedback and events; they do not fetch data. Form values (including empty numeric input strings) are UI state, not generated HTTP schemas.
8
8
 
9
- Run root npm typecheck, tests and build, plus the workspace lint, format:check and publish:dry-run commands. Run scripts/check_npm_artifact.mjs after building. Publishing requires an explicit release request.
9
+ Run root npm typecheck, tests and build, plus the workspace lint, format:check and pack:dry-run commands. Run scripts/check_npm_artifact.mjs after building. Publishing requires an explicit release request.
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@signalsafe/learning-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/SignalSafeSoftware/learning-core.git"
8
+ },
5
9
  "files": [
6
10
  "dist",
7
11
  "README.md",
@@ -28,16 +32,16 @@
28
32
  "typecheck": "tsc --noEmit",
29
33
  "lint": "oxlint --deny-warnings src",
30
34
  "format:check": "oxfmt --check .",
31
- "test": "vitest run --configLoader runner --no-cache",
32
- "publish:dry-run": "npm publish --dry-run --ignore-scripts",
33
- "prepublishOnly": "npm run build"
35
+ "test": "vitest run --configLoader runner --no-cache --coverage",
36
+ "prepublishOnly": "npm run build",
37
+ "pack:dry-run": "npm pack --dry-run --ignore-scripts"
34
38
  },
35
39
  "devDependencies": {
36
- "@vitest/coverage-v8": "4.1.12",
37
- "oxfmt": "0.72.0",
38
- "oxlint": "1.76.0",
39
- "typescript": "5.9.3",
40
- "vitest": "4.1.12"
40
+ "@vitest/coverage-v8": "5.1.0",
41
+ "oxfmt": "0.78.0",
42
+ "oxlint": "1.93.0",
43
+ "typescript": "7.0.2",
44
+ "vitest": "5.1.0"
41
45
  },
42
46
  "engines": {
43
47
  "node": ">=22.12.0"