@geastack/compiler 1.0.17 → 1.0.18

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.
@@ -74,6 +74,23 @@ const claimedElement = (node, carriers) => {
74
74
  * question is asked of it rather than of a list of class names kept here.
75
75
  */
76
76
  const childAdderOf = (carrier, members) => members.has(`${carrier}.addArrangedSubview`) ? 'addArrangedSubview' : 'addSubview';
77
+ /**
78
+ * The view a parent's children are added TO, which is not always the parent.
79
+ *
80
+ * A `UIVisualEffectView` (and a table or collection cell) owns a `contentView`
81
+ * and takes every subview through it; adding one to the effect view itself is
82
+ * a UIKit assertion, so the app aborts at launch inside `_addSubview:`. The
83
+ * member table again decides: a view that has both a `contentView` and its
84
+ * own `addSubview` is one whose content view is where children belong. A
85
+ * window has a `contentView` but no `addSubview`, so it is left as it is.
86
+ *
87
+ * The receiver is asserted non-null. `NSBox` declares its content view
88
+ * nullable (it can be unset), and the checker would otherwise refuse
89
+ * `box.contentView.addSubview(...)` for a box that has just been constructed
90
+ * and cannot be without one; on `UIVisualEffectView`, whose content view is
91
+ * not nullable, the assertion is a no-op the checker accepts.
92
+ */
93
+ const childReceiverOf = (view, carrier, members) => members.has(`${carrier}.contentView`) && members.has(`${carrier}.addSubview`) ? `${view}.contentView!` : view;
77
94
  /** The source text of a node, exactly as the author wrote it. */
78
95
  const sourceTextOf = (node, file) => node.getText(file);
79
96
  /**
@@ -220,15 +237,16 @@ const elementExpressionText = (claimed, file, carriers, members, nextName) => {
220
237
  statements.push(setter ?? `${view}.${attribute.name.text} = ${value};`);
221
238
  }
222
239
  const adder = childAdderOf(carrier, members);
240
+ const receiver = childReceiverOf(view, carrier, members);
223
241
  for (const child of claimed.children) {
224
242
  const nested = claimedElement(child, carriers);
225
243
  if (nested) {
226
- statements.push(`${view}.${adder}(${elementExpressionText(nested, file, carriers, members, nextName)});`);
244
+ statements.push(`${receiver}.${adder}(${elementExpressionText(nested, file, carriers, members, nextName)});`);
227
245
  continue;
228
246
  }
229
247
  if (ts.isJsxExpression(child)) {
230
248
  if (child.expression)
231
- statements.push(`${view}.${adder}(${sourceTextOf(child.expression, file)});`);
249
+ statements.push(`${receiver}.${adder}(${sourceTextOf(child.expression, file)});`);
232
250
  continue;
233
251
  }
234
252
  if (ts.isJsxText(child)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/compiler",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "The geastack TypeScript-to-C++ compiler: one semantic spine, no source-shaped authority, no boxing of statically typed values.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {