@teleporthq/teleport-plugin-common 0.43.65 → 0.43.67

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 (37) hide show
  1. package/__tests__/node-handlers/node-to-jsx/cms-list-repeater-ecommerce-source.ts +72 -0
  2. package/__tests__/node-handlers/node-to-jsx/index.ts +32 -0
  3. package/__tests__/node-handlers/node-to-jsx/utils.ts +17 -0
  4. package/__tests__/utils/ast-utils.ts +14 -0
  5. package/dist/cjs/node-handlers/node-to-jsx/index.d.ts.map +1 -1
  6. package/dist/cjs/node-handlers/node-to-jsx/index.js +9 -4
  7. package/dist/cjs/node-handlers/node-to-jsx/index.js.map +1 -1
  8. package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  9. package/dist/cjs/node-handlers/node-to-jsx/utils.js +29 -2
  10. package/dist/cjs/node-handlers/node-to-jsx/utils.js.map +1 -1
  11. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  12. package/dist/cjs/utils/ast-utils.d.ts.map +1 -1
  13. package/dist/cjs/utils/ast-utils.js +8 -1
  14. package/dist/cjs/utils/ast-utils.js.map +1 -1
  15. package/dist/cjs/utils/url-search-param-sync.d.ts +2 -2
  16. package/dist/cjs/utils/url-search-param-sync.d.ts.map +1 -1
  17. package/dist/cjs/utils/url-search-param-sync.js +40 -8
  18. package/dist/cjs/utils/url-search-param-sync.js.map +1 -1
  19. package/dist/esm/node-handlers/node-to-jsx/index.d.ts.map +1 -1
  20. package/dist/esm/node-handlers/node-to-jsx/index.js +9 -4
  21. package/dist/esm/node-handlers/node-to-jsx/index.js.map +1 -1
  22. package/dist/esm/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
  23. package/dist/esm/node-handlers/node-to-jsx/utils.js +29 -2
  24. package/dist/esm/node-handlers/node-to-jsx/utils.js.map +1 -1
  25. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  26. package/dist/esm/utils/ast-utils.d.ts.map +1 -1
  27. package/dist/esm/utils/ast-utils.js +8 -1
  28. package/dist/esm/utils/ast-utils.js.map +1 -1
  29. package/dist/esm/utils/url-search-param-sync.d.ts +2 -2
  30. package/dist/esm/utils/url-search-param-sync.d.ts.map +1 -1
  31. package/dist/esm/utils/url-search-param-sync.js +40 -8
  32. package/dist/esm/utils/url-search-param-sync.js.map +1 -1
  33. package/package.json +4 -4
  34. package/src/node-handlers/node-to-jsx/index.ts +9 -4
  35. package/src/node-handlers/node-to-jsx/utils.ts +22 -2
  36. package/src/utils/ast-utils.ts +8 -1
  37. package/src/utils/url-search-param-sync.ts +39 -2
@@ -1,3 +1,12 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
1
10
  import * as types from '@babel/types';
2
11
  import * as URLQueryWriter from './url-query-writer';
3
12
  // Shared builders for two-way `<state> ⇄ ?key=` URL search-param syncing.
@@ -28,6 +37,9 @@ var accessKeyOf = function (object, paramKey) {
28
37
  }
29
38
  return types.memberExpression(object, types.stringLiteral(paramKey), true);
30
39
  };
40
+ var adoptedRefCurrent = function (refName) {
41
+ return types.memberExpression(types.identifier(refName), types.identifier('current'));
42
+ };
31
43
  var routerQueryAccess = function (paramKey) {
32
44
  return accessKeyOf(types.memberExpression(types.identifier('router'), types.identifier('query')), paramKey);
33
45
  };
