rip-lang 3.10.10 → 3.10.12
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/CHANGELOG.md +6 -0
- package/README.md +19 -16
- package/docs/dist/rip-ui.min.js +4 -7
- package/docs/dist/rip-ui.min.js.br +0 -0
- package/docs/dist/rip.browser.min.js +4 -7
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/docs/index.html +15 -11
- package/docs/results/index.html +30 -17
- package/package.json +1 -1
- package/src/compiler.js +3 -4
- package/src/components.js +8 -2
|
Binary file
|
package/docs/index.html
CHANGED
|
@@ -520,8 +520,9 @@
|
|
|
520
520
|
<div class="tabs">
|
|
521
521
|
<button class="tab active" data-tab="compiler"><span class="tab-full">Live Compiler</span><span class="tab-short">Compiler</span></button>
|
|
522
522
|
<button class="tab" data-tab="repl"><span class="tab-full">REPL Console</span><span class="tab-short">REPL</span></button>
|
|
523
|
-
<button class="tab" data-tab="demo">Demo</button>
|
|
524
523
|
<button class="tab" data-tab="example">Example</button>
|
|
524
|
+
<button class="tab" data-tab="sierpinski">Sierpinski</button>
|
|
525
|
+
<button class="tab" data-tab="demo" title="Opens in new tab">Demo ⧉</button>
|
|
525
526
|
</div>
|
|
526
527
|
|
|
527
528
|
<!-- Content -->
|
|
@@ -600,9 +601,9 @@
|
|
|
600
601
|
</div>
|
|
601
602
|
</div>
|
|
602
603
|
|
|
603
|
-
<!--
|
|
604
|
-
<div class="pane" id="
|
|
605
|
-
<iframe id="
|
|
604
|
+
<!-- Sierpinski Pane -->
|
|
605
|
+
<div class="pane" id="sierpinski-pane">
|
|
606
|
+
<iframe id="sierpinski-iframe" style="width: 100%; height: 100%; border: none;"></iframe>
|
|
606
607
|
</div>
|
|
607
608
|
|
|
608
609
|
<!-- Example Pane -->
|
|
@@ -1124,10 +1125,13 @@
|
|
|
1124
1125
|
# Tab Switching
|
|
1125
1126
|
# ====================================================================
|
|
1126
1127
|
|
|
1127
|
-
|
|
1128
|
+
sierpinskiLoaded = false
|
|
1128
1129
|
exampleLoaded = false
|
|
1129
1130
|
|
|
1130
1131
|
def switchToTab(tabName)
|
|
1132
|
+
if tabName is 'demo'
|
|
1133
|
+
window.open 'https://shreeve.github.io/rip-lang/results/', '_blank'
|
|
1134
|
+
return
|
|
1131
1135
|
window.location.hash = tabName
|
|
1132
1136
|
document.querySelectorAll('.tab').forEach (t) -> t.classList.remove 'active'
|
|
1133
1137
|
document.querySelector(".tab[data-tab='#{tabName}']").classList.add 'active'
|
|
@@ -1139,10 +1143,10 @@
|
|
|
1139
1143
|
else if tabName is 'compiler'
|
|
1140
1144
|
setTheme! themeSelect.value
|
|
1141
1145
|
compileCode()
|
|
1142
|
-
else if tabName is '
|
|
1143
|
-
unless
|
|
1144
|
-
document.getElementById('
|
|
1145
|
-
|
|
1146
|
+
else if tabName is 'sierpinski'
|
|
1147
|
+
unless sierpinskiLoaded
|
|
1148
|
+
document.getElementById('sierpinski-iframe').src = 'sierpinski.html'
|
|
1149
|
+
sierpinskiLoaded = true
|
|
1146
1150
|
else if tabName is 'example'
|
|
1147
1151
|
unless exampleLoaded
|
|
1148
1152
|
document.getElementById('example-iframe').src = 'example/'
|
|
@@ -1153,7 +1157,7 @@
|
|
|
1153
1157
|
|
|
1154
1158
|
window.addEventListener 'hashchange', ->
|
|
1155
1159
|
hash = window.location.hash.slice 1
|
|
1156
|
-
switchToTab hash if hash is 'compiler' or hash is 'repl' or hash is '
|
|
1160
|
+
switchToTab hash if hash is 'compiler' or hash is 'repl' or hash is 'sierpinski' or hash is 'example'
|
|
1157
1161
|
|
|
1158
1162
|
# ====================================================================
|
|
1159
1163
|
# Resizable Panes
|
|
@@ -1471,7 +1475,7 @@
|
|
|
1471
1475
|
|
|
1472
1476
|
# Initialize from URL hash (default to compiler)
|
|
1473
1477
|
initialTab = window.location.hash.slice 1
|
|
1474
|
-
if initialTab is 'compiler' or initialTab is 'repl' or initialTab is '
|
|
1478
|
+
if initialTab is 'compiler' or initialTab is 'repl' or initialTab is 'sierpinski' or initialTab is 'example'
|
|
1475
1479
|
switchToTab! initialTab
|
|
1476
1480
|
else
|
|
1477
1481
|
compileCode()
|
package/docs/results/index.html
CHANGED
|
@@ -566,8 +566,10 @@ body {
|
|
|
566
566
|
.gauge__value { font-size: 18px; color: white; bottom: 26px; }
|
|
567
567
|
.gauge__units { font-size: 13px; color: rgba(255,255,255,.9); bottom: 13px; }
|
|
568
568
|
|
|
569
|
+
@page { size: letter; margin: 0; }
|
|
570
|
+
|
|
569
571
|
@media print {
|
|
570
|
-
body { background: white; }
|
|
572
|
+
body { margin: 0; background: white; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
571
573
|
|
|
572
574
|
.header, .sidebar, .drawer, .drawer-overlay, .btn-primary,
|
|
573
575
|
.settings__section { display: none !important; }
|
|
@@ -578,16 +580,15 @@ body {
|
|
|
578
580
|
.brochure { width: 100%; box-shadow: none; }
|
|
579
581
|
|
|
580
582
|
.brochure__page {
|
|
581
|
-
width:
|
|
582
|
-
height:
|
|
583
|
-
position: absolute;
|
|
584
|
-
top: 0; left: 0;
|
|
585
|
-
margin: auto;
|
|
583
|
+
width: 8.5in;
|
|
584
|
+
min-height: 11in;
|
|
586
585
|
border: none;
|
|
587
|
-
|
|
586
|
+
overflow: hidden;
|
|
587
|
+
break-before: page;
|
|
588
|
+
break-inside: avoid;
|
|
588
589
|
}
|
|
589
590
|
|
|
590
|
-
.brochure__page:first-child {
|
|
591
|
+
.brochure__page:first-child { break-before: auto; }
|
|
591
592
|
}
|
|
592
593
|
</style>
|
|
593
594
|
</head>
|
|
@@ -610,7 +611,7 @@ export Home = component
|
|
|
610
611
|
gender := 'Male'
|
|
611
612
|
|
|
612
613
|
history := [
|
|
613
|
-
date: '
|
|
614
|
+
date: "#{new Date().getFullYear()}-#{String(new Date().getMonth() + 1).padStart(2, '0')}"
|
|
614
615
|
triglycerides: 181
|
|
615
616
|
hdlCholesterol: 44
|
|
616
617
|
totalCholesterol: 177
|
|
@@ -815,6 +816,17 @@ export Settings = component
|
|
|
815
816
|
label "Hemoglobin A1c (%)"
|
|
816
817
|
input type: 'number', step: '0.1', value <=> history[0].a1c
|
|
817
818
|
|
|
819
|
+
if history?[0]?.waistCircumference
|
|
820
|
+
.settings__section
|
|
821
|
+
.settings__heading "Physical Measurements"
|
|
822
|
+
.settings__fields
|
|
823
|
+
.settings__field
|
|
824
|
+
label "Waist Circumference (in)"
|
|
825
|
+
input type: 'number', value <=> history[0].waistCircumference
|
|
826
|
+
.settings__field
|
|
827
|
+
label "Blood Pressure (mm/Hg)"
|
|
828
|
+
input type: 'text', value <=> history[0].bloodPressure
|
|
829
|
+
|
|
818
830
|
button.btn-primary "Print PDF"
|
|
819
831
|
@click: -> window.print()
|
|
820
832
|
</script>
|
|
@@ -914,9 +926,10 @@ export Summary = component
|
|
|
914
926
|
"#{mo}/#{dy}/#{yr}"
|
|
915
927
|
|
|
916
928
|
historyDate ~=
|
|
917
|
-
return '' unless history
|
|
918
|
-
|
|
919
|
-
|
|
929
|
+
return '' unless history?[0]?.date
|
|
930
|
+
months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
|
931
|
+
[yr, mo] = history[0].date.split('-')
|
|
932
|
+
"#{months[parseInt(mo, 10) - 1]} #{yr}"
|
|
920
933
|
|
|
921
934
|
checkIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>'
|
|
922
935
|
warnIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>'
|
|
@@ -993,11 +1006,11 @@ export DetailPage = component
|
|
|
993
1006
|
history?[0]?[topic.conditional]?
|
|
994
1007
|
|
|
995
1008
|
tipIcons :=
|
|
996
|
-
utensils: '<svg width="
|
|
997
|
-
drop: '<svg width="
|
|
998
|
-
walk: '<svg width="
|
|
999
|
-
doctor: '<svg width="
|
|
1000
|
-
smile: '<svg width="
|
|
1009
|
+
utensils: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><path d="M7 2v20"/><path d="M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/></svg>'
|
|
1010
|
+
drop: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z"/></svg>'
|
|
1011
|
+
walk: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5" r="1"/><path d="m9 20 3-6 3 6"/><path d="m6 8 6 2 6-2"/><path d="M12 10v4"/></svg>'
|
|
1012
|
+
doctor: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11 2v2"/><path d="M5 2v2"/><path d="M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1"/><path d="M8 15a6 6 0 0 0 12 0v-3"/><circle cx="20" cy="10" r="2"/></svg>'
|
|
1013
|
+
smile: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" x2="9.01" y1="9" y2="9"/><line x1="15" x2="15.01" y1="9" y2="9"/></svg>'
|
|
1001
1014
|
|
|
1002
1015
|
checkIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>'
|
|
1003
1016
|
warnIcon := '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>'
|
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -371,7 +371,7 @@ export class CodeGenerator {
|
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
if (head === 'def' || head === '->' || head === '=>') return;
|
|
374
|
+
if (head === 'def' || head === '->' || head === '=>' || head === 'effect') return;
|
|
375
375
|
|
|
376
376
|
if (head === 'if') {
|
|
377
377
|
let [condition, thenBranch, elseBranch] = rest;
|
|
@@ -423,7 +423,7 @@ export class CodeGenerator {
|
|
|
423
423
|
collect(value);
|
|
424
424
|
return;
|
|
425
425
|
}
|
|
426
|
-
if (head === 'def' || head === '->' || head === '=>') return;
|
|
426
|
+
if (head === 'def' || head === '->' || head === '=>' || head === 'effect') return;
|
|
427
427
|
if (head === 'try') {
|
|
428
428
|
collect(rest[0]);
|
|
429
429
|
if (rest.length >= 2 && Array.isArray(rest[1]) && rest[1].length === 2 && rest[1][0] !== 'block') {
|
|
@@ -1110,8 +1110,7 @@ export class CodeGenerator {
|
|
|
1110
1110
|
this.usesReactivity = true;
|
|
1111
1111
|
let bodyCode;
|
|
1112
1112
|
if (this.is(body, 'block')) {
|
|
1113
|
-
|
|
1114
|
-
bodyCode = `{\n${stmts.join('\n')}\n${this.indent()}}`;
|
|
1113
|
+
bodyCode = this.generateFunctionBody(body);
|
|
1115
1114
|
} else if ((this.is(body, '->') || this.is(body, '=>'))) {
|
|
1116
1115
|
let fnCode = this.generate(body, 'value');
|
|
1117
1116
|
if (target) return `const ${str(target) ?? this.generate(target, 'value')} = __effect(${fnCode})`;
|
package/src/components.js
CHANGED
|
@@ -688,8 +688,14 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
688
688
|
// Effects
|
|
689
689
|
for (const effect of effects) {
|
|
690
690
|
const effectBody = effect[2];
|
|
691
|
-
|
|
692
|
-
|
|
691
|
+
if (this.is(effectBody, 'block') && effectBody.length > 2) {
|
|
692
|
+
const transformed = this.transformComponentMembers(effectBody);
|
|
693
|
+
const body = this.generateFunctionBody(transformed, [], true);
|
|
694
|
+
lines.push(` __effect(() => ${body});`);
|
|
695
|
+
} else {
|
|
696
|
+
const effectCode = this.generateInComponent(effectBody, 'value');
|
|
697
|
+
lines.push(` __effect(() => { ${effectCode}; });`);
|
|
698
|
+
}
|
|
693
699
|
}
|
|
694
700
|
|
|
695
701
|
lines.push(' }');
|