@m4l-jweb/wrapper 0.6.5 → 0.7.0

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/package.json +1 -1
  2. package/src/core.ts +47 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l-jweb/wrapper",
3
- "version": "0.6.5",
3
+ "version": "0.7.0",
4
4
  "description": "m4l-jweb: the Max for Live glue layer connecting a device to LiveAPI.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/core.ts CHANGED
@@ -204,6 +204,53 @@ function broadcastState(id: string, json: string): void {
204
204
  }
205
205
  }
206
206
 
207
+ /* ------------------------------------------------------------------ *
208
+ * Native dial visibility (layout.native runtime show/hide) - SPIKE
209
+ *
210
+ * The app (useNativeVisibility) sends `native_show`/`native_hide <varname>` to hide a
211
+ * native `live.*` object the current state does not use - the dynamic visibility a
212
+ * static `presentation` attribute cannot give. We reach the object through the Maxobj
213
+ * API (`this.patcher.getnamed`, the same `this.patcher` deviceFolder() uses) and set
214
+ * its `hidden` flag, LOGGING what we find.
215
+ *
216
+ * The open question, and the whole point of the spike: whether `hidden` (or anything
217
+ * reachable from here) makes a native object leave the M4L device PRESENTATION view
218
+ * at runtime. A first attempt - a `[thispatcher]` running `script hide` - was tried
219
+ * and did NOT work (script acts on the patching canvas, not the presentation). If
220
+ * this one also fails, a frozen M4L device cannot hide a native object at runtime and
221
+ * the fallback is a build-time choice. Watch the Max console for the lines below.
222
+ * ------------------------------------------------------------------ */
223
+
224
+ function native_show(varname: string): void {
225
+ setNativeHidden(varname, 0);
226
+ }
227
+ function native_hide(varname: string): void {
228
+ setNativeHidden(varname, 1);
229
+ }
230
+
231
+ function setNativeHidden(varname: string, hidden: number): void {
232
+ try {
233
+ // `this.patcher` is the device patcher (Max's global object IS the jsthis, so a
234
+ // plainly-called function still sees it - deviceFolder() relies on the same).
235
+ var obj = this.patcher.getnamed(varname);
236
+ if (!obj) {
237
+ post("m4l-jweb: native " + varname + " -> getnamed() null (no such scripting name)\n");
238
+ return;
239
+ }
240
+ // `hidden` is the documented Maxobj visibility toggle. CONFIRMED in Live: it
241
+ // reaches the M4L PRESENTATION view, so a native object vanishes from the device
242
+ // view - which is what the two-screen panel flip (useNativePanel) rides on.
243
+ //
244
+ // Reposition/resize does NOT work the same way: setting `presentation_rect` at
245
+ // runtime is accepted but never redrawn in a frozen M4L device (measured). So
246
+ // there is no `native_rect` here - the panel LAYERS views and hides one, rather
247
+ // than reflowing objects, because hide/show is the only thing that takes.
248
+ obj.hidden = hidden;
249
+ } catch (e) {
250
+ post("m4l-jweb: native " + varname + " error: " + (e as Error).message + "\n");
251
+ }
252
+ }
253
+
207
254
  /* ------------------------------------------------------------------ *
208
255
  * Floating-window messages
209
256
  *