@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.js CHANGED
@@ -4483,10 +4483,12 @@ function toTwine2Archive(story, startName, options) {
4483
4483
  function toTwine2HTML(story, format, startName, options) {
4484
4484
  let template = readFormatSource(format);
4485
4485
  if (template.includes("{{STORY_NAME}}")) {
4486
- template = template.replaceAll("{{STORY_NAME}}", htmlEscape(story.name));
4486
+ const name = htmlEscape(story.name);
4487
+ template = template.replaceAll("{{STORY_NAME}}", () => name);
4487
4488
  }
4488
4489
  if (template.includes("{{STORY_DATA}}")) {
4489
- template = template.replace("{{STORY_DATA}}", getTwine2DataChunk(story, startName, options));
4490
+ const data = getTwine2DataChunk(story, startName, options);
4491
+ template = template.replace("{{STORY_DATA}}", () => data);
4490
4492
  }
4491
4493
  return template;
4492
4494
  }
@@ -4587,10 +4589,11 @@ function toTwine1HTML(story, format, startName) {
4587
4589
  const displayStart = startName === "Start" ? "" : startName;
4588
4590
  template = template.replace('"VERSION"', `Compiled with ${CREATOR_NAME2}, ${VERSION}`);
4589
4591
  template = template.replace('"TIME"', `Built on ${(/* @__PURE__ */ new Date()).toUTCString()}`);
4590
- template = template.replace('"START_AT"', `"${jsStringEscape(displayStart)}"`);
4592
+ const startAtValue = `"${jsStringEscape(displayStart)}"`;
4593
+ template = template.replace('"START_AT"', () => startAtValue);
4591
4594
  template = template.replace('"STORY_SIZE"', `"${count}"`);
4592
4595
  if (template.includes('"STORY"')) {
4593
- template = template.replace('"STORY"', data);
4596
+ template = template.replace('"STORY"', () => data);
4594
4597
  } else {
4595
4598
  let footer;
4596
4599
  try {
@@ -4626,7 +4629,7 @@ function tryReplaceComponent(template, placeholder, componentPath, required) {
4626
4629
  try {
4627
4630
  let content = readFileSync2(componentPath, "utf-8");
4628
4631
  if (content.charCodeAt(0) === 65279) content = content.slice(1);
4629
- return template.replace(placeholder, content);
4632
+ return template.replace(placeholder, () => content);
4630
4633
  } catch (e) {
4631
4634
  if (required) {
4632
4635
  throw new Error(
@@ -4714,7 +4717,8 @@ function modifyHead(html, modulePaths, headFile, diagnostics) {
4714
4717
  }
4715
4718
  if (parts.length > 0) {
4716
4719
  parts.push("</head>");
4717
- return html.replace("</head>", parts.join("\n"));
4720
+ const replacement = parts.join("\n");
4721
+ return html.replace("</head>", () => replacement);
4718
4722
  }
4719
4723
  return html;
4720
4724
  }