@barefootjs/client 0.31.2 → 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.
Files changed (2) hide show
  1. package/dist/csr-adapter.js +105 -10
  2. package/package.json +2 -2
@@ -168861,6 +168861,20 @@ function templatePartsToJsExpr(parts, opts) {
168861
168861
  return result;
168862
168862
  }
168863
168863
 
168864
+ // ../jsx/src/identifier-pattern.ts
168865
+ function withUnicodeFlag(flags) {
168866
+ return flags.includes("u") ? flags : `${flags}u`;
168867
+ }
168868
+ function escapeIdentifierForRegex(name) {
168869
+ return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
168870
+ }
168871
+ var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
168872
+ var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
168873
+ function identifierPattern(name, flags = "") {
168874
+ const esc = escapeIdentifierForRegex(name);
168875
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
168876
+ }
168877
+
168864
168878
  // ../jsx/src/scanner/js-scanner.ts
168865
168879
  var import_typescript2 = __toESM(require_typescript(), 1);
168866
168880
 
@@ -168965,6 +168979,83 @@ function extractFreeIdentifiersFromText(text) {
168965
168979
  return extractFreeIdentifiersFromNode(expr);
168966
168980
  }
168967
168981
 
168982
+ // ../jsx/src/scope/binding-scope.ts
168983
+ class BindingScope {
168984
+ frames;
168985
+ static EMPTY = new BindingScope([]);
168986
+ constructor(frames) {
168987
+ this.frames = frames;
168988
+ }
168989
+ enterLoopRow(loop) {
168990
+ const bindings = new Map;
168991
+ if (loop.paramBindings && loop.paramBindings.length > 0) {
168992
+ for (const b of loop.paramBindings)
168993
+ bindings.set(b.name, { source: "destructure" });
168994
+ } else {
168995
+ bindings.set(loop.param, { source: "item" });
168996
+ }
168997
+ if (loop.index != null)
168998
+ bindings.set(loop.index, { source: "index" });
168999
+ for (const name of loop.preamble?.declaredNames ?? [])
169000
+ bindings.set(name, { source: "preamble" });
169001
+ const frame = { kind: "loop-row", bindings };
169002
+ return new BindingScope([frame, ...this.frames]);
169003
+ }
169004
+ enterCallback(params) {
169005
+ const bindings = new Map;
169006
+ for (const name of params)
169007
+ bindings.set(name, { source: "param" });
169008
+ const frame = { kind: "callback", bindings };
169009
+ return new BindingScope([frame, ...this.frames]);
169010
+ }
169011
+ isBound(name) {
169012
+ for (const frame of this.frames) {
169013
+ if (frame.bindings.has(name))
169014
+ return true;
169015
+ }
169016
+ return false;
169017
+ }
169018
+ lookup(name) {
169019
+ for (let depth = 0;depth < this.frames.length; depth++) {
169020
+ const frame = this.frames[depth];
169021
+ const binding = frame.bindings.get(name);
169022
+ if (binding)
169023
+ return { depth, frame, binding };
169024
+ }
169025
+ return null;
169026
+ }
169027
+ boundNames() {
169028
+ if (this.boundNamesCache)
169029
+ return this.boundNamesCache;
169030
+ const names = new Set;
169031
+ for (const frame of this.frames) {
169032
+ for (const name of frame.bindings.keys())
169033
+ names.add(name);
169034
+ }
169035
+ this.boundNamesCache = names;
169036
+ return names;
169037
+ }
169038
+ boundNamesCache;
169039
+ valueBoundNamesCache;
169040
+ valueBoundNames() {
169041
+ if (this.valueBoundNamesCache)
169042
+ return this.valueBoundNamesCache;
169043
+ const names = new Set;
169044
+ for (const frame of this.frames) {
169045
+ for (const [name, binding] of frame.bindings) {
169046
+ if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
169047
+ names.add(name);
169048
+ }
169049
+ }
169050
+ }
169051
+ this.valueBoundNamesCache = names;
169052
+ return names;
169053
+ }
169054
+ asShadowPredicate() {
169055
+ return (name) => this.isBound(name);
169056
+ }
169057
+ }
169058
+
168968
169059
  // ../jsx/src/ir-to-client-js/html-template.ts
