@lotics/app-sdk 0.123.10 → 0.123.11

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/index.js +22 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12650,27 +12650,33 @@ function innermostLists(value) {
12650
12650
  }
12651
12651
 
12652
12652
  // ../shared/src/interpolate.ts
12653
+ function findInterpolations(text2) {
12654
+ return [...text2.matchAll(/\{\{.*?\}\}/g)].map((match2) => ({
12655
+ start: match2.index,
12656
+ end: match2.index + match2[0].length,
12657
+ source: match2[0],
12658
+ expression: match2[0].slice(2, -2).trim()
12659
+ }));
12660
+ }
12653
12661
  function interpolateObject(obj, context) {
12654
12662
  if (obj === null || obj === void 0) {
12655
12663
  return obj;
12656
12664
  }
12657
12665
  if (typeof obj === "string") {
12658
- const expressionMatches = obj.match(/\{\{.*?\}\}/g);
12659
- if (expressionMatches && expressionMatches.length > 0) {
12660
- if (expressionMatches.length === 1 && obj === expressionMatches[0]) {
12661
- const expression = obj.slice(2, -2).trim();
12662
- return evaluateJsExpression(expression, context);
12663
- }
12664
- const parts = obj.split(/(\{\{.*?\}\})/g);
12665
- const evaluatedParts = parts.map((part) => {
12666
- if (part.startsWith("{{") && part.endsWith("}}")) {
12667
- const expression = part.slice(2, -2).trim();
12668
- const result = evaluateJsExpression(expression, context);
12669
- return result != null ? String(result) : "";
12670
- }
12671
- return part;
12672
- });
12673
- return evaluatedParts.join("");
12666
+ const interpolations = findInterpolations(obj);
12667
+ const [only] = interpolations;
12668
+ if (only) {
12669
+ if (interpolations.length === 1 && obj === only.source) {
12670
+ return evaluateJsExpression(only.expression, context);
12671
+ }
12672
+ let out = "";
12673
+ let cursor = 0;
12674
+ for (const interpolation of interpolations) {
12675
+ const result = evaluateJsExpression(interpolation.expression, context);
12676
+ out += obj.slice(cursor, interpolation.start) + (result != null ? String(result) : "");
12677
+ cursor = interpolation.end;
12678
+ }
12679
+ return out + obj.slice(cursor);
12674
12680
  }
12675
12681
  return obj;
12676
12682
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.123.10",
3
+ "version": "0.123.11",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {