@yannosay/sinth 0.13.5 → 0.13.6

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/README.md CHANGED
@@ -45,7 +45,7 @@ No JSX ternaries. No v-if. No separate script tags. Mixed logic. Clean.
45
45
  ```ts
46
46
  page
47
47
 
48
- title = "Full Test"
48
+ title = "Functions"
49
49
 
50
50
  var str userName = "Sinths User"
51
51
 
@@ -96,7 +96,7 @@ Paragraph {
96
96
 
97
97
  ```ts
98
98
  page
99
- title = "Counter"
99
+ title = "Fullscreen"
100
100
 
101
101
  var bool isFullscreen = false
102
102
  var str userName = ""
@@ -111,8 +111,8 @@ Main {
111
111
  }
112
112
  Input(bind: userName)
113
113
  Paragraph {
114
- if userName == "Yannosay" {
115
- "YANNOSAY??? YOU?? :O"
114
+ if userName == "Sinth" {
115
+ "Oh, welcome back!"
116
116
  } else {
117
117
  "Hello, " + userName + "!"
118
118
  }
@@ -120,6 +120,19 @@ Main {
120
120
  }
121
121
  ```
122
122
 
123
+ #### Fullscreen Sync (0.13.6)
124
+
125
+ Opt-in Escape key handling. `fullscreenSync` keeps your variable in sync with the browser's fullscreen state.
126
+
127
+ ```ts
128
+ Button(onClick: isFullscreen = !isFullscreen, fullscreen: isFullscreen, fullscreenSync: isFullscreen) {
129
+ if isFullscreen { "Exit Fullscreen" } else { "Enter Fullscreen" }
130
+ }
131
+ ```
132
+ Without fullscreenSync, pressing Escape exits fullscreen but the variable stays true.
133
+ With it, Escape resets the variable to false — button text updates automatically.
134
+
135
+
123
136
  #### Animations that make sense.
124
137
  ```ts
125
138
  for item, index in items {
@@ -144,7 +157,23 @@ Delete elements for good. No virtual DOM diffing.
144
157
 
145
158
  Compiles to pure HTML.
146
159
 
147
- #### Ready to upload wherever you want.
160
+ #### Reactivity at its finest
161
+ ```ts
162
+ page
163
+ title = "Reactivity but easy"
164
+
165
+ var str begForFullscreen = ""
166
+ var bool doFullscreen = false
167
+
168
+ Main {
169
+ Input(bind: begForFullscreen, fullscreen: doFullscreen)
170
+ if begForFullscreen == "do fullscreen pls!!" {
171
+ doFullscreen = true
172
+ } else {
173
+ doFullscreen = false
174
+ }
175
+ }
176
+ ```
148
177
 
149
178
 
150
179
  # Install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "description": "A declarative & reactive language that compiles to pure HTML, CSS, and JavaScript.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
@@ -137,6 +137,22 @@ if (name === "delay") {
137
137
  return "";
138
138
  }
139
139
 
140
+ if (name === "fullscreenSync") {
141
+ if (value?.kind === "str") {
142
+ const raw = value.value;
143
+ if (raw.startsWith("__EXPR__")) {
144
+ try {
145
+ const expr: Expression = JSON.parse(raw.substring(8));
146
+ if (expr.kind === "variable" && expr.name) {
147
+ return `data-sinth-fullscreen-sync="${escAttr(expr.name)}"`;
148
+ }
149
+ } catch {}
150
+ }
151
+ return `data-sinth-fullscreen-sync="${escAttr(raw)}"`;
152
+ }
153
+ return "";
154
+ }
155
+
140
156
  if (name === "checked") {
141
157
  return (value as any)?.kind === "bool" && (value as any).value ? "checked" : "";
142
158
  }
@@ -744,8 +760,8 @@ export function buildRuntime(opts: {
744
760
  sharedRuntime: boolean;
745
761
  functionsJS: string;
746
762
  }): string | { page: string; shared: string } {
763
+
747
764
  const { varDecls, bodyHTML, logicBlocks, mixedBlocks, assignedVars, exprRegistry, functionsJS } = opts;
748
-
749
765
  const needsMixed = mixedBlocks.length > 0;
750
766
  const needsExpr = bodyHTML.includes("sinth-expr") || needsMixed;
751
767
  const needsIf = bodyHTML.includes("data-sinth-if") || needsMixed;
@@ -753,7 +769,8 @@ export function buildRuntime(opts: {
753
769
  const needsDelay = bodyHTML.includes("data-sinth-delay") || bodyHTML.includes("data-sinth-delay-expr-id") || mixedBlocks.some(mb => mb.ifHTML.includes("data-sinth-delay") || mb.ifHTML.includes("data-sinth-delay-expr-id") || mb.elseHTML.includes("data-sinth-delay") || mb.elseHTML.includes("data-sinth-delay-expr-id"));
754
770
  const needsLogic = logicBlocks.length > 0;
755
771
  const needsFullscreen = bodyHTML.includes("data-sinth-fullscreen");
756
- const needsRender = needsExpr || needsIf || needsFor || needsMixed || needsLogic || bodyHTML.includes("data-sinth-hide") || needsFullscreen;
772
+ const needsFullscreenSync = bodyHTML.includes("data-sinth-fullscreen-sync");
773
+ const needsRender = needsExpr || needsIf || needsFor || needsMixed || needsLogic || bodyHTML.includes("data-sinth-hide") || needsFullscreen || needsFullscreenSync;
757
774
 
758
775
  const varLines = varDecls.map(v => {
759
776
  if (!v.value) {
@@ -797,7 +814,24 @@ export function buildRuntime(opts: {
797
814
  ? `var __X = [${exprRegistry.map((js) => `function(_ctx){ return ${js}; }`).join(",")}];\n`
798
815
  : "";
799
816
 
800
- const renderFunc = needsRender ? `function sinthRender() {\n${renderBody}}\nsinthRender();` : "";
817
+ let renderFunc = needsRender ? `function sinthRender() {\n${renderBody}}\nsinthRender();` : "";
818
+
819
+ if (needsFullscreenSync) {
820
+ renderFunc += `
821
+ (function() {
822
+ var syncedEls = document.querySelectorAll('[data-sinth-fullscreen-sync]');
823
+ if (syncedEls.length > 0) {
824
+ var vars = [];
825
+ syncedEls.forEach(function(el) { vars.push(el.dataset.sinthFullscreenSync); });
826
+ document.addEventListener('fullscreenchange', function() {
827
+ if (!document.fullscreenElement) {
828
+ vars.forEach(function(v) { window[v] = false; });
829
+ sinthRender();
830
+ }
831
+ });
832
+ }
833
+ })();`;
834
+ }
801
835
 
802
836
  const pageCode = `// Sinth page runtime
803
837
  ${varLines}