rip-lang 3.12.3 → 3.12.5
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 +1 -1
- package/docs/demo.html +1017 -0
- package/docs/dist/rip.js +9483 -0
- package/docs/dist/rip.min.js +48 -48
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/app.rip +10 -4
- package/src/components.js +3 -2
- package/src/lexer.js +12 -0
- package/src/typecheck.js +31 -7
package/docs/dist/rip.min.js.br
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/app.rip
CHANGED
|
@@ -688,7 +688,7 @@ export createRenderer = (opts = {}) ->
|
|
|
688
688
|
for inst in layoutInstances by -1
|
|
689
689
|
inst.beforeUnmount() if inst.beforeUnmount
|
|
690
690
|
inst.unmounted() if inst.unmounted
|
|
691
|
-
inst.
|
|
691
|
+
inst._target?.remove()
|
|
692
692
|
layoutInstances = []
|
|
693
693
|
mountPoint = container
|
|
694
694
|
|
|
@@ -724,7 +724,7 @@ export createRenderer = (opts = {}) ->
|
|
|
724
724
|
return
|
|
725
725
|
|
|
726
726
|
layoutsChanged = not arraysEqual(layoutFiles, currentLayouts)
|
|
727
|
-
|
|
727
|
+
oldTarget = currentComponent?._target
|
|
728
728
|
|
|
729
729
|
if layoutsChanged
|
|
730
730
|
unmount()
|
|
@@ -768,7 +768,7 @@ export createRenderer = (opts = {}) ->
|
|
|
768
768
|
cached = componentCache.get(route.file)
|
|
769
769
|
if cached
|
|
770
770
|
componentCache.delete route.file
|
|
771
|
-
mp.appendChild cached.
|
|
771
|
+
mp.appendChild cached._target
|
|
772
772
|
currentComponent = cached
|
|
773
773
|
currentRoute = route.file
|
|
774
774
|
else
|
|
@@ -783,7 +783,7 @@ export createRenderer = (opts = {}) ->
|
|
|
783
783
|
currentRoute = route.file
|
|
784
784
|
|
|
785
785
|
instance.load!(params, query) if instance.load
|
|
786
|
-
|
|
786
|
+
oldTarget?.remove()
|
|
787
787
|
router.navigating = false
|
|
788
788
|
if container.style.opacity is '0'
|
|
789
789
|
document.fonts.ready.then ->
|
|
@@ -857,6 +857,12 @@ connectWatch = (url) ->
|
|
|
857
857
|
console.log '[Rip] Reloading...'
|
|
858
858
|
location.reload()
|
|
859
859
|
|
|
860
|
+
es.addEventListener 'css', ->
|
|
861
|
+
for link as document.querySelectorAll('link[rel="stylesheet"]')
|
|
862
|
+
url = new URL(link.href)
|
|
863
|
+
url.searchParams.set('_t', Date.now())
|
|
864
|
+
link.href = url.toString()
|
|
865
|
+
|
|
860
866
|
es.onerror = ->
|
|
861
867
|
es.close()
|
|
862
868
|
setTimeout connect, retryDelay
|
package/src/components.js
CHANGED
|
@@ -729,13 +729,14 @@ export function installComponentSupport(CodeGenerator, Lexer) {
|
|
|
729
729
|
// Effects
|
|
730
730
|
for (const effect of effects) {
|
|
731
731
|
const effectBody = effect[2];
|
|
732
|
+
const isAsync = this.containsAwait(effectBody) ? 'async ' : '';
|
|
732
733
|
if (this.is(effectBody, 'block') && effectBody.length > 2) {
|
|
733
734
|
const transformed = this.transformComponentMembers(effectBody);
|
|
734
735
|
const body = this.generateFunctionBody(transformed, [], true);
|
|
735
|
-
lines.push(` __effect(() => ${body});`);
|
|
736
|
+
lines.push(` __effect(${isAsync}() => ${body});`);
|
|
736
737
|
} else {
|
|
737
738
|
const effectCode = this.generateInComponent(effectBody, 'value');
|
|
738
|
-
lines.push(` __effect(() => { ${effectCode}; });`);
|
|
739
|
+
lines.push(` __effect(${isAsync}() => { ${effectCode}; });`);
|
|
739
740
|
}
|
|
740
741
|
}
|
|
741
742
|
|
package/src/lexer.js
CHANGED
|
@@ -768,6 +768,18 @@ export class Lexer {
|
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
|
+
// A > that closes a generic type annotation is NOT a continuation
|
|
772
|
+
let prev = this.tokens[this.tokens.length - 1];
|
|
773
|
+
if (prev?.[0] === 'COMPARE' && prev[1] === '>') {
|
|
774
|
+
let depth = 0;
|
|
775
|
+
for (let k = this.tokens.length - 1; k >= 0; k--) {
|
|
776
|
+
let tk = this.tokens[k];
|
|
777
|
+
if (tk[0] === 'COMPARE' && tk[1] === '>') depth++;
|
|
778
|
+
else if (tk[0] === 'COMPARE' && tk[1] === '<') depth--;
|
|
779
|
+
if (depth === 0 && tk[0] === 'TYPE_ANNOTATION') return false;
|
|
780
|
+
if (tk[0] === 'TERMINATOR' || tk[0] === 'INDENT' || tk[0] === 'OUTDENT') break;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
771
783
|
return LINE_CONTINUER_RE.test(this.chunk) || UNFINISHED.has(this.prevTag());
|
|
772
784
|
}
|
|
773
785
|
|
package/src/typecheck.js
CHANGED
|
@@ -181,26 +181,50 @@ export function compileForCheck(filePath, source, compiler) {
|
|
|
181
181
|
// Build bidirectional line maps
|
|
182
182
|
const { srcToGen, genToSrc } = buildLineMap(result.reverseMap, result.map, headerLines);
|
|
183
183
|
|
|
184
|
-
// Map DTS
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
// variable names to source lines with `x::`.
|
|
184
|
+
// Map DTS declaration lines back to source lines (bidirectional).
|
|
185
|
+
// Covers: let/var declarations, type aliases, interfaces, enums, classes.
|
|
186
|
+
// This enables hover, go-to-definition, and diagnostics for type-only code.
|
|
188
187
|
if (hasTypes && dts) {
|
|
189
188
|
const dtsLines = dts.split('\n');
|
|
190
189
|
const srcLines = source.split('\n');
|
|
191
190
|
for (let i = 0; i < dtsLines.length; i++) {
|
|
192
|
-
const
|
|
191
|
+
const line = dtsLines[i];
|
|
192
|
+
const m = line.match(/^(?:export\s+)?(?:declare\s+)?(?:let|var|type|interface|enum|class)\s+(\w+)/);
|
|
193
193
|
if (!m) continue;
|
|
194
|
-
const
|
|
194
|
+
const name = m[1];
|
|
195
195
|
for (let s = 0; s < srcLines.length; s++) {
|
|
196
|
-
|
|
196
|
+
const src = srcLines[s];
|
|
197
|
+
if (new RegExp('\\b' + name + '\\s*(?:::=|::)').test(src) ||
|
|
198
|
+
new RegExp('^(?:export\\s+)?interface\\s+' + name + '\\b').test(src) ||
|
|
199
|
+
new RegExp('^(?:export\\s+)?enum\\s+' + name + '\\b').test(src) ||
|
|
200
|
+
new RegExp('^(?:export\\s+)?' + name + '\\s*=\\s*component\\b').test(src)) {
|
|
197
201
|
genToSrc.set(i, s);
|
|
202
|
+
srcToGen.set(s, i);
|
|
198
203
|
break;
|
|
199
204
|
}
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
|
|
209
|
+
// Interpolate gaps — if src line A maps to gen line X and src line B maps to
|
|
210
|
+
// gen line Y, fill src lines A+1..B-1 → gen lines X+1..Y-1. This gives hover
|
|
211
|
+
// and diagnostics coverage for function body lines that the compiler didn't map.
|
|
212
|
+
const mapped = [...srcToGen.entries()].sort((a, b) => a[0] - b[0]);
|
|
213
|
+
for (let i = 0; i < mapped.length - 1; i++) {
|
|
214
|
+
const [srcA, genA] = mapped[i];
|
|
215
|
+
const [srcB, genB] = mapped[i + 1];
|
|
216
|
+
const srcGap = srcB - srcA;
|
|
217
|
+
const genGap = genB - genA;
|
|
218
|
+
if (srcGap > 1 && genGap > 1 && srcGap <= genGap + 2) {
|
|
219
|
+
for (let d = 1; d < srcGap; d++) {
|
|
220
|
+
if (!srcToGen.has(srcA + d) && genA + d < genB) {
|
|
221
|
+
srcToGen.set(srcA + d, genA + d);
|
|
222
|
+
genToSrc.set(genA + d, srcA + d);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
204
228
|
return { tsContent, headerLines, hasTypes, srcToGen, genToSrc, source };
|
|
205
229
|
}
|
|
206
230
|
|