168969
169060
  var VOID_ELEMENTS = new Set([
168970
169061
  "area",
@@ -169385,7 +169476,7 @@ function findReachableNames(primaryRefs, declarations) {
169385
169476
  const reachable = new Set;
169386
169477
  const queue = [];
169387
169478
  for (const name of allNames) {
169388
- if (new RegExp(`\\b${name}\\b`).test(primaryRefs)) {
169479
+ if (identifierPattern(name).test(primaryRefs)) {
169389
169480
  reachable.add(name);
169390
169481
  queue.push(name);
169391
169482
  }
@@ -169394,7 +169485,7 @@ function findReachableNames(primaryRefs, declarations) {
169394
169485
  const current = queue.shift();
169395
169486
  const body = bodyMap.get(current) || "";
169396
169487
  for (const name of allNames) {
169397
- if (!reachable.has(name) && new RegExp(`\\b${name}\\b`).test(body)) {
169488
+ if (!reachable.has(name) && identifierPattern(name).test(body)) {
169398
169489
  reachable.add(name);
169399
169490
  queue.push(name);
169400
169491
  }
@@ -170261,7 +170352,7 @@ class JsxAdapter extends BaseAdapter {
170261
170352
  lines.push(` const ${signal.getter} = () => ${initialValue}`);
170262
170353
  }
170263
170354
  if (signal.setter) {
170264
- const setterUsed = new RegExp(`\\b${signal.setter}\\b`).test(setterRefText);
170355
+ const setterUsed = identifierPattern(signal.setter).test(setterRefText);
170265
170356
  if (setterUsed) {
170266
170357
  lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
170267
170358
  }
@@ -170281,7 +170372,7 @@ class JsxAdapter extends BaseAdapter {
170281
170372
  continue;
170282
170373
  const keyword = constant.declarationKind ?? "const";
170283
170374
  if (!constant.value) {
170284
- const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type.raw}` : "";
170375
+ const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
170285
170376
  lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
170286
170377
  continue;
170287
170378
  }
@@ -170291,7 +170382,8 @@ class JsxAdapter extends BaseAdapter {
170291
170382
  if (!reachable.has(constant.name))
170292
170383
  continue;
170293
170384
  const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
170294
- lines.push(` ${keyword} ${constant.name} = ${constValue}`);
170385
+ const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
170386
+ lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
170295
170387
  }
170296
170388
  for (const func of localFunctions) {
170297
170389
  if (moduleScopeNames.has(func.name))
@@ -170398,7 +170490,8 @@ class JsxAdapter extends BaseAdapter {
170398
170490
  const keyword = c.declarationKind ?? "const";
170399
170491
  const exportKw = c.isExported ? "export " : "";
170400
170492
  if (!c.value) {
170401
- entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}` });
170493
+ const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
170494
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
170402
170495
  continue;
170403
170496
  }
170404
170497
  const trimmed = c.value.trim();
@@ -170407,7 +170500,8 @@ class JsxAdapter extends BaseAdapter {
170407
170500
  if (c.isExported && /^createContext\b/.test(trimmed))
170408
170501
  continue;
170409
170502
  const value = preserveTypes ? c.typedValue ?? c.value : c.value;
170410
- entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name} = ${value}` });
170503
+ const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
170504
+ entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
170411
170505
  }
170412
170506
  for (const f of ir.metadata.localFunctions) {
170413
170507
  if (!f.isModule || !moduleNames.has(f.name))
@@ -170456,6 +170550,7 @@ class JsxAdapter extends BaseAdapter {
170456
170550
  }
170457
170551
 
170458
170552
  // ../jsx/src/adapters/template-imports.ts
170553
+ var import_typescript25 = __toESM(require_typescript(), 1);
170459
170554
  var CLIENT_PACKAGE_SOURCES = new Set([
170460
170555
  "@barefootjs/client",
170461
170556
  "@barefootjs/client/runtime"
@@ -170845,11 +170940,11 @@ function registerBuiltinLoweringPlugins() {
170845
170940
  registerLoweringPlugin(plugin);
170846
170941
  }
170847
170942
  // ../jsx/src/combine-client-js.ts
170848
- var import_typescript25 = __toESM(require_typescript(), 1);
170849
- // ../jsx/src/debug.ts
170850
170943
  var import_typescript26 = __toESM(require_typescript(), 1);
170851
- // ../jsx/src/profiler.ts
170944
+ // ../jsx/src/debug.ts
170852
170945
  var import_typescript27 = __toESM(require_typescript(), 1);
170946
+ // ../jsx/src/profiler.ts
170947
+ var import_typescript28 = __toESM(require_typescript(), 1);
170853
170948
 
170854
170949
  // ../jsx/src/index.ts
170855
170950
  registerBuiltinLoweringPlugins();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/client",
3
- "version": "0.31.2",
3
+ "version": "0.31.4",
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.2"
58
+ "@barefootjs/shared": "0.31.4"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@barefootjs/jsx": ">=0.2.0"