@barefootjs/erb 0.31.3 → 0.31.4
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/vite.js +100 -85
- package/package.json +5 -5
package/dist/vite.js
CHANGED
|
@@ -1948,6 +1948,20 @@ function templatePartsToJsExpr(parts, opts) {
|
|
|
1948
1948
|
return result;
|
|
1949
1949
|
}
|
|
1950
1950
|
|
|
1951
|
+
// ../jsx/src/identifier-pattern.ts
|
|
1952
|
+
function withUnicodeFlag(flags) {
|
|
1953
|
+
return flags.includes("u") ? flags : `${flags}u`;
|
|
1954
|
+
}
|
|
1955
|
+
function escapeIdentifierForRegex(name) {
|
|
1956
|
+
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1957
|
+
}
|
|
1958
|
+
var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
|
|
1959
|
+
var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
|
|
1960
|
+
function identifierPattern(name, flags = "") {
|
|
1961
|
+
const esc = escapeIdentifierForRegex(name);
|
|
1962
|
+
return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1951
1965
|
// ../jsx/src/scanner/js-scanner.ts
|
|
1952
1966
|
import ts2 from "typescript";
|
|
1953
1967
|
|
|
@@ -2065,6 +2079,83 @@ function derivesScopeFromSlot(comp) {
|
|
|
2065
2079
|
return comp.slotId != null && comp.loopItemRoot !== true;
|
|
2066
2080
|
}
|
|
2067
2081
|
|
|
2082
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
2083
|
+
class BindingScope {
|
|
2084
|
+
frames;
|
|
2085
|
+
static EMPTY = new BindingScope([]);
|
|
2086
|
+
constructor(frames) {
|
|
2087
|
+
this.frames = frames;
|
|
2088
|
+
}
|
|
2089
|
+
enterLoopRow(loop) {
|
|
2090
|
+
const bindings = new Map;
|
|
2091
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2092
|
+
for (const b of loop.paramBindings)
|
|
2093
|
+
bindings.set(b.name, { source: "destructure" });
|
|
2094
|
+
} else {
|
|
2095
|
+
bindings.set(loop.param, { source: "item" });
|
|
2096
|
+
}
|
|
2097
|
+
if (loop.index != null)
|
|
2098
|
+
bindings.set(loop.index, { source: "index" });
|
|
2099
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2100
|
+
bindings.set(name, { source: "preamble" });
|
|
2101
|
+
const frame = { kind: "loop-row", bindings };
|
|
2102
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2103
|
+
}
|
|
2104
|
+
enterCallback(params) {
|
|
2105
|
+
const bindings = new Map;
|
|
2106
|
+
for (const name of params)
|
|
2107
|
+
bindings.set(name, { source: "param" });
|
|
2108
|
+
const frame = { kind: "callback", bindings };
|
|
2109
|
+
return new BindingScope([frame, ...this.frames]);
|
|
2110
|
+
}
|
|
2111
|
+
isBound(name) {
|
|
2112
|
+
for (const frame of this.frames) {
|
|
2113
|
+
if (frame.bindings.has(name))
|
|
2114
|
+
return true;
|
|
2115
|
+
}
|
|
2116
|
+
return false;
|
|
2117
|
+
}
|
|
2118
|
+
lookup(name) {
|
|
2119
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2120
|
+
const frame = this.frames[depth];
|
|
2121
|
+
const binding = frame.bindings.get(name);
|
|
2122
|
+
if (binding)
|
|
2123
|
+
return { depth, frame, binding };
|
|
2124
|
+
}
|
|
2125
|
+
return null;
|
|
2126
|
+
}
|
|
2127
|
+
boundNames() {
|
|
2128
|
+
if (this.boundNamesCache)
|
|
2129
|
+
return this.boundNamesCache;
|
|
2130
|
+
const names = new Set;
|
|
2131
|
+
for (const frame of this.frames) {
|
|
2132
|
+
for (const name of frame.bindings.keys())
|
|
2133
|
+
names.add(name);
|
|
2134
|
+
}
|
|
2135
|
+
this.boundNamesCache = names;
|
|
2136
|
+
return names;
|
|
2137
|
+
}
|
|
2138
|
+
boundNamesCache;
|
|
2139
|
+
valueBoundNamesCache;
|
|
2140
|
+
valueBoundNames() {
|
|
2141
|
+
if (this.valueBoundNamesCache)
|
|
2142
|
+
return this.valueBoundNamesCache;
|
|
2143
|
+
const names = new Set;
|
|
2144
|
+
for (const frame of this.frames) {
|
|
2145
|
+
for (const [name, binding] of frame.bindings) {
|
|
2146
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2147
|
+
names.add(name);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
this.valueBoundNamesCache = names;
|
|
2152
|
+
return names;
|
|
2153
|
+
}
|
|
2154
|
+
asShadowPredicate() {
|
|
2155
|
+
return (name) => this.isBound(name);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2068
2159
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
2069
2160
|
var VOID_ELEMENTS = new Set([
|
|
2070
2161
|
"area",
|
|
@@ -2499,7 +2590,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
2499
2590
|
const reachable = new Set;
|
|
2500
2591
|
const queue = [];
|
|
2501
2592
|
for (const name of allNames) {
|
|
2502
|
-
if (
|
|
2593
|
+
if (identifierPattern(name).test(primaryRefs)) {
|
|
2503
2594
|
reachable.add(name);
|
|
2504
2595
|
queue.push(name);
|
|
2505
2596
|
}
|
|
@@ -2508,7 +2599,7 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
2508
2599
|
const current = queue.shift();
|
|
2509
2600
|
const body = bodyMap.get(current) || "";
|
|
2510
2601
|
for (const name of allNames) {
|
|
2511
|
-
if (!reachable.has(name) &&
|
|
2602
|
+
if (!reachable.has(name) && identifierPattern(name).test(body)) {
|
|
2512
2603
|
reachable.add(name);
|
|
2513
2604
|
queue.push(name);
|
|
2514
2605
|
}
|
|
@@ -2839,83 +2930,6 @@ var toLocaleDatePlugin = {
|
|
|
2839
2930
|
}
|
|
2840
2931
|
};
|
|
2841
2932
|
|
|
2842
|
-
// ../jsx/src/scope/binding-scope.ts
|
|
2843
|
-
class BindingScope {
|
|
2844
|
-
frames;
|
|
2845
|
-
static EMPTY = new BindingScope([]);
|
|
2846
|
-
constructor(frames) {
|
|
2847
|
-
this.frames = frames;
|
|
2848
|
-
}
|
|
2849
|
-
enterLoopRow(loop) {
|
|
2850
|
-
const bindings = new Map;
|
|
2851
|
-
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
2852
|
-
for (const b of loop.paramBindings)
|
|
2853
|
-
bindings.set(b.name, { source: "destructure" });
|
|
2854
|
-
} else {
|
|
2855
|
-
bindings.set(loop.param, { source: "item" });
|
|
2856
|
-
}
|
|
2857
|
-
if (loop.index != null)
|
|
2858
|
-
bindings.set(loop.index, { source: "index" });
|
|
2859
|
-
for (const name of loop.preamble?.declaredNames ?? [])
|
|
2860
|
-
bindings.set(name, { source: "preamble" });
|
|
2861
|
-
const frame = { kind: "loop-row", bindings };
|
|
2862
|
-
return new BindingScope([frame, ...this.frames]);
|
|
2863
|
-
}
|
|
2864
|
-
enterCallback(params) {
|
|
2865
|
-
const bindings = new Map;
|
|
2866
|
-
for (const name of params)
|
|
2867
|
-
bindings.set(name, { source: "param" });
|
|
2868
|
-
const frame = { kind: "callback", bindings };
|
|
2869
|
-
return new BindingScope([frame, ...this.frames]);
|
|
2870
|
-
}
|
|
2871
|
-
isBound(name) {
|
|
2872
|
-
for (const frame of this.frames) {
|
|
2873
|
-
if (frame.bindings.has(name))
|
|
2874
|
-
return true;
|
|
2875
|
-
}
|
|
2876
|
-
return false;
|
|
2877
|
-
}
|
|
2878
|
-
lookup(name) {
|
|
2879
|
-
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
2880
|
-
const frame = this.frames[depth];
|
|
2881
|
-
const binding = frame.bindings.get(name);
|
|
2882
|
-
if (binding)
|
|
2883
|
-
return { depth, frame, binding };
|
|
2884
|
-
}
|
|
2885
|
-
return null;
|
|
2886
|
-
}
|
|
2887
|
-
boundNames() {
|
|
2888
|
-
if (this.boundNamesCache)
|
|
2889
|
-
return this.boundNamesCache;
|
|
2890
|
-
const names = new Set;
|
|
2891
|
-
for (const frame of this.frames) {
|
|
2892
|
-
for (const name of frame.bindings.keys())
|
|
2893
|
-
names.add(name);
|
|
2894
|
-
}
|
|
2895
|
-
this.boundNamesCache = names;
|
|
2896
|
-
return names;
|
|
2897
|
-
}
|
|
2898
|
-
boundNamesCache;
|
|
2899
|
-
valueBoundNamesCache;
|
|
2900
|
-
valueBoundNames() {
|
|
2901
|
-
if (this.valueBoundNamesCache)
|
|
2902
|
-
return this.valueBoundNamesCache;
|
|
2903
|
-
const names = new Set;
|
|
2904
|
-
for (const frame of this.frames) {
|
|
2905
|
-
for (const [name, binding] of frame.bindings) {
|
|
2906
|
-
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
2907
|
-
names.add(name);
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
this.valueBoundNamesCache = names;
|
|
2912
|
-
return names;
|
|
2913
|
-
}
|
|
2914
|
-
asShadowPredicate() {
|
|
2915
|
-
return (name) => this.isBound(name);
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
|
|
2919
2933
|
// ../jsx/src/jsx-to-ir.ts
|
|
2920
2934
|
var EMPTY_BOUND = new Set;
|
|
2921
2935
|
var constInitializerCache = new WeakMap;
|
|
@@ -3941,7 +3955,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
3941
3955
|
lines.push(` const ${signal.getter} = () => ${initialValue}`);
|
|
3942
3956
|
}
|
|
3943
3957
|
if (signal.setter) {
|
|
3944
|
-
const setterUsed =
|
|
3958
|
+
const setterUsed = identifierPattern(signal.setter).test(setterRefText);
|
|
3945
3959
|
if (setterUsed) {
|
|
3946
3960
|
lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
|
|
3947
3961
|
}
|
|
@@ -4139,6 +4153,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
4139
4153
|
}
|
|
4140
4154
|
|
|
4141
4155
|
// ../jsx/src/adapters/template-imports.ts
|
|
4156
|
+
import ts25 from "typescript";
|
|
4142
4157
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
4143
4158
|
"@barefootjs/client",
|
|
4144
4159
|
"@barefootjs/client/runtime"
|
|
@@ -4812,7 +4827,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
|
|
|
4812
4827
|
};
|
|
4813
4828
|
}
|
|
4814
4829
|
// ../jsx/src/combine-client-js.ts
|
|
4815
|
-
import
|
|
4830
|
+
import ts26 from "typescript";
|
|
4816
4831
|
// ../jsx/src/loop-destructure.ts
|
|
4817
4832
|
function isLowerableLoopDestructure(loop) {
|
|
4818
4833
|
const bindings = loop.paramBindings;
|
|
@@ -4952,9 +4967,9 @@ function escapeRe(s) {
|
|
|
4952
4967
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4953
4968
|
}
|
|
4954
4969
|
// ../jsx/src/debug.ts
|
|
4955
|
-
import ts26 from "typescript";
|
|
4956
|
-
// ../jsx/src/profiler.ts
|
|
4957
4970
|
import ts27 from "typescript";
|
|
4971
|
+
// ../jsx/src/profiler.ts
|
|
4972
|
+
import ts28 from "typescript";
|
|
4958
4973
|
|
|
4959
4974
|
// ../jsx/src/index.ts
|
|
4960
4975
|
registerBuiltinLoweringPlugins();
|
|
@@ -5825,7 +5840,7 @@ function collectImportedLoopChildComponentErrors(ir, componentName) {
|
|
|
5825
5840
|
}
|
|
5826
5841
|
|
|
5827
5842
|
// src/adapter/spread/spread-codegen.ts
|
|
5828
|
-
import
|
|
5843
|
+
import ts29 from "typescript";
|
|
5829
5844
|
function conditionalSpreadToRuby(ctx, expr) {
|
|
5830
5845
|
if (!expr || expr.kind !== "conditional")
|
|
5831
5846
|
return null;
|
|
@@ -5880,7 +5895,7 @@ function recordIndexAccessToRuby(ctx, val) {
|
|
|
5880
5895
|
if (val.kind !== "index-access" || val.object.kind !== "identifier" || val.index.kind !== "identifier") {
|
|
5881
5896
|
return null;
|
|
5882
5897
|
}
|
|
5883
|
-
const tsVal =
|
|
5898
|
+
const tsVal = ts29.factory.createElementAccessExpression(ts29.factory.createIdentifier(val.object.name), ts29.factory.createIdentifier(val.index.name));
|
|
5884
5899
|
const parsed = parseRecordIndexAccess(tsVal, ctx.localConstants, ctx.propsParams);
|
|
5885
5900
|
if (!parsed)
|
|
5886
5901
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/erb",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.4",
|
|
4
4
|
"description": "ERB (Embedded Ruby) adapter for BarefootJS — compiles IR to .erb templates and ships the Ruby rendering backend; runs under any Rack app (Sinatra, Rails)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"directory": "packages/adapter-erb"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@barefootjs/shared": "0.31.
|
|
57
|
+
"@barefootjs/shared": "0.31.4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
74
|
-
"@barefootjs/jsx": "0.31.
|
|
75
|
-
"@barefootjs/vite": "0.31.
|
|
76
|
-
"@barefootjs/client": "0.31.
|
|
74
|
+
"@barefootjs/jsx": "0.31.4",
|
|
75
|
+
"@barefootjs/vite": "0.31.4",
|
|
76
|
+
"@barefootjs/client": "0.31.4",
|
|
77
77
|
"typescript": "^5.0.0",
|
|
78
78
|
"vite": "^6.0.0"
|
|
79
79
|
}
|