single-file-core 1.4.0 → 1.4.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.
@@ -30,6 +30,7 @@ const Blob = globalThis.Blob;
30
30
  const FileReader = globalThis.FileReader;
31
31
  const URL = globalThis.URL;
32
32
  const URLSearchParams = globalThis.URLSearchParams;
33
+ const navigator = globalThis.navigator;
33
34
 
34
35
  // eslint-disable-next-line quotes
35
36
  const DEFAULT_REPLACED_CHARACTERS = ["~", "+", "\\\\", "?", "%", "*", ":", "|", '"', "<", ">", "\x00-\x1f", "\x7F"];
@@ -16915,6 +16916,7 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
16915
16916
  urlSubDomains = "";
16916
16917
  }
16917
16918
  const variables = {
16919
+ "navigator-language": { getter: () => navigator.language },
16918
16920
  "page-title": { getter: () => options.title },
16919
16921
  "page-heading": { getter: () => options.info.heading },
16920
16922
  "page-language": { getter: () => options.info.lang },
@@ -17014,8 +17016,14 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
17014
17016
  "encode-uri": value => { try { return encodeURI(value); } catch (error) { return value; } },
17015
17017
  "decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
17016
17018
  "encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
17017
- "decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } }
17019
+ "decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
17020
+ "date-locale": locales => new Date().toLocaleDateString(locales),
17021
+ "time-locale": locales => new Date().toLocaleTimeString(locales),
17022
+ "datetime-locale": locales => new Date().toLocaleString(locales)
17018
17023
  };
17024
+ functions["date-locale"].dontReplaceSlash = false;
17025
+ functions["time-locale"].dontReplaceSlash = false;
17026
+ functions["datetime-locale"].dontReplaceSlash = false;
17019
17027
  if (doc) {
17020
17028
  functions["page-element-text"] = (selector) => {
17021
17029
  const element = doc.querySelector(selector);
@@ -17043,7 +17051,8 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
17043
17051
  .filter(argument => argument != undefined && argument != null && argument != "");
17044
17052
  if ((argument != undefined && argument != null && argument != "") || optionalArguments.length > 0) {
17045
17053
  try {
17046
- return await getValue(() => fn(argument, ...optionalArguments), true, options.filenameReplacementCharacter, lengthData);
17054
+ const dontReplaceSlash = fn.dontReplaceSlash === undefined ? true : fn.dontReplaceSlash;
17055
+ return await getValue(() => fn(argument, ...optionalArguments), dontReplaceSlash, options.filenameReplacementCharacter, lengthData);
17047
17056
  } catch (error) {
17048
17057
  return "";
17049
17058
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",