@rohal12/twee-ts 1.13.0 → 1.13.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/dist/index.cjs CHANGED
@@ -4544,10 +4544,12 @@ function toTwine2Archive(story, startName, options) {
4544
4544
  function toTwine2HTML(story, format, startName, options) {
4545
4545
  let template = readFormatSource(format);
4546
4546
  if (template.includes("{{STORY_NAME}}")) {
4547
- template = template.replaceAll("{{STORY_NAME}}", htmlEscape(story.name));
4547
+ const name = htmlEscape(story.name);
4548
+ template = template.replaceAll("{{STORY_NAME}}", () => name);
4548
4549
  }
4549
4550
  if (template.includes("{{STORY_DATA}}")) {
4550
- template = template.replace("{{STORY_DATA}}", getTwine2DataChunk(story, startName, options));
4551
+ const data = getTwine2DataChunk(story, startName, options);
4552
+ template = template.replace("{{STORY_DATA}}", () => data);
4551
4553
  }
4552
4554
  return template;
4553
4555
  }
@@ -4648,10 +4650,11 @@ function toTwine1HTML(story, format, startName) {
4648
4650
  const displayStart = startName === "Start" ? "" : startName;
4649
4651
  template = template.replace('"VERSION"', `Compiled with ${CREATOR_NAME2}, ${VERSION}`);
4650
4652
  template = template.replace('"TIME"', `Built on ${(/* @__PURE__ */ new Date()).toUTCString()}`);
4651
- template = template.replace('"START_AT"', `"${jsStringEscape(displayStart)}"`);
4653
+ const startAtValue = `"${jsStringEscape(displayStart)}"`;
4654
+ template = template.replace('"START_AT"', () => startAtValue);
4652
4655
  template = template.replace('"STORY_SIZE"', `"${count}"`);
4653
4656
  if (template.includes('"STORY"')) {
4654
- template = template.replace('"STORY"', data);
4657
+ template = template.replace('"STORY"', () => data);
4655
4658
  } else {
4656
4659
  let footer;
4657
4660
  try {
@@ -4687,7 +4690,7 @@ function tryReplaceComponent(template, placeholder, componentPath, required) {
4687
4690
  try {
4688
4691
  let content = (0, import_node_fs5.readFileSync)(componentPath, "utf-8");
4689
4692
  if (content.charCodeAt(0) === 65279) content = content.slice(1);
4690
- return template.replace(placeholder, content);
4693
+ return template.replace(placeholder, () => content);
4691
4694
  } catch (e) {
4692
4695
  if (required) {
4693
4696
  throw new Error(
@@ -4775,7 +4778,8 @@ function modifyHead(html, modulePaths, headFile, diagnostics) {
4775
4778
  }
4776
4779
  if (parts.length > 0) {
4777
4780
  parts.push("</head>");
4778
- return html.replace("</head>", parts.join("\n"));
4781
+ const replacement = parts.join("\n");
4782
+ return html.replace("</head>", () => replacement);
4779
4783
  }
4780
4784
  return html;
4781
4785
  }