@barefootjs/client 0.31.2 → 0.31.3
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/csr-adapter.js +84 -4
- package/package.json +2 -2
package/dist/csr-adapter.js
CHANGED
|
@@ -169725,6 +169725,83 @@ var toLocaleDatePlugin = {
|
|
|
169725
169725
|
}
|
|
169726
169726
|
};
|
|
169727
169727
|
|
|
169728
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
169729
|
+
class BindingScope {
|
|
169730
|
+
frames;
|
|
169731
|
+
static EMPTY = new BindingScope([]);
|
|
169732
|
+
constructor(frames) {
|
|
169733
|
+
this.frames = frames;
|
|
169734
|
+
}
|
|
169735
|
+
enterLoopRow(loop) {
|
|
169736
|
+
const bindings = new Map;
|
|
169737
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
169738
|
+
for (const b of loop.paramBindings)
|
|
169739
|
+
bindings.set(b.name, { source: "destructure" });
|
|
169740
|
+
} else {
|
|
169741
|
+
bindings.set(loop.param, { source: "item" });
|
|
169742
|
+
}
|
|
169743
|
+
if (loop.index != null)
|
|
169744
|
+
bindings.set(loop.index, { source: "index" });
|
|
169745
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
169746
|
+
bindings.set(name, { source: "preamble" });
|
|
169747
|
+
const frame = { kind: "loop-row", bindings };
|
|
169748
|
+
return new BindingScope([frame, ...this.frames]);
|
|
169749
|
+
}
|
|
169750
|
+
enterCallback(params) {
|
|
169751
|
+
const bindings = new Map;
|
|
169752
|
+
for (const name of params)
|
|
169753
|
+
bindings.set(name, { source: "param" });
|
|
169754
|
+
const frame = { kind: "callback", bindings };
|
|
169755
|
+
return new BindingScope([frame, ...this.frames]);
|
|
169756
|
+
}
|
|
169757
|
+
isBound(name) {
|
|
169758
|
+
for (const frame of this.frames) {
|
|
169759
|
+
if (frame.bindings.has(name))
|
|
169760
|
+
return true;
|
|
169761
|
+
}
|
|
169762
|
+
return false;
|
|
169763
|
+
}
|
|
169764
|
+
lookup(name) {
|
|
169765
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
169766
|
+
const frame = this.frames[depth];
|
|
169767
|
+
const binding = frame.bindings.get(name);
|
|
169768
|
+
if (binding)
|
|
169769
|
+
return { depth, frame, binding };
|
|
169770
|
+
}
|
|
169771
|
+
return null;
|
|
169772
|
+
}
|
|
169773
|
+
boundNames() {
|
|
169774
|
+
if (this.boundNamesCache)
|
|
169775
|
+
return this.boundNamesCache;
|
|
169776
|
+
const names = new Set;
|
|
169777
|
+
for (const frame of this.frames) {
|
|
169778
|
+
for (const name of frame.bindings.keys())
|
|
169779
|
+
names.add(name);
|
|
169780
|
+
}
|
|
169781
|
+
this.boundNamesCache = names;
|
|
169782
|
+
return names;
|
|
169783
|
+
}
|
|
169784
|
+
boundNamesCache;
|
|
169785
|
+
valueBoundNamesCache;
|
|
169786
|
+
valueBoundNames() {
|
|
169787
|
+
if (this.valueBoundNamesCache)
|
|
169788
|
+
return this.valueBoundNamesCache;
|
|
169789
|
+
const names = new Set;
|
|
169790
|
+
for (const frame of this.frames) {
|
|
169791
|
+
for (const [name, binding] of frame.bindings) {
|
|
169792
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
169793
|
+
names.add(name);
|
|
169794
|
+
}
|
|
169795
|
+
}
|
|
169796
|
+
}
|
|
169797
|
+
this.valueBoundNamesCache = names;
|
|
169798
|
+
return names;
|
|
169799
|
+
}
|
|
169800
|
+
asShadowPredicate() {
|
|
169801
|
+
return (name) => this.isBound(name);
|
|
169802
|
+
}
|
|
169803
|
+
}
|
|
169804
|
+
|
|
169728
169805
|
// ../jsx/src/jsx-to-ir.ts
|
|
169729
169806
|
var EMPTY_BOUND = new Set;
|
|
169730
169807
|
var constInitializerCache = new WeakMap;
|
|
@@ -170281,7 +170358,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
170281
170358
|
continue;
|
|
170282
170359
|
const keyword = constant.declarationKind ?? "const";
|
|
170283
170360
|
if (!constant.value) {
|
|
170284
|
-
const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type
|
|
170361
|
+
const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
|
|
170285
170362
|
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
170286
170363
|
continue;
|
|
170287
170364
|
}
|
|
@@ -170291,7 +170368,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
170291
170368
|
if (!reachable.has(constant.name))
|
|
170292
170369
|
continue;
|
|
170293
170370
|
const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
170294
|
-
|
|
170371
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
170372
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
|
|
170295
170373
|
}
|
|
170296
170374
|
for (const func of localFunctions) {
|
|
170297
170375
|
if (moduleScopeNames.has(func.name))
|
|
@@ -170398,7 +170476,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
170398
170476
|
const keyword = c.declarationKind ?? "const";
|
|
170399
170477
|
const exportKw = c.isExported ? "export " : "";
|
|
170400
170478
|
if (!c.value) {
|
|
170401
|
-
|
|
170479
|
+
const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
|
|
170480
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
|
|
170402
170481
|
continue;
|
|
170403
170482
|
}
|
|
170404
170483
|
const trimmed = c.value.trim();
|
|
@@ -170407,7 +170486,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
170407
170486
|
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
170408
170487
|
continue;
|
|
170409
170488
|
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
170410
|
-
|
|
170489
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
|
|
170490
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
|
|
170411
170491
|
}
|
|
170412
170492
|
for (const f of ir.metadata.localFunctions) {
|
|
170413
170493
|
if (!f.isModule || !moduleNames.has(f.name))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/client",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
4
4
|
"description": "BarefootJS client package: reactive primitives (SSR-safe) plus browser runtime under the `/runtime` subpath (compiler target)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"directory": "packages/client"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@barefootjs/shared": "0.31.
|
|
58
|
+
"@barefootjs/shared": "0.31.3"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@barefootjs/jsx": ">=0.2.0"
|