@nac3/runtime 2.9.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/CHANGELOG.md +87 -0
- package/README.md +9 -0
- package/SPEC.md +1 -1
- package/contract-head.json +4 -4
- package/dist/cli-levels.json +1 -1
- package/dist/cli.js +5 -2
- package/dist/nac-chat-client.browser.js +19 -6
- package/dist/nac-chat-client.cjs +19 -6
- package/dist/nac-chat-client.mjs +19 -6
- package/dist/nac-mcp-interop.browser.js +83 -3
- package/dist/nac-mcp-interop.cjs +83 -3
- package/dist/nac-mcp-interop.mjs +83 -3
- package/dist/nac-v2-extensions.d.ts +1 -1
- package/dist/nac.browser.js +273 -66
- package/dist/nac.cjs +273 -66
- package/dist/nac.d.ts +1 -1
- package/dist/nac.mjs +273 -66
- package/package.json +1 -1
package/dist/nac.browser.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
=====================================================================
|
|
7
7
|
|
|
8
8
|
AUTHORITATIVE VERSION CONSTANT: see the global.NAC export at the
|
|
9
|
-
bottom of this file. `version: '2.9.
|
|
9
|
+
bottom of this file. `version: '2.9.1', spec_version: '2.9'`
|
|
10
10
|
is the normative declaration. The dated changelog sections below are
|
|
11
11
|
historical notes; if they ever drift from the export, the export
|
|
12
12
|
wins.
|
|
@@ -343,14 +343,54 @@
|
|
|
343
343
|
So they refuse by name. The headless profile (sec 19) is the other
|
|
344
344
|
half of the same rule: a surface with no document is reached
|
|
345
345
|
through the extension contract (sec 15), never through these. */
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
/* ONE producer of the refusal. Two consumers: the primitives that
|
|
347
|
+
call the guard inline since 2.7.0, and the install-time pass at the
|
|
348
|
+
bottom of this file that applies it to the rest of the family
|
|
349
|
+
(2.9.1). A second copy of this message would be a second answer to
|
|
350
|
+
"what does the contract say when there is no document". */
|
|
351
|
+
function _nac_noDocumentError(where) {
|
|
352
|
+
return NacError('no_document',
|
|
349
353
|
'NAC.' + where + ': no document in this context, so there is no node to resolve. ' +
|
|
350
354
|
'Reach a declared surface through the extension contract -- NAC.call / NAC.read / ' +
|
|
351
355
|
'NAC.subscribe (SPEC sec 15) -- and see the headless profile (SPEC sec 19).',
|
|
352
356
|
{ primitive: where });
|
|
353
357
|
}
|
|
358
|
+
function _nac_requireDocument(where) {
|
|
359
|
+
if (typeof document !== 'undefined' && document) return;
|
|
360
|
+
throw _nac_noDocumentError(where);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* 2.9.1 -- escape a value that is about to be interpolated into a
|
|
364
|
+
QUOTED attribute selector: [data-nac-id="<value>"].
|
|
365
|
+
|
|
366
|
+
WHY. Every id the runtime resolves arrives from outside -- the
|
|
367
|
+
adopter's markup or the agent's call -- and went straight into the
|
|
368
|
+
selector string. A nac_id carrying a double quote closed the string
|
|
369
|
+
and the browser answered with a raw DOMException ("is not a valid
|
|
370
|
+
selector") where the contract promises not_found; a comma could
|
|
371
|
+
continue the selector LIST and resolve a different element. Neither
|
|
372
|
+
is XSS -- a selector does not execute -- but both are an unsanitised
|
|
373
|
+
value reaching a sink, and one of them is a crash where a code was
|
|
374
|
+
promised.
|
|
375
|
+
|
|
376
|
+
Inside a quoted CSS string only two characters can break out, the
|
|
377
|
+
backslash and the quote itself, so those two are escaped and
|
|
378
|
+
nothing else is touched: a dot stays a dot, which matters because
|
|
379
|
+
every NAC id has them. A raw newline is invalid inside a CSS string,
|
|
380
|
+
so it travels as a numeric escape (the trailing space ends it).
|
|
381
|
+
|
|
382
|
+
Deliberately NOT CSS.escape(): that one escapes a value for use as
|
|
383
|
+
an IDENTIFIER, so it backslashes every dot in every id. The only
|
|
384
|
+
escaper this tree had (cssEscape in js/tester-report.js) does the
|
|
385
|
+
same, which is why the runtime could not borrow it. */
|
|
386
|
+
function _nac_attrValue(value) {
|
|
387
|
+
return String(value)
|
|
388
|
+
.replace(/[\\"]/g, function (c) { return '\\' + c; })
|
|
389
|
+
.replace(/[\n\r\f]/g, function (c) {
|
|
390
|
+
return '\\' + c.charCodeAt(0).toString(16) + ' ';
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
354
394
|
|
|
355
395
|
/* ================================================================
|
|
356
396
|
v2.5 / RFC V24-01: Plugin slug uniqueness gate (spec sec 7.4)
|
|
@@ -1937,7 +1977,7 @@
|
|
|
1937
1977
|
data-nac-role MUST match. Skip when DOM is not yet ready
|
|
1938
1978
|
(a deferred check runs on DOMContentLoaded). */
|
|
1939
1979
|
if (typeof document !== 'undefined' && document.body) {
|
|
1940
|
-
const domEl = document.querySelector('[data-nac-id="' + id + '"]');
|
|
1980
|
+
const domEl = document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
|
|
1941
1981
|
if (domEl) {
|
|
1942
1982
|
const domRole = domEl.getAttribute('data-nac-role');
|
|
1943
1983
|
if (domRole && role && domRole !== role) {
|
|
@@ -2298,7 +2338,7 @@
|
|
|
2298
2338
|
|
|
2299
2339
|
function edit_field(field_nac_id) {
|
|
2300
2340
|
if (!field_nac_id) throw NacError('invalid', 'edit_field requires a nac_id');
|
|
2301
|
-
const sourceEl = document.querySelector('[data-nac-id="' + field_nac_id + '"]');
|
|
2341
|
+
const sourceEl = document.querySelector('[data-nac-id="' + _nac_attrValue(field_nac_id) + '"]');
|
|
2302
2342
|
if (!sourceEl) throw NacError('not_found', 'edit_field: ' + field_nac_id + ' not in DOM');
|
|
2303
2343
|
if (sourceEl.tagName !== 'INPUT' && sourceEl.tagName !== 'TEXTAREA' && !sourceEl.isContentEditable) {
|
|
2304
2344
|
throw NacError('invalid', 'edit_field: ' + field_nac_id + ' is not an editable widget');
|
|
@@ -2322,7 +2362,18 @@
|
|
|
2322
2362
|
|
|
2323
2363
|
const head = document.createElement('div');
|
|
2324
2364
|
head.className = 'nac-editor-head';
|
|
2325
|
-
|
|
2365
|
+
/* 2.9.1 -- the title carries the nac_id, and a nac_id is adopter
|
|
2366
|
+
data: ids built from user-supplied text ("row." + title) are the
|
|
2367
|
+
pattern the spec asks for. Through innerHTML that made the EDITOR
|
|
2368
|
+
the one primitive that executed its own argument -- a stored XSS
|
|
2369
|
+
reachable by the contract's happy path. The two other dialog
|
|
2370
|
+
builders in this file never did: toast() writes textContent and
|
|
2371
|
+
confirm_dialog() escapes. Same node, same class, text instead of
|
|
2372
|
+
markup. */
|
|
2373
|
+
const headTitle = document.createElement('span');
|
|
2374
|
+
headTitle.className = 'title';
|
|
2375
|
+
headTitle.textContent = 'Editing ' + field_nac_id;
|
|
2376
|
+
head.appendChild(headTitle);
|
|
2326
2377
|
modal.appendChild(head);
|
|
2327
2378
|
|
|
2328
2379
|
const toolbar = document.createElement('div');
|
|
@@ -2727,7 +2778,7 @@
|
|
|
2727
2778
|
/* Wait for the plugin root to mount, then apply.
|
|
2728
2779
|
Some plugins register before their DOM is mounted. */
|
|
2729
2780
|
function apply() {
|
|
2730
|
-
const root = document.querySelector('[data-nac-plugin="' + slug + '"]');
|
|
2781
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(slug) + '"]');
|
|
2731
2782
|
if (!root) {
|
|
2732
2783
|
/* Try once after DOMContentLoaded if root is not yet in DOM. */
|
|
2733
2784
|
if (document.readyState === 'loading') {
|
|
@@ -3241,8 +3292,8 @@
|
|
|
3241
3292
|
action: el.getAttribute('data-nac-action') || null,
|
|
3242
3293
|
error: el.getAttribute('data-nac-error') || null,
|
|
3243
3294
|
label: el.getAttribute('aria-label')
|
|
3244
|
-
|| (el.id && document.querySelector('label[for="' + el.id + '"]')
|
|
3245
|
-
? document.querySelector('label[for="' + el.id + '"]').textContent.trim()
|
|
3295
|
+
|| (el.id && document.querySelector('label[for="' + _nac_attrValue(el.id) + '"]')
|
|
3296
|
+
? document.querySelector('label[for="' + _nac_attrValue(el.id) + '"]').textContent.trim()
|
|
3246
3297
|
: null)
|
|
3247
3298
|
/* Fallback for KPI/feedback/static elements: look for an
|
|
3248
3299
|
inner labeled child by convention. Resolves the case
|
|
@@ -4151,13 +4202,13 @@
|
|
|
4151
4202
|
/* Field-change events fire on the parent field when an option
|
|
4152
4203
|
is clicked; resolve those too. */
|
|
4153
4204
|
if (e.type === 'nac:field:changed' && d && d.nac_id) {
|
|
4154
|
-
var parentField = el.closest('[data-nac-id="' + d.nac_id + '"]');
|
|
4205
|
+
var parentField = el.closest('[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
|
|
4155
4206
|
if (parentField) return true;
|
|
4156
4207
|
/* Or: the element is a descendant of an element whose nac_id
|
|
4157
4208
|
matches the field that fired. */
|
|
4158
4209
|
var fieldHost = document.querySelector(
|
|
4159
|
-
'[data-nac-role="field"][data-nac-id="' + d.nac_id + '"], ' +
|
|
4160
|
-
'[data-nac-role="combobox"][data-nac-id="' + d.nac_id + '"]');
|
|
4210
|
+
'[data-nac-role="field"][data-nac-id="' + _nac_attrValue(d.nac_id) + '"], ' +
|
|
4211
|
+
'[data-nac-role="combobox"][data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
|
|
4161
4212
|
if (fieldHost && fieldHost.contains(el)) return true;
|
|
4162
4213
|
/* v1.6.4-v1.6.5: combobox option click. The host's option
|
|
4163
4214
|
click handler emits nac:field:changed on the parent field
|
|
@@ -4181,7 +4232,7 @@
|
|
|
4181
4232
|
? optPluginNode.getAttribute('data-nac-plugin') : null;
|
|
4182
4233
|
}
|
|
4183
4234
|
var fieldElForPlugin = document.querySelector(
|
|
4184
|
-
'[data-nac-id="' + d.nac_id + '"]');
|
|
4235
|
+
'[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
|
|
4185
4236
|
var fieldPluginNode = fieldElForPlugin
|
|
4186
4237
|
? fieldElForPlugin.closest('[data-nac-plugin]') : null;
|
|
4187
4238
|
var fieldPluginSlug = fieldPluginNode
|
|
@@ -4356,8 +4407,8 @@
|
|
|
4356
4407
|
}
|
|
4357
4408
|
/* Non-native select widget: try clicking the option element. */
|
|
4358
4409
|
const root = el.closest('[data-nac-plugin]') || document;
|
|
4359
|
-
const opt = root.querySelector('[data-nac-id="' + nac_id + '.' + option + '"]')
|
|
4360
|
-
|| root.querySelector('[data-nac-id="' + option + '"]');
|
|
4410
|
+
const opt = root.querySelector('[data-nac-id="' + _nac_attrValue(nac_id) + '.' + _nac_attrValue(option) + '"]')
|
|
4411
|
+
|| root.querySelector('[data-nac-id="' + _nac_attrValue(option) + '"]');
|
|
4361
4412
|
if (opt) { _focusElement(opt); opt.click(); return { ok: true }; }
|
|
4362
4413
|
throw NacError('not_found', 'option ' + option + ' not present in ' + nac_id);
|
|
4363
4414
|
}
|
|
@@ -4386,7 +4437,7 @@
|
|
|
4386
4437
|
if (tab_key === undefined && typeof plugin === 'string' && plugin.indexOf('.') >= 0) {
|
|
4387
4438
|
const bareId = plugin;
|
|
4388
4439
|
let tabEl = document.querySelector(
|
|
4389
|
-
'[data-nac-role="tab"][data-nac-id="' + bareId + '"]'
|
|
4440
|
+
'[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(bareId) + '"]'
|
|
4390
4441
|
);
|
|
4391
4442
|
/* H1.v7 (2026-05-21): strict resolution. If the bare id is not
|
|
4392
4443
|
in DOM, try the qualified-instance fallback ONLY when the
|
|
@@ -4463,10 +4514,10 @@
|
|
|
4463
4514
|
try { await wait_for('nac:tab:changed', 1500); } catch (e) { /* tolerated */ }
|
|
4464
4515
|
return { ok: true };
|
|
4465
4516
|
}
|
|
4466
|
-
const root = document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
4517
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
4467
4518
|
if (!root) throw NacError('not_found', 'plugin ' + plugin + ' not mounted');
|
|
4468
4519
|
const tabEl = root.querySelector(
|
|
4469
|
-
'[data-nac-role="tab"][data-nac-id="' + tab_key + '"]'
|
|
4520
|
+
'[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(tab_key) + '"]'
|
|
4470
4521
|
);
|
|
4471
4522
|
if (!tabEl) throw NacError('not_found', 'tab ' + tab_key + ' missing');
|
|
4472
4523
|
/* v2.5 V24-04 OCC gate (two-arg path). */
|
|
@@ -4536,14 +4587,14 @@
|
|
|
4536
4587
|
Fall through to the DOM scan so we pick whichever qualified
|
|
4537
4588
|
instance is actually mounted. */
|
|
4538
4589
|
if (matched && matched.nac_id) {
|
|
4539
|
-
const probe = document.querySelector('[data-nac-id="' + matched.nac_id + '"]');
|
|
4590
|
+
const probe = document.querySelector('[data-nac-id="' + _nac_attrValue(matched.nac_id) + '"]');
|
|
4540
4591
|
if (!probe) matched = null;
|
|
4541
4592
|
}
|
|
4542
4593
|
|
|
4543
4594
|
if (!matched) {
|
|
4544
4595
|
/* Fallback: scan DOM within plugin scope for [data-nac-action]. */
|
|
4545
4596
|
const root = targetPlugin
|
|
4546
|
-
? document.querySelector('[data-nac-plugin="' + targetPlugin + '"]')
|
|
4597
|
+
? document.querySelector('[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]')
|
|
4547
4598
|
: document;
|
|
4548
4599
|
if (root) {
|
|
4549
4600
|
if (qualifier) {
|
|
@@ -4558,7 +4609,7 @@
|
|
|
4558
4609
|
SUFFIX after the "__" separator counts. Zero matches
|
|
4559
4610
|
throws no_matching_instance; multiple matches throw
|
|
4560
4611
|
ambiguous_qualifier. No silent resolution. */
|
|
4561
|
-
const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
|
|
4612
|
+
const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4562
4613
|
const exact = [];
|
|
4563
4614
|
for (let i = 0; i < cands.length; i++) {
|
|
4564
4615
|
const id = cands[i].getAttribute('data-nac-id') || '';
|
|
@@ -4611,14 +4662,14 @@
|
|
|
4611
4662
|
}
|
|
4612
4663
|
matched = { nac_id: exact[0].getAttribute('data-nac-id'), verb: verb };
|
|
4613
4664
|
} else if (qualifierOrdinal !== null) {
|
|
4614
|
-
const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
|
|
4665
|
+
const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4615
4666
|
const el = cands[qualifierOrdinal];
|
|
4616
4667
|
if (el && el.getAttribute('data-nac-id')) {
|
|
4617
4668
|
matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
|
|
4618
4669
|
}
|
|
4619
4670
|
} else {
|
|
4620
4671
|
/* Default: first match in DOM order. */
|
|
4621
|
-
const el = root.querySelector('[data-nac-action="' + verb + '"]');
|
|
4672
|
+
const el = root.querySelector('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4622
4673
|
if (el && el.getAttribute('data-nac-id')) {
|
|
4623
4674
|
matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
|
|
4624
4675
|
}
|
|
@@ -4939,7 +4990,7 @@
|
|
|
4939
4990
|
that humans wouldn't say aloud). Same two-tier strict logic. */
|
|
4940
4991
|
if (!matched) {
|
|
4941
4992
|
const root = document.querySelector(
|
|
4942
|
-
'[data-nac-plugin="' + targetPlugin + '"]');
|
|
4993
|
+
'[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]');
|
|
4943
4994
|
if (root) {
|
|
4944
4995
|
const tabs = Array.prototype.slice.call(
|
|
4945
4996
|
root.querySelectorAll('[data-nac-role="tab"]'));
|
|
@@ -5028,7 +5079,7 @@
|
|
|
5028
5079
|
/* Best-effort: serialize the active plugin DOM to data URL.
|
|
5029
5080
|
For real screenshots, the runner uses Playwright's screenshot
|
|
5030
5081
|
primitive; this is a fallback for in-page operators. */
|
|
5031
|
-
const root = document.querySelector('[data-nac-plugin="' + _activePlugin() + '"]')
|
|
5082
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(_activePlugin()) + '"]')
|
|
5032
5083
|
|| document.body;
|
|
5033
5084
|
const xml = new XMLSerializer().serializeToString(root);
|
|
5034
5085
|
return 'data:image/svg+xml;base64,' +
|
|
@@ -5056,7 +5107,7 @@
|
|
|
5056
5107
|
function validate(plugin_slug) {
|
|
5057
5108
|
const m = _manifests[plugin_slug];
|
|
5058
5109
|
if (!m) return { ok: false, code: 'no_manifest' };
|
|
5059
|
-
const root = document.querySelector('[data-nac-plugin="' + plugin_slug + '"]');
|
|
5110
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]');
|
|
5060
5111
|
if (!root) return { ok: false, code: 'plugin_not_mounted' };
|
|
5061
5112
|
const found = {};
|
|
5062
5113
|
const elemByNacId = {};
|
|
@@ -5247,8 +5298,8 @@
|
|
|
5247
5298
|
m.rows.cells.forEach(function (col) {
|
|
5248
5299
|
if (!col || !col.nac_id) return;
|
|
5249
5300
|
const cell = sampleRow.querySelector(
|
|
5250
|
-
'[data-nac-id$="' + col.nac_id + '"], '
|
|
5251
|
-
+ '[data-nac-cell="' + col.nac_id + '"]');
|
|
5301
|
+
'[data-nac-id$="' + _nac_attrValue(col.nac_id) + '"], '
|
|
5302
|
+
+ '[data-nac-cell="' + _nac_attrValue(col.nac_id) + '"]');
|
|
5252
5303
|
if (!cell) {
|
|
5253
5304
|
pushErr('error', 'row_cell_missing', col.nac_id,
|
|
5254
5305
|
'manifest declares row cell "' + col.nac_id
|
|
@@ -5265,7 +5316,7 @@
|
|
|
5265
5316
|
b.items.forEach(function (item) {
|
|
5266
5317
|
if (!item || !item.nac_id) return;
|
|
5267
5318
|
const el = root.querySelector(
|
|
5268
|
-
'[data-nac-role="breadcrumb-item"][data-nac-id="' + item.nac_id + '"]');
|
|
5319
|
+
'[data-nac-role="breadcrumb-item"][data-nac-id="' + _nac_attrValue(item.nac_id) + '"]');
|
|
5269
5320
|
if (!el) {
|
|
5270
5321
|
pushErr('error', 'breadcrumb_item_missing', item.nac_id,
|
|
5271
5322
|
'breadcrumb item "' + item.nac_id
|
|
@@ -5334,7 +5385,7 @@
|
|
|
5334
5385
|
{
|
|
5335
5386
|
const sameSlug = Array.prototype.slice.call(
|
|
5336
5387
|
document.querySelectorAll(
|
|
5337
|
-
'[data-nac-plugin="' + plugin_slug + '"]'));
|
|
5388
|
+
'[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]'));
|
|
5338
5389
|
if (sameSlug.length > 1) {
|
|
5339
5390
|
const ids = sameSlug.map(function (r) {
|
|
5340
5391
|
return r.getAttribute('data-nac-plugin-id') || '';
|
|
@@ -5928,8 +5979,8 @@
|
|
|
5928
5979
|
/* ---------- v1.2: window chrome (min/max/restore) --------------- */
|
|
5929
5980
|
|
|
5930
5981
|
function _findPluginRoot(plugin) {
|
|
5931
|
-
return document.querySelector('[data-nac-plugin="' + plugin + '"]')
|
|
5932
|
-
|| document.querySelector('[data-nac-id="' + plugin + '"]');
|
|
5982
|
+
return document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]')
|
|
5983
|
+
|| document.querySelector('[data-nac-id="' + _nac_attrValue(plugin) + '"]');
|
|
5933
5984
|
}
|
|
5934
5985
|
|
|
5935
5986
|
function _setPluginState(plugin, newState) {
|
|
@@ -6107,7 +6158,7 @@
|
|
|
6107
6158
|
|
|
6108
6159
|
function _genericReset(plugin_slug) {
|
|
6109
6160
|
const root = plugin_slug
|
|
6110
|
-
? document.querySelector('[data-nac-plugin="' + plugin_slug + '"]')
|
|
6161
|
+
? document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]')
|
|
6111
6162
|
: document;
|
|
6112
6163
|
if (!root) return false;
|
|
6113
6164
|
/* Clear every NAC-instrumented field. Honours
|
|
@@ -6187,7 +6238,7 @@
|
|
|
6187
6238
|
|
|
6188
6239
|
function _findSection(sectionId) {
|
|
6189
6240
|
return document.querySelector(
|
|
6190
|
-
'[data-nac-role="section"][data-nac-id="' + sectionId + '"]');
|
|
6241
|
+
'[data-nac-role="section"][data-nac-id="' + _nac_attrValue(sectionId) + '"]');
|
|
6191
6242
|
}
|
|
6192
6243
|
|
|
6193
6244
|
function list_sections() {
|
|
@@ -6298,7 +6349,7 @@
|
|
|
6298
6349
|
}
|
|
6299
6350
|
if (detail.plugin && detail.plugin_instance_id === undefined) {
|
|
6300
6351
|
const root = document.querySelector(
|
|
6301
|
-
'[data-nac-plugin="' + detail.plugin + '"]');
|
|
6352
|
+
'[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]');
|
|
6302
6353
|
detail.plugin_instance_id = root
|
|
6303
6354
|
? (root.getAttribute('data-nac-plugin-id') || null)
|
|
6304
6355
|
: null;
|
|
@@ -6325,9 +6376,9 @@
|
|
|
6325
6376
|
payload filtering. */
|
|
6326
6377
|
if (detail.plugin) {
|
|
6327
6378
|
const root = document.querySelector(
|
|
6328
|
-
'[data-nac-plugin="' + detail.plugin + '"]'
|
|
6379
|
+
'[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]'
|
|
6329
6380
|
+ (detail.plugin_instance_id
|
|
6330
|
-
? '[data-nac-plugin-id="' + detail.plugin_instance_id + '"]'
|
|
6381
|
+
? '[data-nac-plugin-id="' + _nac_attrValue(detail.plugin_instance_id) + '"]'
|
|
6331
6382
|
: ''));
|
|
6332
6383
|
if (root && root.getAttribute('data-nac-plugin-bus') === 'enabled') {
|
|
6333
6384
|
root.dispatchEvent(new CustomEvent(name, {
|
|
@@ -6390,9 +6441,9 @@
|
|
|
6390
6441
|
exposure API. Falls back to document.querySelector when
|
|
6391
6442
|
the deep helper is unavailable (defensive). */
|
|
6392
6443
|
if (typeof _deepQuery === 'function') {
|
|
6393
|
-
return _deepQuery('[data-nac-id="' + id + '"]', document);
|
|
6444
|
+
return _deepQuery('[data-nac-id="' + _nac_attrValue(id) + '"]', document);
|
|
6394
6445
|
}
|
|
6395
|
-
return document.querySelector('[data-nac-id="' + id + '"]');
|
|
6446
|
+
return document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
|
|
6396
6447
|
}
|
|
6397
6448
|
|
|
6398
6449
|
/* ---------- v1.3: toast / banner / confirm --------------------- */
|
|
@@ -6513,8 +6564,8 @@
|
|
|
6513
6564
|
_emit(answer ? 'nac:confirm:confirmed' : 'nac:confirm:cancelled', { id: id });
|
|
6514
6565
|
resolve(!!answer);
|
|
6515
6566
|
}
|
|
6516
|
-
card.querySelector('[data-nac-id="' + id + '.confirm"]').addEventListener('click', function () { done(true); });
|
|
6517
|
-
card.querySelector('[data-nac-id="' + id + '.cancel"]').addEventListener('click', function () { done(false); });
|
|
6567
|
+
card.querySelector('[data-nac-id="' + _nac_attrValue(id) + '.confirm"]').addEventListener('click', function () { done(true); });
|
|
6568
|
+
card.querySelector('[data-nac-id="' + _nac_attrValue(id) + '.cancel"]').addEventListener('click', function () { done(false); });
|
|
6518
6569
|
});
|
|
6519
6570
|
}
|
|
6520
6571
|
function list_pending_confirms() {
|
|
@@ -6587,7 +6638,7 @@
|
|
|
6587
6638
|
|
|
6588
6639
|
function _stepperRoot(stepper_id) {
|
|
6589
6640
|
return document.querySelector(
|
|
6590
|
-
'[data-nac-role="stepper"][data-nac-id="' + stepper_id + '"]');
|
|
6641
|
+
'[data-nac-role="stepper"][data-nac-id="' + _nac_attrValue(stepper_id) + '"]');
|
|
6591
6642
|
}
|
|
6592
6643
|
function _stepperSteps(stepper_id) {
|
|
6593
6644
|
const root = _stepperRoot(stepper_id);
|
|
@@ -6643,7 +6694,7 @@
|
|
|
6643
6694
|
|
|
6644
6695
|
function _treeNode(node_id) {
|
|
6645
6696
|
return document.querySelector(
|
|
6646
|
-
'[data-nac-role="treenode"][data-nac-id="' + node_id + '"]');
|
|
6697
|
+
'[data-nac-role="treenode"][data-nac-id="' + _nac_attrValue(node_id) + '"]');
|
|
6647
6698
|
}
|
|
6648
6699
|
function tree_expand(node_id) {
|
|
6649
6700
|
const n = _treeNode(node_id);
|
|
@@ -6702,7 +6753,7 @@
|
|
|
6702
6753
|
|
|
6703
6754
|
function _tagFieldRoot(field_id) {
|
|
6704
6755
|
const el = document.querySelector(
|
|
6705
|
-
'[data-nac-role="field"][data-nac-field-type="tag-input"][data-nac-id="' + field_id + '"]');
|
|
6756
|
+
'[data-nac-role="field"][data-nac-field-type="tag-input"][data-nac-id="' + _nac_attrValue(field_id) + '"]');
|
|
6706
6757
|
return el;
|
|
6707
6758
|
}
|
|
6708
6759
|
function add_tag(field_id, value) {
|
|
@@ -6732,8 +6783,8 @@
|
|
|
6732
6783
|
|
|
6733
6784
|
function _drawer(id) {
|
|
6734
6785
|
return document.querySelector(
|
|
6735
|
-
'[data-nac-role="drawer"][data-nac-id="' + id + '"], ' +
|
|
6736
|
-
'[data-nac-role="bottom-sheet"][data-nac-id="' + id + '"]');
|
|
6786
|
+
'[data-nac-role="drawer"][data-nac-id="' + _nac_attrValue(id) + '"], ' +
|
|
6787
|
+
'[data-nac-role="bottom-sheet"][data-nac-id="' + _nac_attrValue(id) + '"]');
|
|
6737
6788
|
}
|
|
6738
6789
|
function open_drawer(id, position) {
|
|
6739
6790
|
const d = _drawer(id);
|
|
@@ -6760,14 +6811,14 @@
|
|
|
6760
6811
|
|
|
6761
6812
|
function calendar_view(cal_id, view) {
|
|
6762
6813
|
const c = document.querySelector(
|
|
6763
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6814
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6764
6815
|
if (!c) throw NacError('calendar_not_found', cal_id);
|
|
6765
6816
|
c.setAttribute('data-nac-view', view);
|
|
6766
6817
|
_emit('nac:calendar:view_changed', { calendar_id: cal_id, view: view });
|
|
6767
6818
|
}
|
|
6768
6819
|
function calendar_go_to(cal_id, date) {
|
|
6769
6820
|
const c = document.querySelector(
|
|
6770
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6821
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6771
6822
|
if (!c) throw NacError('calendar_not_found', cal_id);
|
|
6772
6823
|
c.setAttribute('data-nac-date', date);
|
|
6773
6824
|
_emit('nac:calendar:date_selected', { calendar_id: cal_id, date: date });
|
|
@@ -6784,7 +6835,7 @@
|
|
|
6784
6835
|
}
|
|
6785
6836
|
function calendar_list_events(cal_id /*, from, to */) {
|
|
6786
6837
|
const c = document.querySelector(
|
|
6787
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6838
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6788
6839
|
if (!c) return [];
|
|
6789
6840
|
const out = [];
|
|
6790
6841
|
c.querySelectorAll('[data-nac-role="calendar-event"]').forEach(function (e) {
|
|
@@ -6803,7 +6854,7 @@
|
|
|
6803
6854
|
|
|
6804
6855
|
function chart_data(chart_id) {
|
|
6805
6856
|
const c = document.querySelector(
|
|
6806
|
-
'[data-nac-role="chart"][data-nac-id="' + chart_id + '"]');
|
|
6857
|
+
'[data-nac-role="chart"][data-nac-id="' + _nac_attrValue(chart_id) + '"]');
|
|
6807
6858
|
if (!c) throw NacError('chart_not_found', chart_id);
|
|
6808
6859
|
const series = [];
|
|
6809
6860
|
c.querySelectorAll('[data-nac-role="chart-series"]').forEach(function (s) {
|
|
@@ -6827,7 +6878,7 @@
|
|
|
6827
6878
|
}
|
|
6828
6879
|
function chart_toggle_series(chart_id, series_id, on) {
|
|
6829
6880
|
const s = document.querySelector(
|
|
6830
|
-
'[data-nac-role="chart-series"][data-nac-id="' + series_id + '"]');
|
|
6881
|
+
'[data-nac-role="chart-series"][data-nac-id="' + _nac_attrValue(series_id) + '"]');
|
|
6831
6882
|
if (!s) throw NacError('chart_series_not_found', series_id);
|
|
6832
6883
|
const target = (typeof on === 'boolean') ? on : (s.getAttribute('data-nac-state') === 'hidden');
|
|
6833
6884
|
s.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
|
|
@@ -6841,7 +6892,7 @@
|
|
|
6841
6892
|
|
|
6842
6893
|
function map_focus(map_id, lat, lng, zoom) {
|
|
6843
6894
|
const m = document.querySelector(
|
|
6844
|
-
'[data-nac-role="map"][data-nac-id="' + map_id + '"]');
|
|
6895
|
+
'[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
|
|
6845
6896
|
if (!m) throw NacError('map_not_found', map_id);
|
|
6846
6897
|
m.setAttribute('data-nac-lat', String(lat));
|
|
6847
6898
|
m.setAttribute('data-nac-lng', String(lng));
|
|
@@ -6853,7 +6904,7 @@
|
|
|
6853
6904
|
}
|
|
6854
6905
|
function map_select_marker(marker_id) {
|
|
6855
6906
|
const mk = document.querySelector(
|
|
6856
|
-
'[data-nac-role="map-marker"][data-nac-id="' + marker_id + '"]');
|
|
6907
|
+
'[data-nac-role="map-marker"][data-nac-id="' + _nac_attrValue(marker_id) + '"]');
|
|
6857
6908
|
if (!mk) throw NacError('map_marker_not_found', marker_id);
|
|
6858
6909
|
mk.setAttribute('data-nac-state', 'selected');
|
|
6859
6910
|
const map_id = (mk.closest('[data-nac-role="map"]') || {}).getAttribute
|
|
@@ -6869,7 +6920,7 @@
|
|
|
6869
6920
|
}
|
|
6870
6921
|
function map_toggle_layer(map_id, layer_id, on) {
|
|
6871
6922
|
const ly = document.querySelector(
|
|
6872
|
-
'[data-nac-role="map-layer"][data-nac-id="' + layer_id + '"]');
|
|
6923
|
+
'[data-nac-role="map-layer"][data-nac-id="' + _nac_attrValue(layer_id) + '"]');
|
|
6873
6924
|
if (!ly) throw NacError('map_layer_not_found', layer_id);
|
|
6874
6925
|
const target = (typeof on === 'boolean') ? on : (ly.getAttribute('data-nac-state') === 'hidden');
|
|
6875
6926
|
ly.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
|
|
@@ -6877,7 +6928,7 @@
|
|
|
6877
6928
|
}
|
|
6878
6929
|
function list_markers(map_id) {
|
|
6879
6930
|
const m = document.querySelector(
|
|
6880
|
-
'[data-nac-role="map"][data-nac-id="' + map_id + '"]');
|
|
6931
|
+
'[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
|
|
6881
6932
|
if (!m) return [];
|
|
6882
6933
|
const out = [];
|
|
6883
6934
|
m.querySelectorAll('[data-nac-role="map-marker"]').forEach(function (mk) {
|
|
@@ -6911,7 +6962,7 @@
|
|
|
6911
6962
|
|
|
6912
6963
|
function _breadcrumbContainer(crumb_id) {
|
|
6913
6964
|
return document.querySelector(
|
|
6914
|
-
'[data-nac-role="breadcrumb"][data-nac-id="' + crumb_id + '"]');
|
|
6965
|
+
'[data-nac-role="breadcrumb"][data-nac-id="' + _nac_attrValue(crumb_id) + '"]');
|
|
6915
6966
|
}
|
|
6916
6967
|
function _breadcrumbItems(rootEl) {
|
|
6917
6968
|
if (!rootEl) return [];
|
|
@@ -6946,7 +6997,7 @@
|
|
|
6946
6997
|
+ item_id + '"]');
|
|
6947
6998
|
if (!el) {
|
|
6948
6999
|
// fallback: any anchor whose label matches
|
|
6949
|
-
el = document.querySelector('a[data-nac-id="' + item_id + '"]');
|
|
7000
|
+
el = document.querySelector('a[data-nac-id="' + _nac_attrValue(item_id) + '"]');
|
|
6950
7001
|
}
|
|
6951
7002
|
if (!el) {
|
|
6952
7003
|
return Promise.reject(new NacError('not_found',
|
|
@@ -6972,7 +7023,7 @@
|
|
|
6972
7023
|
|
|
6973
7024
|
function _carousel(carousel_id) {
|
|
6974
7025
|
return document.querySelector(
|
|
6975
|
-
'[data-nac-role="carousel"][data-nac-id="' + carousel_id + '"]');
|
|
7026
|
+
'[data-nac-role="carousel"][data-nac-id="' + _nac_attrValue(carousel_id) + '"]');
|
|
6976
7027
|
}
|
|
6977
7028
|
function _carouselSlides(rootEl) {
|
|
6978
7029
|
if (!rootEl) return [];
|
|
@@ -7073,7 +7124,7 @@
|
|
|
7073
7124
|
|
|
7074
7125
|
function _timeline(timeline_id) {
|
|
7075
7126
|
return document.querySelector(
|
|
7076
|
-
'[data-nac-role="timeline"][data-nac-id="' + timeline_id + '"]');
|
|
7127
|
+
'[data-nac-role="timeline"][data-nac-id="' + _nac_attrValue(timeline_id) + '"]');
|
|
7077
7128
|
}
|
|
7078
7129
|
function _timelineItems(rootEl) {
|
|
7079
7130
|
if (!rootEl) return [];
|
|
@@ -7151,7 +7202,7 @@
|
|
|
7151
7202
|
'list not found: ' + list_id));
|
|
7152
7203
|
}
|
|
7153
7204
|
var item = list.querySelector(
|
|
7154
|
-
'[data-nac-role="draggable"][data-nac-id="' + item_id + '"]')
|
|
7205
|
+
'[data-nac-role="draggable"][data-nac-id="' + _nac_attrValue(item_id) + '"]')
|
|
7155
7206
|
|| _byId(item_id);
|
|
7156
7207
|
if (!item) {
|
|
7157
7208
|
return Promise.reject(new NacError('not_found',
|
|
@@ -8687,6 +8738,53 @@
|
|
|
8687
8738
|
}
|
|
8688
8739
|
}
|
|
8689
8740
|
|
|
8741
|
+
/* 2.9.1 (PND-168) -- WHO IS ALLOWED TO READ AN OUTGOING MESSAGE.
|
|
8742
|
+
|
|
8743
|
+
Both postMessage backends sent `binding.target_origin || '*'`, so a
|
|
8744
|
+
manifest that did not declare an origin broadcast the action's
|
|
8745
|
+
arguments to whatever origin happened to occupy that iframe. The
|
|
8746
|
+
INCOMING half was already right (both listeners filter on
|
|
8747
|
+
ev.source === iframe.contentWindow), which is what made the
|
|
8748
|
+
outgoing default stand out rather than look like the house style.
|
|
8749
|
+
|
|
8750
|
+
The default is now the origin of the iframe the adopter pointed at,
|
|
8751
|
+
read from its src. '*' survives exactly where it is the only thing
|
|
8752
|
+
that can work -- srcdoc, about:blank, a blob or no src at all,
|
|
8753
|
+
which all resolve to an opaque origin -- and it survives where the
|
|
8754
|
+
adopter asks for it by declaring target_origin: '*'.
|
|
8755
|
+
|
|
8756
|
+
The derivation is announced once per message id. An adopter whose
|
|
8757
|
+
iframe has navigated cross-origin since it was mounted would
|
|
8758
|
+
otherwise see the message silently dropped by the browser, and a
|
|
8759
|
+
silent drop is the one outcome this project does not accept: the
|
|
8760
|
+
line names the origin it chose and how to pin it. */
|
|
8761
|
+
const _v25_origin_notices = Object.create(null);
|
|
8762
|
+
function _v25_targetOrigin(binding, iframe, backend) {
|
|
8763
|
+
if (binding && binding.target_origin) return binding.target_origin;
|
|
8764
|
+
let origin = null;
|
|
8765
|
+
try {
|
|
8766
|
+
const raw = iframe && typeof iframe.getAttribute === 'function'
|
|
8767
|
+
? iframe.getAttribute('src') : null;
|
|
8768
|
+
if (raw && typeof URL === 'function') {
|
|
8769
|
+
const base = typeof location !== 'undefined' ? location.href : undefined;
|
|
8770
|
+
const resolved = new URL(String(raw), base).origin;
|
|
8771
|
+
if (resolved && resolved !== 'null') origin = resolved;
|
|
8772
|
+
}
|
|
8773
|
+
} catch (e) { origin = null; }
|
|
8774
|
+
if (!origin) return '*';
|
|
8775
|
+
const key = backend + ':' + (binding && binding.message) + ':' + origin;
|
|
8776
|
+
if (!_v25_origin_notices[key]) {
|
|
8777
|
+
_v25_origin_notices[key] = true;
|
|
8778
|
+
if (typeof console !== 'undefined' && console.warn) {
|
|
8779
|
+
console.warn('[nac] ' + backend + ': no target_origin declared for message "'
|
|
8780
|
+
+ (binding && binding.message) + '", so it is posted to ' + origin
|
|
8781
|
+
+ ', the origin of the target iframe. Declare target_origin in the manifest '
|
|
8782
|
+
+ "to pin it (target_origin: '*' restores the pre-2.9.1 broadcast).");
|
|
8783
|
+
}
|
|
8784
|
+
}
|
|
8785
|
+
return origin;
|
|
8786
|
+
}
|
|
8787
|
+
|
|
8690
8788
|
/* postmessage (verb): post a structured message to the iframe.contentWindow
|
|
8691
8789
|
of the target. `values` literal + `values_from_args` forward keys. */
|
|
8692
8790
|
function _v25_backend_postmessage(binding, args) {
|
|
@@ -8715,7 +8813,7 @@
|
|
|
8715
8813
|
}
|
|
8716
8814
|
}
|
|
8717
8815
|
try {
|
|
8718
|
-
iframe.contentWindow.postMessage(msg, binding
|
|
8816
|
+
iframe.contentWindow.postMessage(msg, _v25_targetOrigin(binding, iframe, 'postmessage'));
|
|
8719
8817
|
return Promise.resolve({ ok: true });
|
|
8720
8818
|
} catch (e) {
|
|
8721
8819
|
return Promise.reject(e);
|
|
@@ -8821,7 +8919,7 @@
|
|
|
8821
8919
|
MessageId: binding.message,
|
|
8822
8920
|
SendTime: Date.now(),
|
|
8823
8921
|
Values: wantValues,
|
|
8824
|
-
}, binding
|
|
8922
|
+
}, _v25_targetOrigin(binding, iframe, 'script-bridge'));
|
|
8825
8923
|
});
|
|
8826
8924
|
}
|
|
8827
8925
|
|
|
@@ -9988,7 +10086,7 @@
|
|
|
9988
10086
|
subtree. If plugin is omitted, fall back to global search. */
|
|
9989
10087
|
let root = document;
|
|
9990
10088
|
if (plugin) {
|
|
9991
|
-
const pluginRoot = document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
10089
|
+
const pluginRoot = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
9992
10090
|
if (!pluginRoot) return null;
|
|
9993
10091
|
root = pluginRoot;
|
|
9994
10092
|
}
|
|
@@ -10050,7 +10148,7 @@
|
|
|
10050
10148
|
|
|
10051
10149
|
function _v25b_pluginRoot(plugin) {
|
|
10052
10150
|
if (!plugin) return null;
|
|
10053
|
-
return document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
10151
|
+
return document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
10054
10152
|
}
|
|
10055
10153
|
|
|
10056
10154
|
function context(plugin) {
|
|
@@ -10242,7 +10340,7 @@
|
|
|
10242
10340
|
|
|
10243
10341
|
global.NAC = {
|
|
10244
10342
|
__nac_v1_installed: true,
|
|
10245
|
-
version: '2.9.
|
|
10343
|
+
version: '2.9.1',
|
|
10246
10344
|
spec_version: '2.9',
|
|
10247
10345
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
10248
10346
|
NAC.register throws on findings (manifest_role_unknown,
|
|
@@ -10615,6 +10713,115 @@
|
|
|
10615
10713
|
diff: diff,
|
|
10616
10714
|
};
|
|
10617
10715
|
|
|
10716
|
+
/* ================================================================
|
|
10717
|
+
2.9.1 -- SPEC 19.3 for the whole family (PND-162, PND-163)
|
|
10718
|
+
================================================================
|
|
10719
|
+
|
|
10720
|
+
19.3 names eight primitives and then says "and any other that
|
|
10721
|
+
resolves a name by querying the document". Since 2.7.0 the eight
|
|
10722
|
+
called _nac_requireDocument inline and the OTHERS did not: measured
|
|
10723
|
+
on 2026-11-28 by calling all 151 exports in a sandbox with no
|
|
10724
|
+
document, 69 of them still died with a raw
|
|
10725
|
+
"ReferenceError: document is not defined" -- the same defect D-26
|
|
10726
|
+
closed one layer up, and the suite that guarded it only ever tested
|
|
10727
|
+
the eight, so it asserted more than it measured.
|
|
10728
|
+
|
|
10729
|
+
Worst of them was wait_for: it scheduled a setTimeout BEFORE
|
|
10730
|
+
touching the document, so the ReferenceError came out of the timer
|
|
10731
|
+
-- outside every try/catch the caller could write -- and killed the
|
|
10732
|
+
Node process. A promise .catch() could not reach it.
|
|
10733
|
+
|
|
10734
|
+
WHY HERE, at install, and not inline in 69 bodies. Fail closed
|
|
10735
|
+
before the primitive does any work (which is what kills the timer
|
|
10736
|
+
path), one place to read, and the list is a DECLARATION a gate can
|
|
10737
|
+
enforce. Inline guards would be 69 edits to a published runtime for
|
|
10738
|
+
the same effect, and the next primitive would forget the line.
|
|
10739
|
+
|
|
10740
|
+
WHY TWO LISTS. The channel the refusal arrives through is part of
|
|
10741
|
+
the published surface: an adopter who wrote
|
|
10742
|
+
NAC.confirm(...).catch(h) must keep getting a rejection, not a
|
|
10743
|
+
synchronous throw. So each name carries the channel its failure
|
|
10744
|
+
ALREADY used, measured rather than guessed -- the async ones return
|
|
10745
|
+
a promise (three of them are not declared async: they return
|
|
10746
|
+
new Promise, and the executor's throw rejected). The suite checks
|
|
10747
|
+
this against an independent oracle: it calls the same primitive
|
|
10748
|
+
WITH a document and asks whether the return value is a thenable.
|
|
10749
|
+
|
|
10750
|
+
NOT in these lists, on purpose: the eight that guard inline (their
|
|
10751
|
+
call sites read better where they are), and everything that works
|
|
10752
|
+
with no document at all -- the extension contract (call / read /
|
|
10753
|
+
subscribe), the manifest surface, profile(), the provenance sink.
|
|
10754
|
+
Those are the headless profile, and guarding them would break
|
|
10755
|
+
section 19 instead of serving it. */
|
|
10756
|
+
const _NAC_DOM_PRIMITIVES_SYNC = [
|
|
10757
|
+
'add_tag', 'calendar_go_to', 'calendar_list_events',
|
|
10758
|
+
'calendar_select_event', 'calendar_view', 'carousel_state',
|
|
10759
|
+
'chart_data', 'chart_filter', 'chart_toggle_series',
|
|
10760
|
+
'close_drawer', 'dismiss_banner', 'dismiss_toast', 'edit_field',
|
|
10761
|
+
'emit_dual', 'invalidate_options', 'is_blocked', 'list_banners',
|
|
10762
|
+
'list_breadcrumbs', 'list_carousels', 'list_markers',
|
|
10763
|
+
'list_pending_confirms', 'list_sections', 'list_tags',
|
|
10764
|
+
'list_timelines', 'list_toasts', 'map_focus', 'map_select_marker',
|
|
10765
|
+
'map_toggle_layer', 'open_drawer', 'peek_drawer', 'remove_tag',
|
|
10766
|
+
'richtext_format', 'richtext_insert_link',
|
|
10767
|
+
'richtext_insert_mention', 'set_a11y_hint_localizer', 'step_back',
|
|
10768
|
+
'step_next', 'step_state', 'step_to', 'timeline_state', 'toast',
|
|
10769
|
+
'tree_collapse', 'tree_expand', 'tree_path', 'tree_select',
|
|
10770
|
+
];
|
|
10771
|
+
const _NAC_DOM_PRIMITIVES_ASYNC = [
|
|
10772
|
+
'assert_event_count', 'assert_event_fired', 'carousel_advance',
|
|
10773
|
+
'carousel_autoplay', 'carousel_to', 'click_by_verb', 'confirm',
|
|
10774
|
+
'drag_drop', 'fullscreen', 'go_to_section', 'maximize', 'minimize',
|
|
10775
|
+
'navigate_breadcrumb', 'perf_probe', 'reorder', 'reset', 'restore',
|
|
10776
|
+
'screenshot', 'tab', 'tab_by_label', 'timeline_load_newer',
|
|
10777
|
+
'timeline_load_older', 'validate_event_conformance', 'wait_for',
|
|
10778
|
+
];
|
|
10779
|
+
function _nac_guardDomPrimitive(api, name, isAsync) {
|
|
10780
|
+
const fn = api[name];
|
|
10781
|
+
/* No silent no-op: a name in the table that is not exported means
|
|
10782
|
+
the table and the surface drifted, and the gate says so. */
|
|
10783
|
+
if (typeof fn !== 'function') return false;
|
|
10784
|
+
function guarded() {
|
|
10785
|
+
if (typeof document === 'undefined' || !document) {
|
|
10786
|
+
const err = _nac_noDocumentError(name);
|
|
10787
|
+
if (isAsync) return Promise.reject(err);
|
|
10788
|
+
throw err;
|
|
10789
|
+
}
|
|
10790
|
+
return fn.apply(this, arguments);
|
|
10791
|
+
}
|
|
10792
|
+
/* The published shape of a function is its name and its arity;
|
|
10793
|
+
both are read by adopters and by this tree's own gates. */
|
|
10794
|
+
try { Object.defineProperty(guarded, 'name', { value: name, configurable: true }); } catch (e) { /* older engines */ }
|
|
10795
|
+
try { Object.defineProperty(guarded, 'length', { value: fn.length, configurable: true }); } catch (e) { /* idem */ }
|
|
10796
|
+
guarded.__nac_requires_document = true;
|
|
10797
|
+
api[name] = guarded;
|
|
10798
|
+
return true;
|
|
10799
|
+
}
|
|
10800
|
+
(function _nac_installDocumentGuards(api) {
|
|
10801
|
+
const missing = [];
|
|
10802
|
+
for (let i = 0; i < _NAC_DOM_PRIMITIVES_SYNC.length; i++) {
|
|
10803
|
+
if (!_nac_guardDomPrimitive(api, _NAC_DOM_PRIMITIVES_SYNC[i], false)) {
|
|
10804
|
+
missing.push(_NAC_DOM_PRIMITIVES_SYNC[i]);
|
|
10805
|
+
}
|
|
10806
|
+
}
|
|
10807
|
+
for (let i = 0; i < _NAC_DOM_PRIMITIVES_ASYNC.length; i++) {
|
|
10808
|
+
if (!_nac_guardDomPrimitive(api, _NAC_DOM_PRIMITIVES_ASYNC[i], true)) {
|
|
10809
|
+
missing.push(_NAC_DOM_PRIMITIVES_ASYNC[i]);
|
|
10810
|
+
}
|
|
10811
|
+
}
|
|
10812
|
+
/* Readable from outside so a gate can enforce the declaration
|
|
10813
|
+
instead of re-deriving it, and so an adopter can ask whether a
|
|
10814
|
+
primitive needs a document before calling it. */
|
|
10815
|
+
api.documentPrimitives = function () {
|
|
10816
|
+
return {
|
|
10817
|
+
sync: _NAC_DOM_PRIMITIVES_SYNC.slice(),
|
|
10818
|
+
async: _NAC_DOM_PRIMITIVES_ASYNC.slice(),
|
|
10819
|
+
missing: missing.slice(),
|
|
10820
|
+
};
|
|
10821
|
+
};
|
|
10822
|
+
})(global.NAC);
|
|
10823
|
+
|
|
10824
|
+
|
|
10618
10825
|
/* v2.2.1: guard browser-only init so this module is importable in
|
|
10619
10826
|
Node / SSR / test contexts without crashing. */
|
|
10620
10827
|
if (typeof document !== 'undefined') {
|