@barefootjs/client 0.31.3 → 0.31.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.
Files changed (2) hide show
  1. package/dist/csr-adapter.js +162 -101
  2. package/package.json +2 -2
@@ -168754,7 +168754,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
168754
168754
  });
168755
168755
 
168756
168756
  // ../jsx/src/compiler.ts
168757
- var import_typescript23 = __toESM(require_typescript(), 1);
168757
+ var import_typescript24 = __toESM(require_typescript(), 1);
168758
168758
 
168759
168759
  // ../jsx/src/analyzer.ts
168760
168760
  var import_typescript9 = __toESM(require_typescript(), 1);
@@ -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",
@@ -169336,7 +169427,7 @@ var REACTIVE_PRIMITIVES = new Set([
169336
169427
  ]);
169337
169428
 
169338
169429
  // ../jsx/src/jsx-to-ir.ts
169339
- var import_typescript12 = __toESM(require_typescript(), 1);
169430
+ var import_typescript13 = __toESM(require_typescript(), 1);
169340
169431
 
169341
169432
  // ../jsx/src/types.ts
169342
169433
  var SCOPE_FORBIDDEN = {
@@ -169372,6 +169463,7 @@ var REACTIVE_BINDING_KINDS = new Set([
169372
169463
  ]);
169373
169464
 
169374
169465
  // ../jsx/src/module-exports.ts
169466
+ var import_typescript10 = __toESM(require_typescript(), 1);
169375
169467
  function formatParamWithType(p) {
169376
169468
  const rest = p.isRest ? "..." : "";
169377
169469
  const optional = p.optional ? "?" : "";
@@ -169385,7 +169477,7 @@ function findReachableNames(primaryRefs, declarations) {
169385
169477
  const reachable = new Set;
169386
169478
  const queue = [];
169387
169479
  for (const name of allNames) {
169388
- if (new RegExp(`\\b${name}\\b`).test(primaryRefs)) {
169480
+ if (identifierPattern(name).test(primaryRefs)) {
169389
169481
  reachable.add(name);
169390
169482
  queue.push(name);
169391
169483
  }
@@ -169394,7 +169486,7 @@ function findReachableNames(primaryRefs, declarations) {
169394
169486
  const current = queue.shift();
169395
169487
  const body = bodyMap.get(current) || "";
169396
169488
  for (const name of allNames) {
169397
- if (!reachable.has(name) && new RegExp(`\\b${name}\\b`).test(body)) {
169489
+ if (!reachable.has(name) && identifierPattern(name).test(body)) {
169398
169490
  reachable.add(name);
169399
169491
  queue.push(name);
169400
169492
  }
@@ -169402,12 +169494,55 @@ function findReachableNames(primaryRefs, declarations) {
169402
169494
  }
169403
169495
  return reachable;
169404
169496
  }
169497
+ function findAssignedNames(bodyText, candidates) {
169498
+ const assigned = new Set;
169499
+ if (candidates.size === 0)
169500
+ return assigned;
169501
+ const sf = import_typescript10.default.createSourceFile("bf-assignment-scan.tsx", bodyText, import_typescript10.default.ScriptTarget.Latest, false, import_typescript10.default.ScriptKind.TSX);
169502
+ const record = (target) => {
169503
+ if (import_typescript10.default.isIdentifier(target) && candidates.has(target.text)) {
169504
+ assigned.add(target.text);
169505
+ }
169506
+ };
169507
+ const visit = (node) => {
169508
+ if (import_typescript10.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
169509
+ record(node.left);
169510
+ } else if ((import_typescript10.default.isPrefixUnaryExpression(node) || import_typescript10.default.isPostfixUnaryExpression(node)) && (node.operator === import_typescript10.default.SyntaxKind.PlusPlusToken || node.operator === import_typescript10.default.SyntaxKind.MinusMinusToken)) {
169511
+ record(node.operand);
169512
+ }
169513
+ import_typescript10.default.forEachChild(node, visit);
169514
+ };
169515
+ import_typescript10.default.forEachChild(sf, visit);
169516
+ return assigned;
169517
+ }
169518
+ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
169519
+ let reachable = findReachableNames(primaryRefs, declarations);
169520
+ if (mutableNames.size === 0)
169521
+ return reachable;
169522
+ let seedText = primaryRefs;
169523
+ for (let round = 0;round <= declarations.length; round++) {
169524
+ const survivingMutables = new Set([...reachable].filter((name) => mutableNames.has(name)));
169525
+ if (survivingMutables.size === 0)
169526
+ return reachable;
169527
+ const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
169528
+ if (added.length === 0)
169529
+ return reachable;
169530
+ seedText += `
169531
+ ` + added.join(`
169532
+ `);
169533
+ reachable = findReachableNames(seedText, declarations);
169534
+ }
169535
+ return reachable;
169536
+ }
169537
+ function isAssignmentOperator(kind) {
169538
+ return kind >= import_typescript10.default.SyntaxKind.FirstAssignment && kind <= import_typescript10.default.SyntaxKind.LastAssignment;
169539
+ }
169405
169540
 
169406
169541
  // ../jsx/src/reactivity-checker.ts
169407
- var import_typescript10 = __toESM(require_typescript(), 1);
169542
+ var import_typescript11 = __toESM(require_typescript(), 1);
169408
169543
 
169409
169544
  // ../jsx/src/free-refs.ts
169410
- var import_typescript11 = __toESM(require_typescript(), 1);
169545
+ var import_typescript12 = __toESM(require_typescript(), 1);
169411
169546
  var _bindingMapCache = new WeakMap;
169412
169547
 
169413
169548
  // ../jsx/src/to-locale-date-lowering.ts
@@ -169725,83 +169860,6 @@ var toLocaleDatePlugin = {
169725
169860
  }
169726
169861
  };
169727
169862
 
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
-
169805
169863
  // ../jsx/src/jsx-to-ir.ts
169806
169864
  var EMPTY_BOUND = new Set;
169807
169865
  var constInitializerCache = new WeakMap;
@@ -169898,13 +169956,13 @@ var KEYWORDS_AND_GLOBALS = new Set([
169898
169956
  ]);
169899
169957
 
169900
169958
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
169901
- var import_typescript13 = __toESM(require_typescript(), 1);
169959
+ var import_typescript14 = __toESM(require_typescript(), 1);
169902
169960
 
169903
169961
  // ../jsx/src/value-references.ts
169904
- var import_typescript14 = __toESM(require_typescript(), 1);
169962
+ var import_typescript15 = __toESM(require_typescript(), 1);
169905
169963
 
169906
169964
  // ../jsx/src/relocate.ts
169907
- var import_typescript15 = __toESM(require_typescript(), 1);
169965
+ var import_typescript16 = __toESM(require_typescript(), 1);
169908
169966
 
169909
169967
  // ../jsx/src/lowering-registry.ts
169910
169968
  var plugins = [];
@@ -170083,10 +170141,10 @@ function formatDateLocalNames(metadata) {
170083
170141
  }
170084
170142
 
170085
170143
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
170086
- var import_typescript16 = __toESM(require_typescript(), 1);
170144
+ var import_typescript17 = __toESM(require_typescript(), 1);
170087
170145
 
170088
170146
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
170089
- var import_typescript17 = __toESM(require_typescript(), 1);
170147
+ var import_typescript18 = __toESM(require_typescript(), 1);
170090
170148
  var NO_PREAMBLE = {
170091
170149
  lazySafe: true,
170092
170150
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -170136,7 +170194,7 @@ var INERT_BINDING_GLOBALS = new Set([
170136
170194
  ]);
170137
170195
 
170138
170196
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
170139
- var import_typescript18 = __toESM(require_typescript(), 1);
170197
+ var import_typescript19 = __toESM(require_typescript(), 1);
170140
170198
 
170141
170199
  // ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
170142
170200
  var NON_BUBBLING_EVENTS = new Set([
@@ -170151,7 +170209,7 @@ var NON_BUBBLING_EVENTS = new Set([
170151
170209
  ]);
170152
170210
 
170153
170211
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
170154
- var import_typescript19 = __toESM(require_typescript(), 1);
170212
+ var import_typescript20 = __toESM(require_typescript(), 1);
170155
170213
 
170156
170214
  // ../jsx/src/ir-to-client-js/source-map.ts
170157
170215
  var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -170242,20 +170300,20 @@ class SourceMapGenerator {
170242
170300
  }
170243
170301
 
170244
170302
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
170245
- var import_typescript20 = __toESM(require_typescript(), 1);
170303
+ var import_typescript21 = __toESM(require_typescript(), 1);
170246
170304
 
170247
170305
  // ../jsx/src/ssr-defaults.ts
170248
- var import_typescript21 = __toESM(require_typescript(), 1);
170306
+ var import_typescript22 = __toESM(require_typescript(), 1);
170249
170307
  var UNRESOLVED = Symbol("unresolved");
170250
170308
  var NO_RETURN = Symbol("no-return");
170251
170309
 
170252
170310
  // ../jsx/src/augment-inherited-props.ts
170253
- var import_typescript22 = __toESM(require_typescript(), 1);
170311
+ var import_typescript23 = __toESM(require_typescript(), 1);
170254
170312
 
170255
170313
  // ../jsx/src/rich-type-refusal.ts
170256
170314
  var EMPTY_BINDINGS2 = new Map;
170257
170315
  // ../jsx/src/shared-program.ts
170258
- var import_typescript24 = __toESM(require_typescript(), 1);
170316
+ var import_typescript25 = __toESM(require_typescript(), 1);
170259
170317
  // ../jsx/src/adapters/interface.ts
170260
170318
  class BaseAdapter {
170261
170319
  renderChildren(children) {
@@ -170308,7 +170366,7 @@ class JsxAdapter extends BaseAdapter {
170308
170366
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
170309
170367
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
170310
170368
  ];
170311
- const reachable = findReachableNames(primaryRefText, declarations);
170369
+ const reachable = closeOverWritersOfMutableBindings(primaryRefText, declarations, new Set(ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)));
170312
170370
  const reachableBodies = [...reachable].map((name) => {
170313
170371
  const func = localFunctions.find((f) => f.name === name);
170314
170372
  if (func)
@@ -170338,9 +170396,10 @@ class JsxAdapter extends BaseAdapter {
170338
170396
  lines.push(` const ${signal.getter} = () => ${initialValue}`);
170339
170397
  }
170340
170398
  if (signal.setter) {
170341
- const setterUsed = new RegExp(`\\b${signal.setter}\\b`).test(setterRefText);
170399
+ const setterUsed = identifierPattern(signal.setter).test(setterRefText);
170342
170400
  if (setterUsed) {
170343
- lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
170401
+ const setterType = preserveTypes && signal.type.kind !== "unknown" ? `(valueOrFn: ${signal.type.raw} | ((prev: ${signal.type.raw}) => ${signal.type.raw})) => void` : null;
170402
+ lines.push(setterType ? ` const ${signal.setter}: ${setterType} = () => {}` : ` const ${signal.setter} = (..._args: any[]) => {}`);
170344
170403
  }
170345
170404
  }
170346
170405
  }
@@ -170536,6 +170595,7 @@ class JsxAdapter extends BaseAdapter {
170536
170595
  }
170537
170596
 
170538
170597
  // ../jsx/src/adapters/template-imports.ts
170598
+ var import_typescript26 = __toESM(require_typescript(), 1);
170539
170599
  var CLIENT_PACKAGE_SOURCES = new Set([
170540
170600
  "@barefootjs/client",
170541
170601
  "@barefootjs/client/runtime"
@@ -170674,7 +170734,8 @@ export default ${this.componentName}` : "";
170674
170734
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
170675
170735
  const lines = [];
170676
170736
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
170677
- lines.push(`${exportPrefix}function ${name}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
170737
+ const typeParameters = ir.metadata.typeParameters ?? "";
170738
+ lines.push(`${exportPrefix}function ${name}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
170678
170739
  if (hasClientInteractivity) {
170679
170740
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name}_\${Math.random().toString(36).slice(2, 8)}\``);
170680
170741
  } else {
@@ -170925,11 +170986,11 @@ function registerBuiltinLoweringPlugins() {
170925
170986
  registerLoweringPlugin(plugin);
170926
170987
  }
170927
170988
  // ../jsx/src/combine-client-js.ts
170928
- var import_typescript25 = __toESM(require_typescript(), 1);
170989
+ var import_typescript27 = __toESM(require_typescript(), 1);
170929
170990
  // ../jsx/src/debug.ts
170930
- var import_typescript26 = __toESM(require_typescript(), 1);
170991
+ var import_typescript28 = __toESM(require_typescript(), 1);
170931
170992
  // ../jsx/src/profiler.ts
170932
- var import_typescript27 = __toESM(require_typescript(), 1);
170993
+ var import_typescript29 = __toESM(require_typescript(), 1);
170933
170994
 
170934
170995
  // ../jsx/src/index.ts
170935
170996
  registerBuiltinLoweringPlugins();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/client",
3
- "version": "0.31.3",
3
+ "version": "0.31.5",
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.3"
58
+ "@barefootjs/shared": "0.31.5"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@barefootjs/jsx": ">=0.2.0"