@patterkit/core 0.6.2 → 0.7.0
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/index.cjs +29 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -388,6 +388,20 @@ function validateProject(input) {
|
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
+
const labelled = (project.cast ?? []).filter((c) => c.qualifierLabels && typeof c.qualifierLabels === "object");
|
|
392
|
+
const usedPairs = labelled.length === 0 ? /* @__PURE__ */ new Set() : new Set((0, import_model.usedSpeakerPairs)(scenes.filter((sc) => Array.isArray(sc?.blocks) && sc.blocks.every((b) => Array.isArray(b?.children)))).map((p) => `${p.character}\0${p.qualifier}`));
|
|
393
|
+
for (const c of labelled) {
|
|
394
|
+
const labels = c.qualifierLabels;
|
|
395
|
+
if (!labels || typeof labels !== "object") continue;
|
|
396
|
+
for (const q of Object.keys(labels)) {
|
|
397
|
+
if (usedPairs.has(`${c.name}\0${q}`)) continue;
|
|
398
|
+
issues.push({
|
|
399
|
+
code: "unused-speaker-label",
|
|
400
|
+
severity: "warning",
|
|
401
|
+
message: `'${c.name}' has its own label with the qualifier '${q}', but no line has that speaker with that qualifier`
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
391
405
|
return issues;
|
|
392
406
|
}
|
|
393
407
|
function isQualifierEntry(q) {
|
|
@@ -468,6 +482,21 @@ function validateProjectFile(project, issues) {
|
|
|
468
482
|
}
|
|
469
483
|
if (typeof q.gameId === "string") seenQualifiers.add(q.gameId);
|
|
470
484
|
}
|
|
485
|
+
const pattern = project.speakerPattern;
|
|
486
|
+
if (pattern !== void 0 && typeof pattern !== "string") {
|
|
487
|
+
issues.push({ code: "invalid-speaker-label", message: "the speaker pattern must be text" });
|
|
488
|
+
}
|
|
489
|
+
for (const c of project.cast ?? []) {
|
|
490
|
+
const labels = c.qualifierLabels;
|
|
491
|
+
if (labels === void 0) continue;
|
|
492
|
+
if (!labels || typeof labels !== "object" || Array.isArray(labels)) {
|
|
493
|
+
issues.push({ code: "invalid-speaker-label", message: `'${c.name}' qualifier labels must map a qualifier to its label` });
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
for (const [q, label] of Object.entries(labels)) {
|
|
497
|
+
if (typeof label !== "string") issues.push({ code: "invalid-speaker-label", message: `'${c.name}' label with the qualifier '${q}' must be text` });
|
|
498
|
+
}
|
|
499
|
+
}
|
|
471
500
|
for (const [kind, fields] of Object.entries(project.gameDataFields ?? {})) {
|
|
472
501
|
const seen = /* @__PURE__ */ new Set();
|
|
473
502
|
for (const f of fields ?? []) {
|
package/dist/index.d.cts
CHANGED
|
@@ -26,7 +26,7 @@ interface StringifyOptions {
|
|
|
26
26
|
declare function canonicalStringify(value: unknown, opts?: StringifyOptions): string;
|
|
27
27
|
|
|
28
28
|
interface ValidationIssue {
|
|
29
|
-
code: "duplicate-id" | "missing-id" | "malformed-node" | "missing-name" | "empty-scene" | "empty-snippet" | "empty-container" | "dangling-jump" | "jump-into-non-addressable" | "invalid-gameid" | "duplicate-gameid" | "unknown-character" | "unknown-qualifier" | "invalid-qualifier" | "invalid-pad" | "pad-overlaps-seam" | "prompt-pad-without-beat" | "qualifier-without-speaker" | "invalid-temporary" | "invalid-declaration" | "invalid-status-ladder" | "invalid-locales" | "invalid-captions" | "missing-prompt" | "invalid-prompt" | "multiple-fallbacks" | "choice-can-empty" | "invalid-status-value" | "unknown-doc-class" | "invalid-tag" | "invalid-gamedata-field" | "jump-cycle";
|
|
29
|
+
code: "duplicate-id" | "missing-id" | "malformed-node" | "missing-name" | "empty-scene" | "empty-snippet" | "empty-container" | "dangling-jump" | "jump-into-non-addressable" | "invalid-gameid" | "duplicate-gameid" | "unknown-character" | "unknown-qualifier" | "invalid-qualifier" | "invalid-pad" | "pad-overlaps-seam" | "prompt-pad-without-beat" | "qualifier-without-speaker" | "invalid-speaker-label" | "unused-speaker-label" | "invalid-temporary" | "invalid-declaration" | "invalid-status-ladder" | "invalid-locales" | "invalid-captions" | "missing-prompt" | "invalid-prompt" | "multiple-fallbacks" | "choice-can-empty" | "invalid-status-value" | "unknown-doc-class" | "invalid-tag" | "invalid-gamedata-field" | "jump-cycle";
|
|
30
30
|
message: string;
|
|
31
31
|
/** Id of the offending node/beat, where applicable. */
|
|
32
32
|
id?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface StringifyOptions {
|
|
|
26
26
|
declare function canonicalStringify(value: unknown, opts?: StringifyOptions): string;
|
|
27
27
|
|
|
28
28
|
interface ValidationIssue {
|
|
29
|
-
code: "duplicate-id" | "missing-id" | "malformed-node" | "missing-name" | "empty-scene" | "empty-snippet" | "empty-container" | "dangling-jump" | "jump-into-non-addressable" | "invalid-gameid" | "duplicate-gameid" | "unknown-character" | "unknown-qualifier" | "invalid-qualifier" | "invalid-pad" | "pad-overlaps-seam" | "prompt-pad-without-beat" | "qualifier-without-speaker" | "invalid-temporary" | "invalid-declaration" | "invalid-status-ladder" | "invalid-locales" | "invalid-captions" | "missing-prompt" | "invalid-prompt" | "multiple-fallbacks" | "choice-can-empty" | "invalid-status-value" | "unknown-doc-class" | "invalid-tag" | "invalid-gamedata-field" | "jump-cycle";
|
|
29
|
+
code: "duplicate-id" | "missing-id" | "malformed-node" | "missing-name" | "empty-scene" | "empty-snippet" | "empty-container" | "dangling-jump" | "jump-into-non-addressable" | "invalid-gameid" | "duplicate-gameid" | "unknown-character" | "unknown-qualifier" | "invalid-qualifier" | "invalid-pad" | "pad-overlaps-seam" | "prompt-pad-without-beat" | "qualifier-without-speaker" | "invalid-speaker-label" | "unused-speaker-label" | "invalid-temporary" | "invalid-declaration" | "invalid-status-ladder" | "invalid-locales" | "invalid-captions" | "missing-prompt" | "invalid-prompt" | "multiple-fallbacks" | "choice-can-empty" | "invalid-status-value" | "unknown-doc-class" | "invalid-tag" | "invalid-gamedata-field" | "jump-cycle";
|
|
30
30
|
message: string;
|
|
31
31
|
/** Id of the offending node/beat, where applicable. */
|
|
32
32
|
id?: string;
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ ${indent}}`;
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// src/validate.ts
|
|
58
|
-
import { walkNodes, DEFAULT_WRITING_STATUSES, DEFAULT_RECORDING_STATUSES, DEFAULT_DOCUMENTATION_CLASSES, projectQualifiers, PAD_AFTER_MIN, PAD_AFTER_MAX } from "@patterkit/model";
|
|
58
|
+
import { walkNodes, DEFAULT_WRITING_STATUSES, DEFAULT_RECORDING_STATUSES, DEFAULT_DOCUMENTATION_CLASSES, projectQualifiers, usedSpeakerPairs, PAD_AFTER_MIN, PAD_AFTER_MAX } from "@patterkit/model";
|
|
59
59
|
import { isValidGameId, effectiveGameId } from "@patterkit/model";
|
|
60
60
|
import { isValidPropertyName, propertyNameify, RESERVED_PROPERTY_NAMES } from "@patterkit/model";
|
|
61
61
|
function choiceLoopsBack(choice, ...targets) {
|
|
@@ -350,6 +350,20 @@ function validateProject(input) {
|
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
+
const labelled = (project.cast ?? []).filter((c) => c.qualifierLabels && typeof c.qualifierLabels === "object");
|
|
354
|
+
const usedPairs = labelled.length === 0 ? /* @__PURE__ */ new Set() : new Set(usedSpeakerPairs(scenes.filter((sc) => Array.isArray(sc?.blocks) && sc.blocks.every((b) => Array.isArray(b?.children)))).map((p) => `${p.character}\0${p.qualifier}`));
|
|
355
|
+
for (const c of labelled) {
|
|
356
|
+
const labels = c.qualifierLabels;
|
|
357
|
+
if (!labels || typeof labels !== "object") continue;
|
|
358
|
+
for (const q of Object.keys(labels)) {
|
|
359
|
+
if (usedPairs.has(`${c.name}\0${q}`)) continue;
|
|
360
|
+
issues.push({
|
|
361
|
+
code: "unused-speaker-label",
|
|
362
|
+
severity: "warning",
|
|
363
|
+
message: `'${c.name}' has its own label with the qualifier '${q}', but no line has that speaker with that qualifier`
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
353
367
|
return issues;
|
|
354
368
|
}
|
|
355
369
|
function isQualifierEntry(q) {
|
|
@@ -430,6 +444,21 @@ function validateProjectFile(project, issues) {
|
|
|
430
444
|
}
|
|
431
445
|
if (typeof q.gameId === "string") seenQualifiers.add(q.gameId);
|
|
432
446
|
}
|
|
447
|
+
const pattern = project.speakerPattern;
|
|
448
|
+
if (pattern !== void 0 && typeof pattern !== "string") {
|
|
449
|
+
issues.push({ code: "invalid-speaker-label", message: "the speaker pattern must be text" });
|
|
450
|
+
}
|
|
451
|
+
for (const c of project.cast ?? []) {
|
|
452
|
+
const labels = c.qualifierLabels;
|
|
453
|
+
if (labels === void 0) continue;
|
|
454
|
+
if (!labels || typeof labels !== "object" || Array.isArray(labels)) {
|
|
455
|
+
issues.push({ code: "invalid-speaker-label", message: `'${c.name}' qualifier labels must map a qualifier to its label` });
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
for (const [q, label] of Object.entries(labels)) {
|
|
459
|
+
if (typeof label !== "string") issues.push({ code: "invalid-speaker-label", message: `'${c.name}' label with the qualifier '${q}' must be text` });
|
|
460
|
+
}
|
|
461
|
+
}
|
|
433
462
|
for (const [kind, fields] of Object.entries(project.gameDataFields ?? {})) {
|
|
434
463
|
const seen = /* @__PURE__ */ new Set();
|
|
435
464
|
for (const f of fields ?? []) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patterkit/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Patter core: stable id generation, readable-handle computation, canonical (de)serialisation, and the structural validator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patterkit/model": "0.
|
|
37
|
+
"@patterkit/model": "0.14.0",
|
|
38
38
|
"@wildwinter/toolkit": "^0.1.0",
|
|
39
39
|
"json5": "^2.2.3"
|
|
40
40
|
}
|