@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/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# twee-ts
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@rohal12/twee-ts)
|
|
4
|
+
[](https://github.com/rohal12/twee-ts/actions)
|
|
5
|
+
[](https://bundlephobia.com/package/@rohal12/twee-ts)
|
|
6
|
+
[]()
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://github.com/rohal12/twee-ts/commits)
|
|
10
|
+
[](./UNLICENSE)
|
|
11
|
+
|
|
3
12
|
TypeScript reimplementation of [Tweego](https://www.motoslave.net/tweego/) — a command-line compiler for Twine/Twee interactive fiction projects.
|
|
4
13
|
|
|
5
14
|
Zero runtime dependencies. Node.js 22+.
|
package/dist/bin/twee-ts.js
CHANGED
|
@@ -1409,23 +1409,24 @@ function getTwine2DataChunk(story, startName, diagnostics) {
|
|
|
1409
1409
|
if (val) opts.push(opt);
|
|
1410
1410
|
}
|
|
1411
1411
|
const options = opts.join(" ");
|
|
1412
|
-
const zoom =
|
|
1412
|
+
const zoom = String(story.twine2.zoom);
|
|
1413
1413
|
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>`;
|
|
1414
1414
|
return wrapper + parts.join("") + "</tw-storydata>";
|
|
1415
1415
|
}
|
|
1416
1416
|
function ensureIFID(story, diagnostics) {
|
|
1417
1417
|
if (story.ifid !== "") return;
|
|
1418
1418
|
if (story.legacyIFID !== "") {
|
|
1419
|
+
story.ifid = story.legacyIFID;
|
|
1419
1420
|
diagnostics.push({
|
|
1420
1421
|
level: "warning",
|
|
1421
1422
|
message: 'Story IFID not found; reusing "ifid" entry from the "StorySettings" special passage.'
|
|
1422
1423
|
});
|
|
1423
|
-
story.ifid = story.legacyIFID;
|
|
1424
1424
|
} else {
|
|
1425
|
-
|
|
1425
|
+
const ifid = generateIFID();
|
|
1426
|
+
story.ifid = ifid;
|
|
1426
1427
|
diagnostics.push({
|
|
1427
|
-
level: "
|
|
1428
|
-
message: `Story IFID not found
|
|
1428
|
+
level: "error",
|
|
1429
|
+
message: `Story IFID not found. Add a StoryData passage with: {"ifid":"${ifid}"}`
|
|
1429
1430
|
});
|
|
1430
1431
|
}
|
|
1431
1432
|
}
|
|
@@ -1822,6 +1823,7 @@ function discoverCachedFormats() {
|
|
|
1822
1823
|
}
|
|
1823
1824
|
|
|
1824
1825
|
// src/compiler.ts
|
|
1826
|
+
var CREATOR_NAME3 = "Twee-ts";
|
|
1825
1827
|
var DEFAULT_FORMAT_ID = "sugarcube-2";
|
|
1826
1828
|
var DEFAULT_START_NAME = "Start";
|
|
1827
1829
|
var TweeTsError = class extends Error {
|
|
@@ -1968,28 +1970,46 @@ async function buildOutput(options) {
|
|
|
1968
1970
|
return { output, story, format, diagnostics, stats };
|
|
1969
1971
|
}
|
|
1970
1972
|
function storyToJSON(story) {
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1973
|
+
const scripts = [];
|
|
1974
|
+
const stylesheets = [];
|
|
1975
|
+
const storyPassages = [];
|
|
1976
|
+
for (const p of story.passages) {
|
|
1977
|
+
if (p.name === "StoryTitle" || p.name === "StoryData") continue;
|
|
1978
|
+
if (hasTag(p, "Twine.private")) continue;
|
|
1979
|
+
if (hasTag(p, "script")) {
|
|
1980
|
+
scripts.push(p.text);
|
|
1981
|
+
} else if (hasTag(p, "stylesheet")) {
|
|
1982
|
+
stylesheets.push(p.text);
|
|
1983
|
+
} else {
|
|
1984
|
+
const entry = {
|
|
1976
1985
|
name: p.name,
|
|
1977
1986
|
tags: p.tags,
|
|
1978
|
-
text: p.text
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
tagColors: Object.fromEntries(story.twine2.tagColors),
|
|
1986
|
-
options: Object.fromEntries(story.twine2.options),
|
|
1987
|
-
zoom: story.twine2.zoom
|
|
1987
|
+
text: p.text
|
|
1988
|
+
};
|
|
1989
|
+
if (p.metadata && (p.metadata.position || p.metadata.size)) {
|
|
1990
|
+
const meta = {};
|
|
1991
|
+
if (p.metadata.position) meta.position = p.metadata.position;
|
|
1992
|
+
if (p.metadata.size) meta.size = p.metadata.size;
|
|
1993
|
+
entry.metadata = meta;
|
|
1988
1994
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1995
|
+
storyPassages.push(entry);
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
const obj = {
|
|
1999
|
+
name: story.name
|
|
2000
|
+
};
|
|
2001
|
+
if (story.ifid) obj.ifid = story.ifid;
|
|
2002
|
+
if (story.twine2.format) obj.format = story.twine2.format;
|
|
2003
|
+
if (story.twine2.formatVersion) obj["format-version"] = story.twine2.formatVersion;
|
|
2004
|
+
if (story.twine2.start) obj.start = story.twine2.start;
|
|
2005
|
+
if (story.twine2.tagColors.size > 0) obj["tag-colors"] = Object.fromEntries(story.twine2.tagColors);
|
|
2006
|
+
if (story.twine2.zoom !== 1) obj.zoom = story.twine2.zoom;
|
|
2007
|
+
obj.creator = CREATOR_NAME3;
|
|
2008
|
+
obj["creator-version"] = VERSION;
|
|
2009
|
+
obj.style = stylesheets.join("\n");
|
|
2010
|
+
obj.script = scripts.join("\n");
|
|
2011
|
+
obj.passages = storyPassages;
|
|
2012
|
+
return JSON.stringify(obj, null, 2);
|
|
1993
2013
|
}
|
|
1994
2014
|
|
|
1995
2015
|
// src/config.ts
|