@yannosay/sinth 3.1.0 → 4.1.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/dist/server.js CHANGED
@@ -54,7 +54,9 @@ async function startDevServer(opts) {
54
54
  try {
55
55
  c.write("data: reload\n\n");
56
56
  }
57
- catch { }
57
+ catch {
58
+ void 0;
59
+ }
58
60
  }
59
61
  }
60
62
  function compileAll() {
@@ -104,7 +106,9 @@ async function startDevServer(opts) {
104
106
  });
105
107
  watchReady = true;
106
108
  }
107
- catch { }
109
+ catch {
110
+ void 0;
111
+ }
108
112
  if (!watchReady) {
109
113
  const mtimes = new Map();
110
114
  const poller = setInterval(() => {
@@ -121,7 +125,9 @@ async function startDevServer(opts) {
121
125
  break;
122
126
  }
123
127
  }
124
- catch { }
128
+ catch {
129
+ void 0;
130
+ }
125
131
  }
126
132
  }, 500);
127
133
  process.on("exit", () => clearInterval(poller));
@@ -47,7 +47,9 @@ function readCache() {
47
47
  return JSON.parse(fs.readFileSync(CACHE_FILE, "utf-8"));
48
48
  }
49
49
  }
50
- catch { }
50
+ catch {
51
+ void 0;
52
+ }
51
53
  return null;
52
54
  }
53
55
  function writeCache() {
@@ -55,7 +57,9 @@ function writeCache() {
55
57
  fs.mkdirSync(CACHE_DIR, { recursive: true });
56
58
  fs.writeFileSync(CACHE_FILE, JSON.stringify({ lastCheck: Date.now() }));
57
59
  }
58
- catch { }
60
+ catch {
61
+ void 0;
62
+ }
59
63
  }
60
64
  function fetchLatestVersion() {
61
65
  return new Promise((resolve) => {
package/dist/utils.js CHANGED
@@ -9,6 +9,13 @@ exports.litToString = litToString;
9
9
  exports.interpolateAttr = interpolateAttr;
10
10
  exports.renderText = renderText;
11
11
  const types_1 = require("./core/types");
12
+ const PLACEHOLDER_PREFIX = "__SINTH_PH_";
13
+ let _phCounter = 0;
14
+ function createPlaceholder(tag) {
15
+ return `${PLACEHOLDER_PREFIX}${tag}_${_phCounter++}_${Date.now().toString(36)}__`;
16
+ }
17
+ const ESCAPED_LEFT_BRACE = createPlaceholder("LB");
18
+ const ESCAPED_DOLLAR = createPlaceholder("DOLLAR");
12
19
  function fnv1a(s) {
13
20
  let h = 0x811c9dc5;
14
21
  for (let i = 0; i < s.length; i++) {
@@ -41,29 +48,29 @@ function litToString(lit) {
41
48
  }
42
49
  }
43
50
  function interpolateAttr(text, params) {
44
- let s = text.replace(/\\\{/g, "\x00LB\x00");
51
+ let s = text.replace(/\\\{/g, ESCAPED_LEFT_BRACE);
45
52
  s = s.replace(/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g, (_, n) => params.get(n) ?? `{${n}}`);
46
- return s.replace(/\x00LB\x00/g, "{");
53
+ return s.replace(new RegExp(ESCAPED_LEFT_BRACE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), "{");
47
54
  }
48
55
  function renderText(text, params) {
49
56
  const rawSlots = new Map();
50
- let counter = 0;
51
- let s = text.replace(/\\\$/g, "\x00DOLLAR\x00");
57
+ let s = text.replace(/\\\$/g, ESCAPED_DOLLAR);
52
58
  s = s.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g, (_, n) => {
53
59
  const val = params.get(n);
54
60
  if (val === undefined)
55
61
  return `$${n}`;
56
62
  if (n === "slot") {
57
- const ph = `\x00RAW${counter++}\x00`;
63
+ const ph = createPlaceholder("RAW");
58
64
  rawSlots.set(ph, val);
59
65
  return ph;
60
66
  }
61
67
  return val;
62
68
  });
63
69
  s = esc(s);
64
- for (const [ph, val] of rawSlots)
65
- s = s.replace(ph, val);
66
- s = s.replace(/\x00DOLLAR\x00/g, "$");
70
+ for (const [ph, val] of rawSlots) {
71
+ s = s.replace(new RegExp(ph.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), val);
72
+ }
73
+ s = s.replace(new RegExp(ESCAPED_DOLLAR.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), "$");
67
74
  const braceRe = /\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;
68
75
  let m;
69
76
  while ((m = braceRe.exec(s)) !== null) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "3.1.0",
4
- "description": "A declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
3
+ "version": "4.1.0",
4
+ "description": "An easy, powerful, declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
7
7
  "homepage": "https://sinth.yannosay.com",
@@ -36,12 +36,19 @@
36
36
  ],
37
37
  "scripts": {
38
38
  "build": "tsc",
39
+ "lint": "eslint src --ext .ts",
40
+ "lint:fix": "eslint src --ext .ts --fix",
39
41
  "prepublishOnly": "npm run build"
40
42
  },
41
43
  "devDependencies": {
44
+ "@eslint/js": "^10.0.1",
42
45
  "@types/node": "^25.9.3",
46
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
47
+ "@typescript-eslint/parser": "^8.61.0",
48
+ "eslint": "^10.5.0",
43
49
  "ts-node": "^10.9.0",
44
- "typescript": "^5.3.0"
50
+ "typescript": "^5.3.0",
51
+ "typescript-eslint": "^8.61.0"
45
52
  },
46
53
  "engines": {
47
54
  "node": ">=18.0.0"