@@ -84,20 +96,33 @@ var clone = function (expr) {
84
96
  // means there is nothing to re-assert.
85
97
  // 4. Empty / null value deletes the key entirely so the URL never keeps a
86
98
  // sticky `?key=` empty param. The writer treats `undefined` as "remove".
87
- export var buildUrlWriteBackEffect = function (paramKey, valueExpr, depExpr, defaultValueExpr) {
99
+ // 5. `adoptedRefName` (optional) names a `useRef(false)` the paired read-back
100
+ // flips once it has adopted the URL value; until then the write-back stays
101
+ // silent. For a state seeded with its DEFAULT rather than from the URL
102
+ // (`urlSearchParamBinding.hydrateAfterMount`): on the first ready render
103
+ // the state still holds the default, and a write-back running before the
104
+ // read-back would push that default onto the URL — deleting the very key
105
+ // the read-back was about to adopt — after which the two chase each other
106
+ // forever (`/products?view=list` → `/products` → …).
107
+ export var buildUrlWriteBackEffect = function (paramKey, valueExpr, depExpr, defaultValueExpr, adoptedRefName) {
88
108
  // value === '' || value == null [|| value === <default>]
89
109
  var deleteCondition = types.logicalExpression('||', types.binaryExpression('===', clone(valueExpr), types.stringLiteral('')), types.binaryExpression('==', clone(valueExpr), types.nullLiteral()));
90
110
  if (defaultValueExpr) {
91
111
  deleteCondition = types.logicalExpression('||', deleteCondition, types.binaryExpression('===', clone(valueExpr), clone(defaultValueExpr)));
92
112
  }
93
- var effectBody = types.blockStatement([
113
+ var effectBody = types.blockStatement(__spreadArray(__spreadArray([
94
114
  // if (typeof window === 'undefined') return
95
115
  types.ifStatement(types.binaryExpression('===', types.unaryExpression('typeof', types.identifier('window')), types.stringLiteral('undefined')), types.returnStatement(null)),
96
116
  // if (!router.isReady) return
97
- types.ifStatement(types.unaryExpression('!', types.memberExpression(types.identifier('router'), types.identifier('isReady'))), types.returnStatement(null)),
117
+ types.ifStatement(types.unaryExpression('!', types.memberExpression(types.identifier('router'), types.identifier('isReady'))), types.returnStatement(null))
118
+ ], (adoptedRefName
119
+ ? [
120
+ types.ifStatement(types.unaryExpression('!', adoptedRefCurrent(adoptedRefName)), types.returnStatement(null)),
121
+ ]
122
+ : []), true), [
98
123
  // __tqWriteQueryParam('<key>', <deleteCondition> ? undefined : <value>)
99
124
  URLQueryWriter.buildQueryWriteCall(paramKey, types.conditionalExpression(deleteCondition, types.identifier('undefined'), clone(valueExpr))),
100
- ]);
125
+ ], false));
101
126
  return types.expressionStatement(types.callExpression(types.identifier('useEffect'), [
102
127
  types.arrowFunctionExpression([], effectBody),
103
128
  types.arrayExpression([
@@ -142,7 +167,10 @@ export var buildUrlWriteBackEffect = function (paramKey, valueExpr, depExpr, def
142
167
  // key, forcing an extra unsorted fetch and losing the ordering. It also keeps
143
168
  // browser back/forward to the param-free URL restoring the default view.
144
169
  // Omitting it reproduces the pre-default `''` fallback byte-for-byte.
145
- export var buildUrlReadBackEffect = function (paramKey, setterName, defaultValueExpr) {
170
+ //
171
+ // `adoptedRefName` (optional): the flag the paired write-back waits on — set
172
+ // once the URL value has been handed to the state. See the write-back's note 5.
173
+ export var buildUrlReadBackEffect = function (paramKey, setterName, defaultValueExpr, adoptedRefName) {
146
174
  var normalizeArg = types.conditionalExpression(
147
175
  // typeof __urlValue === 'string' ? __urlValue
148
176
  types.binaryExpression('===', types.unaryExpression('typeof', types.identifier('__urlValue')), types.stringLiteral('string')), types.identifier('__urlValue'), types.conditionalExpression(
@@ -154,7 +182,7 @@ export var buildUrlReadBackEffect = function (paramKey, setterName, defaultValue
154
182
  var nextValueExpr = defaultValueExpr
155
183
  ? types.logicalExpression('||', normalizeArg, clone(defaultValueExpr))
156
184
  : normalizeArg;
157
- var effectBody = types.blockStatement([
185
+ var effectBody = types.blockStatement(__spreadArray([
158
186
  // if (!router.isReady) return
159
187
  types.ifStatement(types.unaryExpression('!', types.memberExpression(types.identifier('router'), types.identifier('isReady'))), types.returnStatement(null)),
160
188
  // const __urlValue = router.query.<paramKey>
@@ -168,8 +196,12 @@ export var buildUrlReadBackEffect = function (paramKey, setterName, defaultValue
168
196
  // setState((prev) => prev === __nextValue ? prev : __nextValue)
169
197
  types.expressionStatement(types.callExpression(types.identifier(setterName), [
170
198
  types.arrowFunctionExpression([types.identifier('prev')], types.conditionalExpression(types.binaryExpression('===', types.identifier('prev'), types.identifier('__nextValue')), types.identifier('prev'), types.identifier('__nextValue'))),
171
- ])),
172
- ]);
199
+ ]))
200
+ ], (adoptedRefName
201
+ ? [
202
+ types.expressionStatement(types.assignmentExpression('=', adoptedRefCurrent(adoptedRefName), types.booleanLiteral(true))),
203
+ ]
204
+ : []), true));
173
205
  return types.expressionStatement(types.callExpression(types.identifier('useEffect'), [
174
206
  types.arrowFunctionExpression([], effectBody),
175
207
  types.arrayExpression([
@@ -1 +1 @@
1
- {"version":3,"file":"url-search-param-sync.js","sourceRoot":"","sources":["../../../src/utils/url-search-param-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AAEpD,0EAA0E;AAC1E,EAAE;AACF,gBAAgB;AAChB,8EAA8E;AAC9E,4EAA4E;AAC5E,iEAAiE;AACjE,iFAAiF;AACjF,iEAAiE;AACjE,kFAAkF;AAClF,wEAAwE;AACxE,EAAE;AACF,4EAA4E;AAC5E,uEAAuE;AACvE,0CAA0C;AAE1C,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,sDAAsD;AACtD,IAAM,mBAAmB,GAAG,4BAA4B,CAAA;AAExD,iFAAiF;AACjF,0EAA0E;AAC1E,IAAM,WAAW,GAAG,UAAC,MAAwB,EAAE,QAAgB;IAC7D,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtC,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;KAClE;IACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;AAC5E,CAAC,CAAA;AAED,IAAM,iBAAiB,GAAG,UAAC,QAAgB;IACzC,OAAA,WAAW,CACT,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7E,QAAQ,CACT;AAHD,CAGC,CAAA;AAEH,2EAA2E;AAC3E,8E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UAAU,CAAC,EAAE;YACjD,KAAK,CAAC,uBAAuB,CAC3B,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC1B,KAAK,CAAC,qBAAqB,CACzB,KAAK,CAAC,gBAAgB,CACpB,KAAK,EACL,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,EACD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,CACF;SACF,CAAC,CACH;KACF,CAAC,CAAA;IAEF,OAAO,KAAK,CAAC,mBAAmB,CAC9B,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAClD,KAAK,CAAC,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC;QAC7C,KAAK,CAAC,eAAe,CAAC;YACpB,iBAAiB,CAAC,QAAQ,CAAC;YAC3B,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAChF,CAAC;KACH,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"url-search-param-sync.js","sourceRoot":"","sources":["../../../src/utils/url-search-param-sync.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AAEpD,0EAA0E;AAC1E,EAAE;AACF,gBAAgB;AAChB,8EAA8E;AAC9E,4EAA4E;AAC5E,iEAAiE;AACjE,iFAAiF;AACjF,iEAAiE;AACjE,kFAAkF;AAClF,wEAAwE;AACxE,EAAE;AACF,4EAA4E;AAC5E,uEAAuE;AACvE,0CAA0C;AAE1C,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,s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AAU,CAAC,EAAE;YACjD,KAAK,CAAC,uBAAuB,CAC3B,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC1B,KAAK,CAAC,qBAAqB,CACzB,KAAK,CAAC,gBAAgB,CACpB,KAAK,EACL,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,EACD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,CACF;SACF,CAAC,CACH;OAEE,CAAC,cAAc;QAChB,CAAC,CAAC;YACE,KAAK,CAAC,mBAAmB,CACvB,KAAK,CAAC,oBAAoB,CACxB,GAAG,EACH,iBAAiB,CAAC,cAAc,CAAC,EACjC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAC3B,CACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC,QACP,CAAA;IAEF,OAAO,KAAK,CAAC,mBAAmB,CAC9B,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAClD,KAAK,CAAC,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC;QAC7C,KAAK,CAAC,eAAe,CAAC;YACpB,iBAAiB,CAAC,QAAQ,CAAC;YAC3B,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAChF,CAAC;KACH,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teleporthq/teleport-plugin-common",
3
- "version": "0.43.65",
3
+ "version": "0.43.67",
4
4
  "description": "Common building and modelating functions for ASTs and HASTs",
5
5
  "author": "teleportHQ",
6
6
  "license": "MIT",
@@ -27,10 +27,10 @@
27
27
  "@babel/core": "^7.5.5",
28
28
  "@babel/preset-react": "^7.22.5",
29
29
  "@babel/types": "^7.5.5",
30
- "@teleporthq/teleport-shared": "^0.43.65",
31
- "@teleporthq/teleport-types": "^0.43.65",
30
+ "@teleporthq/teleport-shared": "^0.43.67",
31
+ "@teleporthq/teleport-types": "^0.43.67",
32
32
  "jss": "^10.0.0",
33
33
  "jss-preset-default": "^10.0.0"
34
34
  },
35
- "gitHead": "59095d5fafc8f898e0760163d108bb3cd5379b22"
35
+ "gitHead": "692355951ec33ee4b89018177e7ec4d58a66c073"
36
36
  }
@@ -698,9 +698,7 @@ const resolveScopedDynamicStyleValues = (
698
698
  const inlineStyleOverrides: Record<string, ParsedASTNode> = {}
699
699
  for (const cssProperty of Object.keys(style)) {
700
700
  const styleValue = style[cssProperty]
701
- const camelCaseProperty = cssProperty.replace(/-([a-z])/g, (_, letter: string) =>
702
- letter.toUpperCase()
703
- )
701
+ const camelCaseProperty = StringUtils.cssPropertyToInlineStyleKey(cssProperty)
704
702
 
705
703
  // A pre-resolved expression style value (e.g. a data-source-bound style whose
706
704
  // mapper already produced the full member-access expression). The UIDL style
@@ -2132,7 +2130,10 @@ const generateCMSListRepeaterNode: NodeToJSX<UIDLCMSListRepeaterNode, JSXASTRetu
2132
2130
 
2133
2131
  // When the repeater source is a global context like "ecommerce", resolve to
2134
2132
  // the appropriate array from the ecommerce context based on what the repeater
2135
- // iterates over (determined by renderPropIdentifier).
2133
+ // iterates over (determined by renderPropIdentifier). The editor's mapper
2134
+ // keeps only the global's id, not the array's path, so the identifier is the
2135
+ // whole contract: every e-commerce list the editor builds names its context
2136
+ // after one of these keys.
2136
2137
  let repeaterItemsExpr: types.Expression
2137
2138
  const source = node.content.source ?? 'params'
2138
2139
  if (source === 'ecommerce') {
@@ -2141,6 +2142,10 @@ const generateCMSListRepeaterNode: NodeToJSX<UIDLCMSListRepeaterNode, JSXASTRetu
2141
2142
  const ecommercePathMap: Record<string, string[]> = {
2142
2143
  paymentProvider: ['paymentProviders'],
2143
2144
  storeLocation: ['storeLocations'],
2145
+ // The checkout's shipping-method list (`Cart.shippingOptions`). Without
2146
+ // this entry it fell to the cart items below and offered the buyer their
2147
+ // own products as shipping methods.
2148
+ shippingMethod: ['Cart', 'shippingOptions'],
2144
2149
  }
2145
2150
  // Default: cart items for orderItem, cartItem, or any unrecognized identifier
2146
2151
  const path = ecommercePathMap[rpId] || ['Cart', 'items']
@@ -1045,6 +1045,26 @@ const resolveOperandExpression = (
1045
1045
  return convertValueToLiteral(operand, conditionalIdentifier.type)
1046
1046
  }
1047
1047
 
1048
+ /**
1049
+ * `resolveOperandExpression` for an operand that is ONE ELEMENT of the bound
1050
+ * collection (`contains` / `notContains`), not a value of the collection's own
1051
+ * type.
1052
+ *
1053
+ * The typed resolver parses a static operand as the identifier's type, which
1054
+ * for an array-typed state means `JSON.parse`: the string `"5"` came out as the
1055
+ * number `5`, `"true"` as `true`. The rows an array state actually holds are
1056
+ * whatever a workflow pushed — strings, read off `data-*` attributes — so
1057
+ * `selectedRatings.includes(5)` never matched `["5"]` and a ticked rating
1058
+ * checkbox stayed empty. The literal keeps the type it was authored with, which
1059
+ * is also how the editor's canvas evaluates the same condition.
1060
+ */
1061
+ const resolveElementOperandExpression = (
1062
+ operand: string | number | boolean | UIDLDynamicReference | UIDLExpressionValue,
1063
+ conditionalIdentifier: ConditionalIdentifier,
1064
+ options: { localIdentifier?: string; detailsPageExposeAsName?: string }
1065
+ ): types.Expression =>
1066
+ resolveOperandExpression(operand, { ...conditionalIdentifier, type: '' }, options)
1067
+
1048
1068
  /**
1049
1069
  * Coerce a conditional identifier to an empty collection when it is null or
1050
1070
  * undefined, so the collection operators below can dereference it safely.
@@ -1199,7 +1219,7 @@ export const createBinaryExpression = (
1199
1219
  }
1200
1220
 
1201
1221
  if (operation === 'contains' && operand !== undefined) {
1202
- const operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options)
1222
+ const operandExpr = resolveElementOperandExpression(operand, conditionalIdentifier, options)
1203
1223
  const target = createNullSafeCollection(identifier, conditionalIdentifier, t)
1204
1224
 
1205
1225
  if (containsField) {
@@ -1220,7 +1240,7 @@ export const createBinaryExpression = (
1220
1240
  }
1221
1241
 
1222
1242
  if (operation === 'notContains' && operand !== undefined) {
1223
- const operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options)
1243
+ const operandExpr = resolveElementOperandExpression(operand, conditionalIdentifier, options)
1224
1244
  const target = createNullSafeCollection(identifier, conditionalIdentifier, t)
1225
1245
 
1226
1246
  if (containsField) {
@@ -949,7 +949,14 @@ export const createStateHookAST = (
949
949
  } else if (
950
950
  stateDefinition.urlSearchParamBinding &&
951
951
  typeof stateDefinition.urlSearchParamBinding.key === 'string' &&
952
- stateDefinition.urlSearchParamBinding.key !== ''
952
+ stateDefinition.urlSearchParamBinding.key !== '' &&
953
+ // `hydrateAfterMount`: the state keeps its static default on the client's
954
+ // first render too, and the router read-back effect adopts the URL value
955
+ // once `router.isReady` — a real update, so the elements it gates
956
+ // re-render. Needed where the server markup and a URL-seeded client value
957
+ // would differ only in ATTRIBUTES of same-tag siblings (a pressed toggle):
958
+ // React 17 does not patch those on hydration. See the type's docs.
959
+ stateDefinition.urlSearchParamBinding.hydrateAfterMount !== true
953
960
  ) {
954
961
  // URL-search-param binding: seed the initial state directly from
955
962
  // `window.location.search`. We deliberately DO NOT use Next.js'
@@ -32,6 +32,9 @@ const accessKeyOf = (object: types.Expression, paramKey: string): types.MemberEx
32
32
  return types.memberExpression(object, types.stringLiteral(paramKey), true)
33
33
  }
34
34
 
35
+ const adoptedRefCurrent = (refName: string): types.MemberExpression =>
36
+ types.memberExpression(types.identifier(refName), types.identifier('current'))
37
+
35
38
  const routerQueryAccess = (paramKey: string): types.MemberExpression =>
36
39
  accessKeyOf(
37
40
  types.memberExpression(types.identifier('router'), types.identifier('query')),
@@ -91,11 +94,20 @@ const clone = (expr: types.Expression): types.Expression =>
91
94
  // means there is nothing to re-assert.
92
95
  // 4. Empty / null value deletes the key entirely so the URL never keeps a
93
96
  // sticky `?key=` empty param. The writer treats `undefined` as "remove".
97
+ // 5. `adoptedRefName` (optional) names a `useRef(false)` the paired read-back
98
+ // flips once it has adopted the URL value; until then the write-back stays
99
+ // silent. For a state seeded with its DEFAULT rather than from the URL
100
+ // (`urlSearchParamBinding.hydrateAfterMount`): on the first ready render
101
+ // the state still holds the default, and a write-back running before the
102
+ // read-back would push that default onto the URL — deleting the very key
103
+ // the read-back was about to adopt — after which the two chase each other
104
+ // forever (`/products?view=list` → `/products` → …).
94
105
  export const buildUrlWriteBackEffect = (
95
106
  paramKey: string,
96
107
  valueExpr: types.Expression,
97
108
  depExpr: types.Expression,
98
- defaultValueExpr?: types.Expression
109
+ defaultValueExpr?: types.Expression,
110
+ adoptedRefName?: string
99
111
  ): types.ExpressionStatement => {
100
112
  // value === '' || value == null [|| value === <default>]
101
113
  let deleteCondition: types.Expression = types.logicalExpression(
@@ -129,6 +141,15 @@ export const buildUrlWriteBackEffect = (
129
141
  ),
130
142
  types.returnStatement(null)
131
143
  ),
144
+ // if (!<adoptedRef>.current) return — only with `adoptedRefName`, see note 5
145
+ ...(adoptedRefName
146
+ ? [
147
+ types.ifStatement(
148
+ types.unaryExpression('!', adoptedRefCurrent(adoptedRefName)),
149
+ types.returnStatement(null)
150
+ ),
151
+ ]
152
+ : []),
132
153
  // __tqWriteQueryParam('<key>', <deleteCondition> ? undefined : <value>)
133
154
  URLQueryWriter.buildQueryWriteCall(
134
155
  paramKey,
@@ -183,10 +204,14 @@ export const buildUrlWriteBackEffect = (
183
204
  // key, forcing an extra unsorted fetch and losing the ordering. It also keeps
184
205
  // browser back/forward to the param-free URL restoring the default view.
185
206
  // Omitting it reproduces the pre-default `''` fallback byte-for-byte.
207
+ //
208
+ // `adoptedRefName` (optional): the flag the paired write-back waits on — set
209
+ // once the URL value has been handed to the state. See the write-back's note 5.
186
210
  export const buildUrlReadBackEffect = (
187
211
  paramKey: string,
188
212
  setterName: string,
189
- defaultValueExpr?: types.Expression
213
+ defaultValueExpr?: types.Expression,
214
+ adoptedRefName?: string
190
215
  ): types.ExpressionStatement => {
191
216
  const normalizeArg = types.conditionalExpression(
192
217
  // typeof __urlValue === 'string' ? __urlValue
@@ -252,6 +277,18 @@ export const buildUrlReadBackEffect = (
252
277
  ),
253
278
  ])
254
279
  ),
280
+ // <adoptedRef>.current = true — only with `adoptedRefName`
281
+ ...(adoptedRefName
282
+ ? [
283
+ types.expressionStatement(
284
+ types.assignmentExpression(
285
+ '=',
286
+ adoptedRefCurrent(adoptedRefName),
287
+ types.booleanLiteral(true)
288
+ )
289
+ ),
290
+ ]
291
+ : []),
255
292
  ])
256
293
 
257
294
  return types.expressionStatement(