@nac3/runtime 2.8.0 → 2.9.1

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.
package/dist/nac.mjs CHANGED
@@ -7,7 +7,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
7
7
  =====================================================================
8
8
 
9
9
  AUTHORITATIVE VERSION CONSTANT: see the global.NAC export at the
10
- bottom of this file. `version: '2.8.0', spec_version: '2.8'`
10
+ bottom of this file. `version: '2.9.1', spec_version: '2.9'`
11
11
  is the normative declaration. The dated changelog sections below are
12
12
  historical notes; if they ever drift from the export, the export
13
13
  wins.
@@ -344,14 +344,54 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
344
344
  So they refuse by name. The headless profile (sec 19) is the other
345
345
  half of the same rule: a surface with no document is reached
346
346
  through the extension contract (sec 15), never through these. */
347
- function _nac_requireDocument(where) {
348
- if (typeof document !== 'undefined' && document) return;
349
- throw NacError('no_document',
347
+ /* ONE producer of the refusal. Two consumers: the primitives that
348
+ call the guard inline since 2.7.0, and the install-time pass at the
349
+ bottom of this file that applies it to the rest of the family
350
+ (2.9.1). A second copy of this message would be a second answer to
351
+ "what does the contract say when there is no document". */
352
+ function _nac_noDocumentError(where) {
353
+ return NacError('no_document',
350
354
  'NAC.' + where + ': no document in this context, so there is no node to resolve. ' +
351
355
  'Reach a declared surface through the extension contract -- NAC.call / NAC.read / ' +
352
356
  'NAC.subscribe (SPEC sec 15) -- and see the headless profile (SPEC sec 19).',
353
357
  { primitive: where });
354
358
  }
359
+ function _nac_requireDocument(where) {
360
+ if (typeof document !== 'undefined' && document) return;
361
+ throw _nac_noDocumentError(where);
362
+ }
363
+
364
+ /* 2.9.1 -- escape a value that is about to be interpolated into a
365
+ QUOTED attribute selector: [data-nac-id="<value>"].
366
+
367
+ WHY. Every id the runtime resolves arrives from outside -- the
368
+ adopter's markup or the agent's call -- and went straight into the
369
+ selector string. A nac_id carrying a double quote closed the string
370
+ and the browser answered with a raw DOMException ("is not a valid
371
+ selector") where the contract promises not_found; a comma could
372
+ continue the selector LIST and resolve a different element. Neither
373
+ is XSS -- a selector does not execute -- but both are an unsanitised
374
+ value reaching a sink, and one of them is a crash where a code was
375
+ promised.
376
+
377
+ Inside a quoted CSS string only two characters can break out, the
378
+ backslash and the quote itself, so those two are escaped and
379
+ nothing else is touched: a dot stays a dot, which matters because
380
+ every NAC id has them. A raw newline is invalid inside a CSS string,
381
+ so it travels as a numeric escape (the trailing space ends it).
382
+
383
+ Deliberately NOT CSS.escape(): that one escapes a value for use as
384
+ an IDENTIFIER, so it backslashes every dot in every id. The only
385
+ escaper this tree had (cssEscape in js/tester-report.js) does the
386
+ same, which is why the runtime could not borrow it. */
387
+ function _nac_attrValue(value) {
388
+ return String(value)
389
+ .replace(/[\\"]/g, function (c) { return '\\' + c; })
390
+ .replace(/[\n\r\f]/g, function (c) {
391
+ return '\\' + c.charCodeAt(0).toString(16) + ' ';
392
+ });
393
+ }
394
+
355
395
 
356
396
  /* ================================================================
357
397
  v2.5 / RFC V24-01: Plugin slug uniqueness gate (spec sec 7.4)
@@ -1791,7 +1831,33 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
1791
1831
  /* Structure. Every one of these is consumed by something: three
1792
1832
  are queried by this runtime, `list` hosts reorder(), and
1793
1833
  `canvas` is the door section 15.12 assigned to that surface. */
1794
- 'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas'
1834
+ 'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas',
1835
+
1836
+ /* ---- v2.9.0: the document vocabulary (SPEC.md 1.2) ----------
1837
+ THE DEFECT THIS CLOSES, and it was this project's own site.
1838
+ Measured 2026-11-27 with the PUBLISHED validator over the
1839
+ whole tree: 45 677 elements across 526 pages carried a role
1840
+ the specification did not declare, and they were not written
1841
+ by hand -- a single producer emits them,
1842
+ scripts/build-spec-html.mjs, which renders the normative text
1843
+ itself as a NAC3 page. So the document that declares the
1844
+ vocabulary was being served marked up in words it did not
1845
+ declare, 354 times per page.
1846
+
1847
+ Why declaring them is the right half of the fix rather than
1848
+ un-painting them: these are document structure, and under
1849
+ section 19 reading a document is a capability, not a side
1850
+ effect of having a screen. An agent with no screen navigates
1851
+ prose by heading; code says the text inside must be read
1852
+ verbatim rather than paraphrased. list and paragraph were
1853
+ already declared, so list-item and heading missing was half a
1854
+ family, which is why the count was in the tens of thousands.
1855
+
1856
+ All five are read-only: they go in _CLICK_NO_EVENT_ROLES
1857
+ below, never in the click family map, because putting a
1858
+ read-only role in that map would make click() promise a
1859
+ completion nobody emits. */
1860
+ 'heading', 'list-item', 'code', 'code-inline', 'note'
1795
1861
  ]);
1796
1862
 
1797
1863
  /* ---- Declared aliases (SPEC.md 1.5) ---------------------------
@@ -1912,7 +1978,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
1912
1978
  data-nac-role MUST match. Skip when DOM is not yet ready
1913
1979
  (a deferred check runs on DOMContentLoaded). */
1914
1980
  if (typeof document !== 'undefined' && document.body) {
1915
- const domEl = document.querySelector('[data-nac-id="' + id + '"]');
1981
+ const domEl = document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
1916
1982
  if (domEl) {
1917
1983
  const domRole = domEl.getAttribute('data-nac-role');
1918
1984
  if (domRole && role && domRole !== role) {
@@ -2273,7 +2339,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
2273
2339
 
2274
2340
  function edit_field(field_nac_id) {
2275
2341
  if (!field_nac_id) throw NacError('invalid', 'edit_field requires a nac_id');
2276
- const sourceEl = document.querySelector('[data-nac-id="' + field_nac_id + '"]');
2342
+ const sourceEl = document.querySelector('[data-nac-id="' + _nac_attrValue(field_nac_id) + '"]');
2277
2343
  if (!sourceEl) throw NacError('not_found', 'edit_field: ' + field_nac_id + ' not in DOM');
2278
2344
  if (sourceEl.tagName !== 'INPUT' && sourceEl.tagName !== 'TEXTAREA' && !sourceEl.isContentEditable) {
2279
2345
  throw NacError('invalid', 'edit_field: ' + field_nac_id + ' is not an editable widget');
@@ -2297,7 +2363,18 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
2297
2363
 
2298
2364
  const head = document.createElement('div');
2299
2365
  head.className = 'nac-editor-head';
2300
- head.innerHTML = '<span class="title">Editing ' + field_nac_id + '</span>';
2366
+ /* 2.9.1 -- the title carries the nac_id, and a nac_id is adopter
2367
+ data: ids built from user-supplied text ("row." + title) are the
2368
+ pattern the spec asks for. Through innerHTML that made the EDITOR
2369
+ the one primitive that executed its own argument -- a stored XSS
2370
+ reachable by the contract's happy path. The two other dialog
2371
+ builders in this file never did: toast() writes textContent and
2372
+ confirm_dialog() escapes. Same node, same class, text instead of
2373
+ markup. */
2374
+ const headTitle = document.createElement('span');
2375
+ headTitle.className = 'title';
2376
+ headTitle.textContent = 'Editing ' + field_nac_id;
2377
+ head.appendChild(headTitle);
2301
2378
  modal.appendChild(head);
2302
2379
 
2303
2380
  const toolbar = document.createElement('div');
@@ -2702,7 +2779,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
2702
2779
  /* Wait for the plugin root to mount, then apply.
2703
2780
  Some plugins register before their DOM is mounted. */
2704
2781
  function apply() {
2705
- const root = document.querySelector('[data-nac-plugin="' + slug + '"]');
2782
+ const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(slug) + '"]');
2706
2783
  if (!root) {
2707
2784
  /* Try once after DOMContentLoaded if root is not yet in DOM. */
2708
2785
  if (document.readyState === 'loading') {
@@ -3216,8 +3293,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
3216
3293
  action: el.getAttribute('data-nac-action') || null,
3217
3294
  error: el.getAttribute('data-nac-error') || null,
3218
3295
  label: el.getAttribute('aria-label')
3219
- || (el.id && document.querySelector('label[for="' + el.id + '"]')
3220
- ? document.querySelector('label[for="' + el.id + '"]').textContent.trim()
3296
+ || (el.id && document.querySelector('label[for="' + _nac_attrValue(el.id) + '"]')
3297
+ ? document.querySelector('label[for="' + _nac_attrValue(el.id) + '"]').textContent.trim()
3221
3298
  : null)
3222
3299
  /* Fallback for KPI/feedback/static elements: look for an
3223
3300
  inner labeled child by convention. Resolves the case
@@ -3495,7 +3572,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
3495
3572
  }
3496
3573
  }
3497
3574
  return {
3498
- spec_version: '2.8',
3575
+ spec_version: '2.9',
3499
3576
  canonical: Array.from(_KNOWN_ROLES_V22),
3500
3577
  aliases: Object.assign({}, _ROLE_ALIASES),
3501
3578
  registered: registered,
@@ -3795,6 +3872,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
3795
3872
  'breadcrumb', 'pagination-control',
3796
3873
  'avatar', 'presence-indicator', 'skeleton', 'empty-state',
3797
3874
  'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas',
3875
+ /* v2.9.0: the five document roles. Read-only, every one. */
3876
+ 'heading', 'list-item', 'code', 'code-inline', 'note',
3798
3877
  ]);
3799
3878
 
3800
3879
  /* v1.6.4: field types whose click() act on a value (toggle).
@@ -4124,13 +4203,13 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4124
4203
  /* Field-change events fire on the parent field when an option
4125
4204
  is clicked; resolve those too. */
4126
4205
  if (e.type === 'nac:field:changed' && d && d.nac_id) {
4127
- var parentField = el.closest('[data-nac-id="' + d.nac_id + '"]');
4206
+ var parentField = el.closest('[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
4128
4207
  if (parentField) return true;
4129
4208
  /* Or: the element is a descendant of an element whose nac_id
4130
4209
  matches the field that fired. */
4131
4210
  var fieldHost = document.querySelector(
4132
- '[data-nac-role="field"][data-nac-id="' + d.nac_id + '"], ' +
4133
- '[data-nac-role="combobox"][data-nac-id="' + d.nac_id + '"]');
4211
+ '[data-nac-role="field"][data-nac-id="' + _nac_attrValue(d.nac_id) + '"], ' +
4212
+ '[data-nac-role="combobox"][data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
4134
4213
  if (fieldHost && fieldHost.contains(el)) return true;
4135
4214
  /* v1.6.4-v1.6.5: combobox option click. The host's option
4136
4215
  click handler emits nac:field:changed on the parent field
@@ -4154,7 +4233,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4154
4233
  ? optPluginNode.getAttribute('data-nac-plugin') : null;
4155
4234
  }
4156
4235
  var fieldElForPlugin = document.querySelector(
4157
- '[data-nac-id="' + d.nac_id + '"]');
4236
+ '[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
4158
4237
  var fieldPluginNode = fieldElForPlugin
4159
4238
  ? fieldElForPlugin.closest('[data-nac-plugin]') : null;
4160
4239
  var fieldPluginSlug = fieldPluginNode
@@ -4329,8 +4408,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4329
4408
  }
4330
4409
  /* Non-native select widget: try clicking the option element. */
4331
4410
  const root = el.closest('[data-nac-plugin]') || document;
4332
- const opt = root.querySelector('[data-nac-id="' + nac_id + '.' + option + '"]')
4333
- || root.querySelector('[data-nac-id="' + option + '"]');
4411
+ const opt = root.querySelector('[data-nac-id="' + _nac_attrValue(nac_id) + '.' + _nac_attrValue(option) + '"]')
4412
+ || root.querySelector('[data-nac-id="' + _nac_attrValue(option) + '"]');
4334
4413
  if (opt) { _focusElement(opt); opt.click(); return { ok: true }; }
4335
4414
  throw NacError('not_found', 'option ' + option + ' not present in ' + nac_id);
4336
4415
  }
@@ -4359,7 +4438,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4359
4438
  if (tab_key === undefined && typeof plugin === 'string' && plugin.indexOf('.') >= 0) {
4360
4439
  const bareId = plugin;
4361
4440
  let tabEl = document.querySelector(
4362
- '[data-nac-role="tab"][data-nac-id="' + bareId + '"]'
4441
+ '[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(bareId) + '"]'
4363
4442
  );
4364
4443
  /* H1.v7 (2026-05-21): strict resolution. If the bare id is not
4365
4444
  in DOM, try the qualified-instance fallback ONLY when the
@@ -4436,10 +4515,10 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4436
4515
  try { await wait_for('nac:tab:changed', 1500); } catch (e) { /* tolerated */ }
4437
4516
  return { ok: true };
4438
4517
  }
4439
- const root = document.querySelector('[data-nac-plugin="' + plugin + '"]');
4518
+ const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
4440
4519
  if (!root) throw NacError('not_found', 'plugin ' + plugin + ' not mounted');
4441
4520
  const tabEl = root.querySelector(
4442
- '[data-nac-role="tab"][data-nac-id="' + tab_key + '"]'
4521
+ '[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(tab_key) + '"]'
4443
4522
  );
4444
4523
  if (!tabEl) throw NacError('not_found', 'tab ' + tab_key + ' missing');
4445
4524
  /* v2.5 V24-04 OCC gate (two-arg path). */
@@ -4509,14 +4588,14 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4509
4588
  Fall through to the DOM scan so we pick whichever qualified
4510
4589
  instance is actually mounted. */
4511
4590
  if (matched && matched.nac_id) {
4512
- const probe = document.querySelector('[data-nac-id="' + matched.nac_id + '"]');
4591
+ const probe = document.querySelector('[data-nac-id="' + _nac_attrValue(matched.nac_id) + '"]');
4513
4592
  if (!probe) matched = null;
4514
4593
  }
4515
4594
 
4516
4595
  if (!matched) {
4517
4596
  /* Fallback: scan DOM within plugin scope for [data-nac-action]. */
4518
4597
  const root = targetPlugin
4519
- ? document.querySelector('[data-nac-plugin="' + targetPlugin + '"]')
4598
+ ? document.querySelector('[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]')
4520
4599
  : document;
4521
4600
  if (root) {
4522
4601
  if (qualifier) {
@@ -4531,7 +4610,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4531
4610
  SUFFIX after the "__" separator counts. Zero matches
4532
4611
  throws no_matching_instance; multiple matches throw
4533
4612
  ambiguous_qualifier. No silent resolution. */
4534
- const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
4613
+ const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
4535
4614
  const exact = [];
4536
4615
  for (let i = 0; i < cands.length; i++) {
4537
4616
  const id = cands[i].getAttribute('data-nac-id') || '';
@@ -4584,14 +4663,14 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4584
4663
  }
4585
4664
  matched = { nac_id: exact[0].getAttribute('data-nac-id'), verb: verb };
4586
4665
  } else if (qualifierOrdinal !== null) {
4587
- const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
4666
+ const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
4588
4667
  const el = cands[qualifierOrdinal];
4589
4668
  if (el && el.getAttribute('data-nac-id')) {
4590
4669
  matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
4591
4670
  }
4592
4671
  } else {
4593
4672
  /* Default: first match in DOM order. */
4594
- const el = root.querySelector('[data-nac-action="' + verb + '"]');
4673
+ const el = root.querySelector('[data-nac-action="' + _nac_attrValue(verb) + '"]');
4595
4674
  if (el && el.getAttribute('data-nac-id')) {
4596
4675
  matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
4597
4676
  }
@@ -4912,7 +4991,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
4912
4991
  that humans wouldn't say aloud). Same two-tier strict logic. */
4913
4992
  if (!matched) {
4914
4993
  const root = document.querySelector(
4915
- '[data-nac-plugin="' + targetPlugin + '"]');
4994
+ '[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]');
4916
4995
  if (root) {
4917
4996
  const tabs = Array.prototype.slice.call(
4918
4997
  root.querySelectorAll('[data-nac-role="tab"]'));
@@ -5001,7 +5080,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5001
5080
  /* Best-effort: serialize the active plugin DOM to data URL.
5002
5081
  For real screenshots, the runner uses Playwright's screenshot
5003
5082
  primitive; this is a fallback for in-page operators. */
5004
- const root = document.querySelector('[data-nac-plugin="' + _activePlugin() + '"]')
5083
+ const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(_activePlugin()) + '"]')
5005
5084
  || document.body;
5006
5085
  const xml = new XMLSerializer().serializeToString(root);
5007
5086
  return 'data:image/svg+xml;base64,' +
@@ -5029,7 +5108,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5029
5108
  function validate(plugin_slug) {
5030
5109
  const m = _manifests[plugin_slug];
5031
5110
  if (!m) return { ok: false, code: 'no_manifest' };
5032
- const root = document.querySelector('[data-nac-plugin="' + plugin_slug + '"]');
5111
+ const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]');
5033
5112
  if (!root) return { ok: false, code: 'plugin_not_mounted' };
5034
5113
  const found = {};
5035
5114
  const elemByNacId = {};
@@ -5220,8 +5299,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5220
5299
  m.rows.cells.forEach(function (col) {
5221
5300
  if (!col || !col.nac_id) return;
5222
5301
  const cell = sampleRow.querySelector(
5223
- '[data-nac-id$="' + col.nac_id + '"], '
5224
- + '[data-nac-cell="' + col.nac_id + '"]');
5302
+ '[data-nac-id$="' + _nac_attrValue(col.nac_id) + '"], '
5303
+ + '[data-nac-cell="' + _nac_attrValue(col.nac_id) + '"]');
5225
5304
  if (!cell) {
5226
5305
  pushErr('error', 'row_cell_missing', col.nac_id,
5227
5306
  'manifest declares row cell "' + col.nac_id
@@ -5238,7 +5317,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5238
5317
  b.items.forEach(function (item) {
5239
5318
  if (!item || !item.nac_id) return;
5240
5319
  const el = root.querySelector(
5241
- '[data-nac-role="breadcrumb-item"][data-nac-id="' + item.nac_id + '"]');
5320
+ '[data-nac-role="breadcrumb-item"][data-nac-id="' + _nac_attrValue(item.nac_id) + '"]');
5242
5321
  if (!el) {
5243
5322
  pushErr('error', 'breadcrumb_item_missing', item.nac_id,
5244
5323
  'breadcrumb item "' + item.nac_id
@@ -5307,7 +5386,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5307
5386
  {
5308
5387
  const sameSlug = Array.prototype.slice.call(
5309
5388
  document.querySelectorAll(
5310
- '[data-nac-plugin="' + plugin_slug + '"]'));
5389
+ '[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]'));
5311
5390
  if (sameSlug.length > 1) {
5312
5391
  const ids = sameSlug.map(function (r) {
5313
5392
  return r.getAttribute('data-nac-plugin-id') || '';
@@ -5901,8 +5980,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5901
5980
  /* ---------- v1.2: window chrome (min/max/restore) --------------- */
5902
5981
 
5903
5982
  function _findPluginRoot(plugin) {
5904
- return document.querySelector('[data-nac-plugin="' + plugin + '"]')
5905
- || document.querySelector('[data-nac-id="' + plugin + '"]');
5983
+ return document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]')
5984
+ || document.querySelector('[data-nac-id="' + _nac_attrValue(plugin) + '"]');
5906
5985
  }
5907
5986
 
5908
5987
  function _setPluginState(plugin, newState) {
@@ -6080,7 +6159,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6080
6159
 
6081
6160
  function _genericReset(plugin_slug) {
6082
6161
  const root = plugin_slug
6083
- ? document.querySelector('[data-nac-plugin="' + plugin_slug + '"]')
6162
+ ? document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]')
6084
6163
  : document;
6085
6164
  if (!root) return false;
6086
6165
  /* Clear every NAC-instrumented field. Honours
@@ -6160,7 +6239,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6160
6239
 
6161
6240
  function _findSection(sectionId) {
6162
6241
  return document.querySelector(
6163
- '[data-nac-role="section"][data-nac-id="' + sectionId + '"]');
6242
+ '[data-nac-role="section"][data-nac-id="' + _nac_attrValue(sectionId) + '"]');
6164
6243
  }
6165
6244
 
6166
6245
  function list_sections() {
@@ -6271,7 +6350,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6271
6350
  }
6272
6351
  if (detail.plugin && detail.plugin_instance_id === undefined) {
6273
6352
  const root = document.querySelector(
6274
- '[data-nac-plugin="' + detail.plugin + '"]');
6353
+ '[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]');
6275
6354
  detail.plugin_instance_id = root
6276
6355
  ? (root.getAttribute('data-nac-plugin-id') || null)
6277
6356
  : null;
@@ -6298,9 +6377,9 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6298
6377
  payload filtering. */
6299
6378
  if (detail.plugin) {
6300
6379
  const root = document.querySelector(
6301
- '[data-nac-plugin="' + detail.plugin + '"]'
6380
+ '[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]'
6302
6381
  + (detail.plugin_instance_id
6303
- ? '[data-nac-plugin-id="' + detail.plugin_instance_id + '"]'
6382
+ ? '[data-nac-plugin-id="' + _nac_attrValue(detail.plugin_instance_id) + '"]'
6304
6383
  : ''));
6305
6384
  if (root && root.getAttribute('data-nac-plugin-bus') === 'enabled') {
6306
6385
  root.dispatchEvent(new CustomEvent(name, {
@@ -6363,9 +6442,9 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6363
6442
  exposure API. Falls back to document.querySelector when
6364
6443
  the deep helper is unavailable (defensive). */
6365
6444
  if (typeof _deepQuery === 'function') {
6366
- return _deepQuery('[data-nac-id="' + id + '"]', document);
6445
+ return _deepQuery('[data-nac-id="' + _nac_attrValue(id) + '"]', document);
6367
6446
  }
6368
- return document.querySelector('[data-nac-id="' + id + '"]');
6447
+ return document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
6369
6448
  }
6370
6449
 
6371
6450
  /* ---------- v1.3: toast / banner / confirm --------------------- */
@@ -6486,8 +6565,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6486
6565
  _emit(answer ? 'nac:confirm:confirmed' : 'nac:confirm:cancelled', { id: id });
6487
6566
  resolve(!!answer);
6488
6567
  }
6489
- card.querySelector('[data-nac-id="' + id + '.confirm"]').addEventListener('click', function () { done(true); });
6490
- card.querySelector('[data-nac-id="' + id + '.cancel"]').addEventListener('click', function () { done(false); });
6568
+ card.querySelector('[data-nac-id="' + _nac_attrValue(id) + '.confirm"]').addEventListener('click', function () { done(true); });
6569
+ card.querySelector('[data-nac-id="' + _nac_attrValue(id) + '.cancel"]').addEventListener('click', function () { done(false); });
6491
6570
  });
6492
6571
  }
6493
6572
  function list_pending_confirms() {
@@ -6560,7 +6639,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6560
6639
 
6561
6640
  function _stepperRoot(stepper_id) {
6562
6641
  return document.querySelector(
6563
- '[data-nac-role="stepper"][data-nac-id="' + stepper_id + '"]');
6642
+ '[data-nac-role="stepper"][data-nac-id="' + _nac_attrValue(stepper_id) + '"]');
6564
6643
  }
6565
6644
  function _stepperSteps(stepper_id) {
6566
6645
  const root = _stepperRoot(stepper_id);
@@ -6616,7 +6695,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6616
6695
 
6617
6696
  function _treeNode(node_id) {
6618
6697
  return document.querySelector(
6619
- '[data-nac-role="treenode"][data-nac-id="' + node_id + '"]');
6698
+ '[data-nac-role="treenode"][data-nac-id="' + _nac_attrValue(node_id) + '"]');
6620
6699
  }
6621
6700
  function tree_expand(node_id) {
6622
6701
  const n = _treeNode(node_id);
@@ -6675,7 +6754,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6675
6754
 
6676
6755
  function _tagFieldRoot(field_id) {
6677
6756
  const el = document.querySelector(
6678
- '[data-nac-role="field"][data-nac-field-type="tag-input"][data-nac-id="' + field_id + '"]');
6757
+ '[data-nac-role="field"][data-nac-field-type="tag-input"][data-nac-id="' + _nac_attrValue(field_id) + '"]');
6679
6758
  return el;
6680
6759
  }
6681
6760
  function add_tag(field_id, value) {
@@ -6705,8 +6784,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6705
6784
 
6706
6785
  function _drawer(id) {
6707
6786
  return document.querySelector(
6708
- '[data-nac-role="drawer"][data-nac-id="' + id + '"], ' +
6709
- '[data-nac-role="bottom-sheet"][data-nac-id="' + id + '"]');
6787
+ '[data-nac-role="drawer"][data-nac-id="' + _nac_attrValue(id) + '"], ' +
6788
+ '[data-nac-role="bottom-sheet"][data-nac-id="' + _nac_attrValue(id) + '"]');
6710
6789
  }
6711
6790
  function open_drawer(id, position) {
6712
6791
  const d = _drawer(id);
@@ -6733,14 +6812,14 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6733
6812
 
6734
6813
  function calendar_view(cal_id, view) {
6735
6814
  const c = document.querySelector(
6736
- '[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
6815
+ '[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
6737
6816
  if (!c) throw NacError('calendar_not_found', cal_id);
6738
6817
  c.setAttribute('data-nac-view', view);
6739
6818
  _emit('nac:calendar:view_changed', { calendar_id: cal_id, view: view });
6740
6819
  }
6741
6820
  function calendar_go_to(cal_id, date) {
6742
6821
  const c = document.querySelector(
6743
- '[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
6822
+ '[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
6744
6823
  if (!c) throw NacError('calendar_not_found', cal_id);
6745
6824
  c.setAttribute('data-nac-date', date);
6746
6825
  _emit('nac:calendar:date_selected', { calendar_id: cal_id, date: date });
@@ -6757,7 +6836,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6757
6836
  }
6758
6837
  function calendar_list_events(cal_id /*, from, to */) {
6759
6838
  const c = document.querySelector(
6760
- '[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
6839
+ '[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
6761
6840
  if (!c) return [];
6762
6841
  const out = [];
6763
6842
  c.querySelectorAll('[data-nac-role="calendar-event"]').forEach(function (e) {
@@ -6776,7 +6855,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6776
6855
 
6777
6856
  function chart_data(chart_id) {
6778
6857
  const c = document.querySelector(
6779
- '[data-nac-role="chart"][data-nac-id="' + chart_id + '"]');
6858
+ '[data-nac-role="chart"][data-nac-id="' + _nac_attrValue(chart_id) + '"]');
6780
6859
  if (!c) throw NacError('chart_not_found', chart_id);
6781
6860
  const series = [];
6782
6861
  c.querySelectorAll('[data-nac-role="chart-series"]').forEach(function (s) {
@@ -6800,7 +6879,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6800
6879
  }
6801
6880
  function chart_toggle_series(chart_id, series_id, on) {
6802
6881
  const s = document.querySelector(
6803
- '[data-nac-role="chart-series"][data-nac-id="' + series_id + '"]');
6882
+ '[data-nac-role="chart-series"][data-nac-id="' + _nac_attrValue(series_id) + '"]');
6804
6883
  if (!s) throw NacError('chart_series_not_found', series_id);
6805
6884
  const target = (typeof on === 'boolean') ? on : (s.getAttribute('data-nac-state') === 'hidden');
6806
6885
  s.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
@@ -6814,7 +6893,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6814
6893
 
6815
6894
  function map_focus(map_id, lat, lng, zoom) {
6816
6895
  const m = document.querySelector(
6817
- '[data-nac-role="map"][data-nac-id="' + map_id + '"]');
6896
+ '[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
6818
6897
  if (!m) throw NacError('map_not_found', map_id);
6819
6898
  m.setAttribute('data-nac-lat', String(lat));
6820
6899
  m.setAttribute('data-nac-lng', String(lng));
@@ -6826,7 +6905,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6826
6905
  }
6827
6906
  function map_select_marker(marker_id) {
6828
6907
  const mk = document.querySelector(
6829
- '[data-nac-role="map-marker"][data-nac-id="' + marker_id + '"]');
6908
+ '[data-nac-role="map-marker"][data-nac-id="' + _nac_attrValue(marker_id) + '"]');
6830
6909
  if (!mk) throw NacError('map_marker_not_found', marker_id);
6831
6910
  mk.setAttribute('data-nac-state', 'selected');
6832
6911
  const map_id = (mk.closest('[data-nac-role="map"]') || {}).getAttribute
@@ -6842,7 +6921,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6842
6921
  }
6843
6922
  function map_toggle_layer(map_id, layer_id, on) {
6844
6923
  const ly = document.querySelector(
6845
- '[data-nac-role="map-layer"][data-nac-id="' + layer_id + '"]');
6924
+ '[data-nac-role="map-layer"][data-nac-id="' + _nac_attrValue(layer_id) + '"]');
6846
6925
  if (!ly) throw NacError('map_layer_not_found', layer_id);
6847
6926
  const target = (typeof on === 'boolean') ? on : (ly.getAttribute('data-nac-state') === 'hidden');
6848
6927
  ly.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
@@ -6850,7 +6929,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6850
6929
  }
6851
6930
  function list_markers(map_id) {
6852
6931
  const m = document.querySelector(
6853
- '[data-nac-role="map"][data-nac-id="' + map_id + '"]');
6932
+ '[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
6854
6933
  if (!m) return [];
6855
6934
  const out = [];
6856
6935
  m.querySelectorAll('[data-nac-role="map-marker"]').forEach(function (mk) {
@@ -6884,7 +6963,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6884
6963
 
6885
6964
  function _breadcrumbContainer(crumb_id) {
6886
6965
  return document.querySelector(
6887
- '[data-nac-role="breadcrumb"][data-nac-id="' + crumb_id + '"]');
6966
+ '[data-nac-role="breadcrumb"][data-nac-id="' + _nac_attrValue(crumb_id) + '"]');
6888
6967
  }
6889
6968
  function _breadcrumbItems(rootEl) {
6890
6969
  if (!rootEl) return [];
@@ -6919,7 +6998,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6919
6998
  + item_id + '"]');
6920
6999
  if (!el) {
6921
7000
  // fallback: any anchor whose label matches
6922
- el = document.querySelector('a[data-nac-id="' + item_id + '"]');
7001
+ el = document.querySelector('a[data-nac-id="' + _nac_attrValue(item_id) + '"]');
6923
7002
  }
6924
7003
  if (!el) {
6925
7004
  return Promise.reject(new NacError('not_found',
@@ -6945,7 +7024,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
6945
7024
 
6946
7025
  function _carousel(carousel_id) {
6947
7026
  return document.querySelector(
6948
- '[data-nac-role="carousel"][data-nac-id="' + carousel_id + '"]');
7027
+ '[data-nac-role="carousel"][data-nac-id="' + _nac_attrValue(carousel_id) + '"]');
6949
7028
  }
6950
7029
  function _carouselSlides(rootEl) {
6951
7030
  if (!rootEl) return [];
@@ -7046,7 +7125,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
7046
7125
 
7047
7126
  function _timeline(timeline_id) {
7048
7127
  return document.querySelector(
7049
- '[data-nac-role="timeline"][data-nac-id="' + timeline_id + '"]');
7128
+ '[data-nac-role="timeline"][data-nac-id="' + _nac_attrValue(timeline_id) + '"]');
7050
7129
  }
7051
7130
  function _timelineItems(rootEl) {
7052
7131
  if (!rootEl) return [];
@@ -7124,7 +7203,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
7124
7203
  'list not found: ' + list_id));
7125
7204
  }
7126
7205
  var item = list.querySelector(
7127
- '[data-nac-role="draggable"][data-nac-id="' + item_id + '"]')
7206
+ '[data-nac-role="draggable"][data-nac-id="' + _nac_attrValue(item_id) + '"]')
7128
7207
  || _byId(item_id);
7129
7208
  if (!item) {
7130
7209
  return Promise.reject(new NacError('not_found',
@@ -8660,6 +8739,53 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
8660
8739
  }
8661
8740
  }
8662
8741
 
8742
+ /* 2.9.1 (PND-168) -- WHO IS ALLOWED TO READ AN OUTGOING MESSAGE.
8743
+
8744
+ Both postMessage backends sent `binding.target_origin || '*'`, so a
8745
+ manifest that did not declare an origin broadcast the action's
8746
+ arguments to whatever origin happened to occupy that iframe. The
8747
+ INCOMING half was already right (both listeners filter on
8748
+ ev.source === iframe.contentWindow), which is what made the
8749
+ outgoing default stand out rather than look like the house style.
8750
+
8751
+ The default is now the origin of the iframe the adopter pointed at,
8752
+ read from its src. '*' survives exactly where it is the only thing
8753
+ that can work -- srcdoc, about:blank, a blob or no src at all,
8754
+ which all resolve to an opaque origin -- and it survives where the
8755
+ adopter asks for it by declaring target_origin: '*'.
8756
+
8757
+ The derivation is announced once per message id. An adopter whose
8758
+ iframe has navigated cross-origin since it was mounted would
8759
+ otherwise see the message silently dropped by the browser, and a
8760
+ silent drop is the one outcome this project does not accept: the
8761
+ line names the origin it chose and how to pin it. */
8762
+ const _v25_origin_notices = Object.create(null);
8763
+ function _v25_targetOrigin(binding, iframe, backend) {
8764
+ if (binding && binding.target_origin) return binding.target_origin;
8765
+ let origin = null;
8766
+ try {
8767
+ const raw = iframe && typeof iframe.getAttribute === 'function'
8768
+ ? iframe.getAttribute('src') : null;
8769
+ if (raw && typeof URL === 'function') {
8770
+ const base = typeof location !== 'undefined' ? location.href : undefined;
8771
+ const resolved = new URL(String(raw), base).origin;
8772
+ if (resolved && resolved !== 'null') origin = resolved;
8773
+ }
8774
+ } catch (e) { origin = null; }
8775
+ if (!origin) return '*';
8776
+ const key = backend + ':' + (binding && binding.message) + ':' + origin;
8777
+ if (!_v25_origin_notices[key]) {
8778
+ _v25_origin_notices[key] = true;
8779
+ if (typeof console !== 'undefined' && console.warn) {
8780
+ console.warn('[nac] ' + backend + ': no target_origin declared for message "'
8781
+ + (binding && binding.message) + '", so it is posted to ' + origin
8782
+ + ', the origin of the target iframe. Declare target_origin in the manifest '
8783
+ + "to pin it (target_origin: '*' restores the pre-2.9.1 broadcast).");
8784
+ }
8785
+ }
8786
+ return origin;
8787
+ }
8788
+
8663
8789
  /* postmessage (verb): post a structured message to the iframe.contentWindow
8664
8790
  of the target. `values` literal + `values_from_args` forward keys. */
8665
8791
  function _v25_backend_postmessage(binding, args) {
@@ -8688,7 +8814,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
8688
8814
  }
8689
8815
  }
8690
8816
  try {
8691
- iframe.contentWindow.postMessage(msg, binding.target_origin || '*');
8817
+ iframe.contentWindow.postMessage(msg, _v25_targetOrigin(binding, iframe, 'postmessage'));
8692
8818
  return Promise.resolve({ ok: true });
8693
8819
  } catch (e) {
8694
8820
  return Promise.reject(e);
@@ -8794,7 +8920,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
8794
8920
  MessageId: binding.message,
8795
8921
  SendTime: Date.now(),
8796
8922
  Values: wantValues,
8797
- }, binding.target_origin || '*');
8923
+ }, _v25_targetOrigin(binding, iframe, 'script-bridge'));
8798
8924
  });
8799
8925
  }
8800
8926
 
@@ -9961,7 +10087,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
9961
10087
  subtree. If plugin is omitted, fall back to global search. */
9962
10088
  let root = document;
9963
10089
  if (plugin) {
9964
- const pluginRoot = document.querySelector('[data-nac-plugin="' + plugin + '"]');
10090
+ const pluginRoot = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
9965
10091
  if (!pluginRoot) return null;
9966
10092
  root = pluginRoot;
9967
10093
  }
@@ -10023,7 +10149,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
10023
10149
 
10024
10150
  function _v25b_pluginRoot(plugin) {
10025
10151
  if (!plugin) return null;
10026
- return document.querySelector('[data-nac-plugin="' + plugin + '"]');
10152
+ return document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
10027
10153
  }
10028
10154
 
10029
10155
  function context(plugin) {
@@ -10215,8 +10341,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
10215
10341
 
10216
10342
  global.NAC = {
10217
10343
  __nac_v1_installed: true,
10218
- version: '2.8.0',
10219
- spec_version: '2.8',
10344
+ version: '2.9.1',
10345
+ spec_version: '2.9',
10220
10346
  /* v2.2.0 (V22-01) -- strict validation toggle. When true,
10221
10347
  NAC.register throws on findings (manifest_role_unknown,
10222
10348
  tab_id_manifest_role_drift, manifest_dom_role_mismatch).
@@ -10588,6 +10714,115 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
10588
10714
  diff: diff,
10589
10715
  };
10590
10716
 
10717
+ /* ================================================================
10718
+ 2.9.1 -- SPEC 19.3 for the whole family (PND-162, PND-163)
10719
+ ================================================================
10720
+
10721
+ 19.3 names eight primitives and then says "and any other that
10722
+ resolves a name by querying the document". Since 2.7.0 the eight
10723
+ called _nac_requireDocument inline and the OTHERS did not: measured
10724
+ on 2026-11-28 by calling all 151 exports in a sandbox with no
10725
+ document, 69 of them still died with a raw
10726
+ "ReferenceError: document is not defined" -- the same defect D-26
10727
+ closed one layer up, and the suite that guarded it only ever tested
10728
+ the eight, so it asserted more than it measured.
10729
+
10730
+ Worst of them was wait_for: it scheduled a setTimeout BEFORE
10731
+ touching the document, so the ReferenceError came out of the timer
10732
+ -- outside every try/catch the caller could write -- and killed the
10733
+ Node process. A promise .catch() could not reach it.
10734
+
10735
+ WHY HERE, at install, and not inline in 69 bodies. Fail closed
10736
+ before the primitive does any work (which is what kills the timer
10737
+ path), one place to read, and the list is a DECLARATION a gate can
10738
+ enforce. Inline guards would be 69 edits to a published runtime for
10739
+ the same effect, and the next primitive would forget the line.
10740
+
10741
+ WHY TWO LISTS. The channel the refusal arrives through is part of
10742
+ the published surface: an adopter who wrote
10743
+ NAC.confirm(...).catch(h) must keep getting a rejection, not a
10744
+ synchronous throw. So each name carries the channel its failure
10745
+ ALREADY used, measured rather than guessed -- the async ones return
10746
+ a promise (three of them are not declared async: they return
10747
+ new Promise, and the executor's throw rejected). The suite checks
10748
+ this against an independent oracle: it calls the same primitive
10749
+ WITH a document and asks whether the return value is a thenable.
10750
+
10751
+ NOT in these lists, on purpose: the eight that guard inline (their
10752
+ call sites read better where they are), and everything that works
10753
+ with no document at all -- the extension contract (call / read /
10754
+ subscribe), the manifest surface, profile(), the provenance sink.
10755
+ Those are the headless profile, and guarding them would break
10756
+ section 19 instead of serving it. */
10757
+ const _NAC_DOM_PRIMITIVES_SYNC = [
10758
+ 'add_tag', 'calendar_go_to', 'calendar_list_events',
10759
+ 'calendar_select_event', 'calendar_view', 'carousel_state',
10760
+ 'chart_data', 'chart_filter', 'chart_toggle_series',
10761
+ 'close_drawer', 'dismiss_banner', 'dismiss_toast', 'edit_field',
10762
+ 'emit_dual', 'invalidate_options', 'is_blocked', 'list_banners',
10763
+ 'list_breadcrumbs', 'list_carousels', 'list_markers',
10764
+ 'list_pending_confirms', 'list_sections', 'list_tags',
10765
+ 'list_timelines', 'list_toasts', 'map_focus', 'map_select_marker',
10766
+ 'map_toggle_layer', 'open_drawer', 'peek_drawer', 'remove_tag',
10767
+ 'richtext_format', 'richtext_insert_link',
10768
+ 'richtext_insert_mention', 'set_a11y_hint_localizer', 'step_back',
10769
+ 'step_next', 'step_state', 'step_to', 'timeline_state', 'toast',
10770
+ 'tree_collapse', 'tree_expand', 'tree_path', 'tree_select',
10771
+ ];
10772
+ const _NAC_DOM_PRIMITIVES_ASYNC = [
10773
+ 'assert_event_count', 'assert_event_fired', 'carousel_advance',
10774
+ 'carousel_autoplay', 'carousel_to', 'click_by_verb', 'confirm',
10775
+ 'drag_drop', 'fullscreen', 'go_to_section', 'maximize', 'minimize',
10776
+ 'navigate_breadcrumb', 'perf_probe', 'reorder', 'reset', 'restore',
10777
+ 'screenshot', 'tab', 'tab_by_label', 'timeline_load_newer',
10778
+ 'timeline_load_older', 'validate_event_conformance', 'wait_for',
10779
+ ];
10780
+ function _nac_guardDomPrimitive(api, name, isAsync) {
10781
+ const fn = api[name];
10782
+ /* No silent no-op: a name in the table that is not exported means
10783
+ the table and the surface drifted, and the gate says so. */
10784
+ if (typeof fn !== 'function') return false;
10785
+ function guarded() {
10786
+ if (typeof document === 'undefined' || !document) {
10787
+ const err = _nac_noDocumentError(name);
10788
+ if (isAsync) return Promise.reject(err);
10789
+ throw err;
10790
+ }
10791
+ return fn.apply(this, arguments);
10792
+ }
10793
+ /* The published shape of a function is its name and its arity;
10794
+ both are read by adopters and by this tree's own gates. */
10795
+ try { Object.defineProperty(guarded, 'name', { value: name, configurable: true }); } catch (e) { /* older engines */ }
10796
+ try { Object.defineProperty(guarded, 'length', { value: fn.length, configurable: true }); } catch (e) { /* idem */ }
10797
+ guarded.__nac_requires_document = true;
10798
+ api[name] = guarded;
10799
+ return true;
10800
+ }
10801
+ (function _nac_installDocumentGuards(api) {
10802
+ const missing = [];
10803
+ for (let i = 0; i < _NAC_DOM_PRIMITIVES_SYNC.length; i++) {
10804
+ if (!_nac_guardDomPrimitive(api, _NAC_DOM_PRIMITIVES_SYNC[i], false)) {
10805
+ missing.push(_NAC_DOM_PRIMITIVES_SYNC[i]);
10806
+ }
10807
+ }
10808
+ for (let i = 0; i < _NAC_DOM_PRIMITIVES_ASYNC.length; i++) {
10809
+ if (!_nac_guardDomPrimitive(api, _NAC_DOM_PRIMITIVES_ASYNC[i], true)) {
10810
+ missing.push(_NAC_DOM_PRIMITIVES_ASYNC[i]);
10811
+ }
10812
+ }
10813
+ /* Readable from outside so a gate can enforce the declaration
10814
+ instead of re-deriving it, and so an adopter can ask whether a
10815
+ primitive needs a document before calling it. */
10816
+ api.documentPrimitives = function () {
10817
+ return {
10818
+ sync: _NAC_DOM_PRIMITIVES_SYNC.slice(),
10819
+ async: _NAC_DOM_PRIMITIVES_ASYNC.slice(),
10820
+ missing: missing.slice(),
10821
+ };
10822
+ };
10823
+ })(global.NAC);
10824
+
10825
+
10591
10826
  /* v2.2.1: guard browser-only init so this module is importable in
10592
10827
  Node / SSR / test contexts without crashing. */
10593
10828
  if (typeof document !== 'undefined') {