@rohal12/twee-ts 1.1.1 → 1.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.
@@ -1251,11 +1251,15 @@ function loadTagged(story, tag, filename, diagnostics) {
1251
1251
  function loadMedia(story, tag, filename, diagnostics) {
1252
1252
  const source = readBase64(filename);
1253
1253
  const name = basename(filename).split(".")[0];
1254
- storyAdd(story, {
1255
- name,
1256
- tags: [tag],
1257
- text: `data:${mediaTypeFromFilename(filename)};base64,${source}`
1258
- }, diagnostics);
1254
+ storyAdd(
1255
+ story,
1256
+ {
1257
+ name,
1258
+ tags: [tag],
1259
+ text: `data:${mediaTypeFromFilename(filename)};base64,${source}`
1260
+ },
1261
+ diagnostics
1262
+ );
1259
1263
  }
1260
1264
  function loadFont(story, filename, diagnostics) {
1261
1265
  const source = readBase64(filename);
@@ -1264,14 +1268,18 @@ function loadFont(story, filename, diagnostics) {
1264
1268
  const ext = normalizedFileExt(filename);
1265
1269
  const mediaType = mediaTypeFromExt(ext);
1266
1270
  const hint = fontFormatHint(ext);
1267
- storyAdd(story, {
1268
- name,
1269
- tags: ["stylesheet"],
1270
- text: `@font-face {
1271
+ storyAdd(
1272
+ story,
1273
+ {
1274
+ name,
1275
+ tags: ["stylesheet"],
1276
+ text: `@font-face {
1271
1277
  font-family: "${family}";
1272
1278
  src: url("data:${mediaType};base64,${source}") format("${hint}");
1273
1279
  }`
1274
- }, diagnostics);
1280
+ },
1281
+ diagnostics
1282
+ );
1275
1283
  }
1276
1284
 
1277
1285
  // src/output-twine2.ts
@@ -1802,10 +1810,7 @@ async function buildOutput(options) {
1802
1810
  let format;
1803
1811
  let formatId = options.formatId ?? "";
1804
1812
  if (outputMode === "html") {
1805
- const formatSearchDirs = getFormatSearchDirs(
1806
- options.formatPaths,
1807
- options.useTweegoPath ?? true
1808
- );
1813
+ const formatSearchDirs = getFormatSearchDirs(options.formatPaths, options.useTweegoPath ?? true);
1809
1814
  const formats = discoverFormats(formatSearchDirs);
1810
1815
  if (!formatId && story.twine2.format) {
1811
1816
  formatId = getFormatIdByNameAndVersion(formats, story.twine2.format, story.twine2.formatVersion) ?? "";
@@ -1818,12 +1823,7 @@ async function buildOutput(options) {
1818
1823
  const remoteName = story.twine2.format || formatId;
1819
1824
  const remoteVersion = story.twine2.formatVersion || "";
1820
1825
  try {
1821
- format = await resolveRemoteFormat(
1822
- remoteName,
1823
- remoteVersion,
1824
- options.formatIndices,
1825
- options.formatUrls
1826
- );
1826
+ format = await resolveRemoteFormat(remoteName, remoteVersion, options.formatIndices, options.formatUrls);
1827
1827
  } catch {
1828
1828
  }
1829
1829
  }
@@ -1895,24 +1895,28 @@ async function buildOutput(options) {
1895
1895
  return { output, story, format, diagnostics, stats };
1896
1896
  }
1897
1897
  function storyToJSON(story) {
1898
- return JSON.stringify({
1899
- name: story.name,
1900
- ifid: story.ifid,
1901
- passages: story.passages.map((p) => ({
1902
- name: p.name,
1903
- tags: p.tags,
1904
- text: p.text,
1905
- metadata: p.metadata ?? null
1906
- })),
1907
- twine2: {
1908
- format: story.twine2.format,
1909
- formatVersion: story.twine2.formatVersion,
1910
- start: story.twine2.start,
1911
- tagColors: Object.fromEntries(story.twine2.tagColors),
1912
- options: Object.fromEntries(story.twine2.options),
1913
- zoom: story.twine2.zoom
1914
- }
1915
- }, null, 2);
1898
+ return JSON.stringify(
1899
+ {
1900
+ name: story.name,
1901
+ ifid: story.ifid,
1902
+ passages: story.passages.map((p) => ({
1903
+ name: p.name,
1904
+ tags: p.tags,
1905
+ text: p.text,
1906
+ metadata: p.metadata ?? null
1907
+ })),
1908
+ twine2: {
1909
+ format: story.twine2.format,
1910
+ formatVersion: story.twine2.formatVersion,
1911
+ start: story.twine2.start,
1912
+ tagColors: Object.fromEntries(story.twine2.tagColors),
1913
+ options: Object.fromEntries(story.twine2.options),
1914
+ zoom: story.twine2.zoom
1915
+ }
1916
+ },
1917
+ null,
1918
+ 2
1919
+ );
1916
1920
  }
1917
1921
 
1918
1922
  // src/config.ts
@@ -2188,16 +2192,22 @@ Statistics:`);
2188
2192
  function runInit() {
2189
2193
  console.log("Initializing new twee-ts project...");
2190
2194
  mkdirSync2("src", { recursive: true });
2191
- writeFileSync3(join6("src", "StoryData.tw"), `:: StoryData
2195
+ writeFileSync3(
2196
+ join6("src", "StoryData.tw"),
2197
+ `:: StoryData
2192
2198
  {
2193
2199
  "ifid": "${crypto.randomUUID().toUpperCase()}"
2194
2200
  }
2195
- `);
2196
- writeFileSync3(join6("src", "Start.tw"), `:: Start
2201
+ `
2202
+ );
2203
+ writeFileSync3(
2204
+ join6("src", "Start.tw"),
2205
+ `:: Start
2197
2206
  Welcome to your new Twine story!
2198
2207
 
2199
2208
  This is the starting passage. Edit this file to begin writing your story.
2200
- `);
2209
+ `
2210
+ );
2201
2211
  if (!existsSync3(CONFIG_FILENAME)) {
2202
2212
  writeFileSync3(CONFIG_FILENAME, scaffoldConfig());
2203
2213
  console.log(`Created: ${CONFIG_FILENAME}`);