@rohal12/twee-ts 1.2.0 → 1.3.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/README.md +9 -0
- package/dist/bin/twee-ts.js +44 -24
- package/dist/bin/twee-ts.js.map +1 -1
- package/dist/{chunk-S4SWCQLW.js → chunk-OGP2NXLJ.js} +45 -25
- package/dist/chunk-OGP2NXLJ.js.map +1 -0
- package/dist/index.cjs +44 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -24
- package/dist/index.js.map +1 -1
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/vite.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-S4SWCQLW.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1421,23 +1421,24 @@ function getTwine2DataChunk(story, startName, diagnostics) {
|
|
|
1421
1421
|
if (val) opts.push(opt);
|
|
1422
1422
|
}
|
|
1423
1423
|
const options = opts.join(" ");
|
|
1424
|
-
const zoom =
|
|
1424
|
+
const zoom = String(story.twine2.zoom);
|
|
1425
1425
|
const wrapper = `<!-- UUID://${htmlCommentSanitize(story.ifid)}// --><tw-storydata name="${attrEscape(story.name)}" startnode="${attrEscape(startID)}" creator="${attrEscape(CREATOR_NAME)}" creator-version="${attrEscape(VERSION)}" ifid="${attrEscape(story.ifid)}" zoom="${attrEscape(zoom)}" format="${attrEscape(story.twine2.format)}" format-version="${attrEscape(story.twine2.formatVersion)}" options="${attrEscape(options)}" hidden>`;
|
|
1426
1426
|
return wrapper + parts.join("") + "</tw-storydata>";
|
|
1427
1427
|
}
|
|
1428
1428
|
function ensureIFID(story, diagnostics) {
|
|
1429
1429
|
if (story.ifid !== "") return;
|
|
1430
1430
|
if (story.legacyIFID !== "") {
|
|
1431
|
+
story.ifid = story.legacyIFID;
|
|
1431
1432
|
diagnostics.push({
|
|
1432
1433
|
level: "warning",
|
|
1433
1434
|
message: 'Story IFID not found; reusing "ifid" entry from the "StorySettings" special passage.'
|
|
1434
1435
|
});
|
|
1435
|
-
story.ifid = story.legacyIFID;
|
|
1436
1436
|
} else {
|
|
1437
|
-
|
|
1437
|
+
const ifid = generateIFID();
|
|
1438
|
+
story.ifid = ifid;
|
|
1438
1439
|
diagnostics.push({
|
|
1439
|
-
level: "
|
|
1440
|
-
message: `Story IFID not found
|
|
1440
|
+
level: "error",
|
|
1441
|
+
message: `Story IFID not found. Add a StoryData passage with: {"ifid":"${ifid}"}`
|
|
1441
1442
|
});
|
|
1442
1443
|
}
|
|
1443
1444
|
}
|
|
@@ -1834,6 +1835,7 @@ function discoverCachedFormats() {
|
|
|
1834
1835
|
}
|
|
1835
1836
|
|
|
1836
1837
|
// src/compiler.ts
|
|
1838
|
+
var CREATOR_NAME3 = "Twee-ts";
|
|
1837
1839
|
var DEFAULT_FORMAT_ID = "sugarcube-2";
|
|
1838
1840
|
var DEFAULT_START_NAME = "Start";
|
|
1839
1841
|
var TweeTsError = class extends Error {
|
|
@@ -1980,28 +1982,46 @@ async function buildOutput(options) {
|
|
|
1980
1982
|
return { output, story, format, diagnostics, stats };
|
|
1981
1983
|
}
|
|
1982
1984
|
function storyToJSON(story) {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1985
|
+
const scripts = [];
|
|
1986
|
+
const stylesheets = [];
|
|
1987
|
+
const storyPassages = [];
|
|
1988
|
+
for (const p of story.passages) {
|
|
1989
|
+
if (p.name === "StoryTitle" || p.name === "StoryData") continue;
|
|
1990
|
+
if (hasTag(p, "Twine.private")) continue;
|
|
1991
|
+
if (hasTag(p, "script")) {
|
|
1992
|
+
scripts.push(p.text);
|
|
1993
|
+
} else if (hasTag(p, "stylesheet")) {
|
|
1994
|
+
stylesheets.push(p.text);
|
|
1995
|
+
} else {
|
|
1996
|
+
const entry = {
|
|
1988
1997
|
name: p.name,
|
|
1989
1998
|
tags: p.tags,
|
|
1990
|
-
text: p.text
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
tagColors: Object.fromEntries(story.twine2.tagColors),
|
|
1998
|
-
options: Object.fromEntries(story.twine2.options),
|
|
1999
|
-
zoom: story.twine2.zoom
|
|
1999
|
+
text: p.text
|
|
2000
|
+
};
|
|
2001
|
+
if (p.metadata && (p.metadata.position || p.metadata.size)) {
|
|
2002
|
+
const meta = {};
|
|
2003
|
+
if (p.metadata.position) meta.position = p.metadata.position;
|
|
2004
|
+
if (p.metadata.size) meta.size = p.metadata.size;
|
|
2005
|
+
entry.metadata = meta;
|
|
2000
2006
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2007
|
+
storyPassages.push(entry);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
const obj = {
|
|
2011
|
+
name: story.name
|
|
2012
|
+
};
|
|
2013
|
+
if (story.ifid) obj.ifid = story.ifid;
|
|
2014
|
+
if (story.twine2.format) obj.format = story.twine2.format;
|
|
2015
|
+
if (story.twine2.formatVersion) obj["format-version"] = story.twine2.formatVersion;
|
|
2016
|
+
if (story.twine2.start) obj.start = story.twine2.start;
|
|
2017
|
+
if (story.twine2.tagColors.size > 0) obj["tag-colors"] = Object.fromEntries(story.twine2.tagColors);
|
|
2018
|
+
if (story.twine2.zoom !== 1) obj.zoom = story.twine2.zoom;
|
|
2019
|
+
obj.creator = CREATOR_NAME3;
|
|
2020
|
+
obj["creator-version"] = VERSION;
|
|
2021
|
+
obj.style = stylesheets.join("\n");
|
|
2022
|
+
obj.script = scripts.join("\n");
|
|
2023
|
+
obj.passages = storyPassages;
|
|
2024
|
+
return JSON.stringify(obj, null, 2);
|
|
2005
2025
|
}
|
|
2006
2026
|
|
|
2007
2027
|
// src/inspect.ts
|