drafter-mcp 0.26.0 → 0.26.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/drafter-mcp.js +43 -7
- package/package.json +1 -1
package/drafter-mcp.js
CHANGED
|
@@ -23233,7 +23233,7 @@ function toError(value) {
|
|
|
23233
23233
|
return value instanceof Error ? value : new Error(String(value));
|
|
23234
23234
|
}
|
|
23235
23235
|
// package.json
|
|
23236
|
-
var version = "0.26.
|
|
23236
|
+
var version = "0.26.1";
|
|
23237
23237
|
// ../fountain/src/inline.ts
|
|
23238
23238
|
const MARKERS$1 = /[*_\\]/;
|
|
23239
23239
|
const isSpace$10 = (code) => code === void 0 || /\s/.test(String.fromCharCode(code));
|
|
@@ -33929,6 +33929,45 @@ function isRecord(value) {
|
|
|
33929
33929
|
function target(value) {
|
|
33930
33930
|
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_TARGET ? value : void 0;
|
|
33931
33931
|
}
|
|
33932
|
+
/** The text cut to `max` code units, never leaving half of a surrogate pair at the cut. */
|
|
33933
|
+
function cut(value, max) {
|
|
33934
|
+
let s = value.slice(0, max);
|
|
33935
|
+
const last = s.charCodeAt(s.length - 1);
|
|
33936
|
+
if (last >= 55296 && last <= 56319) s = s.slice(0, -1);
|
|
33937
|
+
return s;
|
|
33938
|
+
}
|
|
33939
|
+
/** A manuscript field or contact line cut to `MAX_DETAIL`, as the book keeps it. */
|
|
33940
|
+
function cutDetail(value) {
|
|
33941
|
+
return cut(value, 300);
|
|
33942
|
+
}
|
|
33943
|
+
const DETAIL_KEYS = [
|
|
33944
|
+
"title",
|
|
33945
|
+
"byline",
|
|
33946
|
+
"legalName",
|
|
33947
|
+
"surname",
|
|
33948
|
+
"shortTitle"
|
|
33949
|
+
];
|
|
33950
|
+
function manuscript(value) {
|
|
33951
|
+
if (!isRecord(value)) return void 0;
|
|
33952
|
+
const out = {};
|
|
33953
|
+
for (const key of DETAIL_KEYS) {
|
|
33954
|
+
const v = value[key];
|
|
33955
|
+
if (typeof v === "string" && v.trim() !== "") out[key] = cutDetail(v);
|
|
33956
|
+
}
|
|
33957
|
+
if (Array.isArray(value.contact)) {
|
|
33958
|
+
const lines = [];
|
|
33959
|
+
for (const item of value.contact) {
|
|
33960
|
+
if (typeof item !== "string") continue;
|
|
33961
|
+
for (const line of item.split(/\r\n|\r|\n/)) {
|
|
33962
|
+
const t = cutDetail(line.trim());
|
|
33963
|
+
if (t !== "") lines.push(t);
|
|
33964
|
+
}
|
|
33965
|
+
}
|
|
33966
|
+
if (lines.length > 0) out.contact = lines.slice(0, 10);
|
|
33967
|
+
}
|
|
33968
|
+
if (value.font === "times" || value.font === "courier") out.font = value.font;
|
|
33969
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
33970
|
+
}
|
|
33932
33971
|
function newNodes() {
|
|
33933
33972
|
return Object.create(null);
|
|
33934
33973
|
}
|
|
@@ -33937,12 +33976,7 @@ function readOne(raw) {
|
|
|
33937
33976
|
const facts = {};
|
|
33938
33977
|
const status = raw.status;
|
|
33939
33978
|
if (typeof status === "string" && STATUSES.includes(status)) facts.status = status;
|
|
33940
|
-
if (typeof raw.synopsis === "string" && raw.synopsis !== "")
|
|
33941
|
-
let s = raw.synopsis.slice(0, MAX_SYNOPSIS);
|
|
33942
|
-
const last = s.charCodeAt(s.length - 1);
|
|
33943
|
-
if (last >= 55296 && last <= 56319) s = s.slice(0, -1);
|
|
33944
|
-
facts.synopsis = s;
|
|
33945
|
-
}
|
|
33979
|
+
if (typeof raw.synopsis === "string" && raw.synopsis !== "") facts.synopsis = cut(raw.synopsis, MAX_SYNOPSIS);
|
|
33946
33980
|
const t = target(raw.target);
|
|
33947
33981
|
if (t !== void 0) facts.target = t;
|
|
33948
33982
|
return Object.keys(facts).length > 0 ? facts : null;
|
|
@@ -33959,6 +33993,8 @@ function readFacts(text) {
|
|
|
33959
33993
|
if (!isRecord(novel)) return out;
|
|
33960
33994
|
const bookTarget = target(novel.bookTarget);
|
|
33961
33995
|
if (bookTarget !== void 0) out.bookTarget = bookTarget;
|
|
33996
|
+
const details = manuscript(novel.manuscript);
|
|
33997
|
+
if (details) out.manuscript = details;
|
|
33962
33998
|
if (isRecord(novel.nodes)) for (const id of Object.keys(novel.nodes)) {
|
|
33963
33999
|
const facts = readOne(novel.nodes[id]);
|
|
33964
34000
|
if (facts) out.nodes[id] = facts;
|
package/package.json
CHANGED