@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/CHANGELOG.md +198 -0
- package/README.md +10 -0
- package/SPEC.md +45 -4
- package/contract-head.json +4 -4
- package/dist/cli-levels.json +2 -2
- package/dist/cli-lint.mjs +255 -6
- package/dist/cli.js +6 -3
- 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 +636 -0
- package/dist/nac-mcp-interop.cjs +641 -0
- package/dist/nac-mcp-interop.d.ts +57 -0
- package/dist/nac-mcp-interop.mjs +641 -0
- package/dist/nac-v2-extensions.d.ts +1 -1
- package/dist/nac.browser.js +304 -69
- package/dist/nac.cjs +304 -69
- package/dist/nac.d.ts +1 -1
- package/dist/nac.mjs +304 -69
- package/package.json +28 -10
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
|
+
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)
|
|
@@ -1790,7 +1830,33 @@
|
|
|
1790
1830
|
/* Structure. Every one of these is consumed by something: three
|
|
1791
1831
|
are queried by this runtime, `list` hosts reorder(), and
|
|
1792
1832
|
`canvas` is the door section 15.12 assigned to that surface. */
|
|
1793
|
-
'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas'
|
|
1833
|
+
'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas',
|
|
1834
|
+
|
|
1835
|
+
/* ---- v2.9.0: the document vocabulary (SPEC.md 1.2) ----------
|
|
1836
|
+
THE DEFECT THIS CLOSES, and it was this project's own site.
|
|
1837
|
+
Measured 2026-11-27 with the PUBLISHED validator over the
|
|
1838
|
+
whole tree: 45 677 elements across 526 pages carried a role
|
|
1839
|
+
the specification did not declare, and they were not written
|
|
1840
|
+
by hand -- a single producer emits them,
|
|
1841
|
+
scripts/build-spec-html.mjs, which renders the normative text
|
|
1842
|
+
itself as a NAC3 page. So the document that declares the
|
|
1843
|
+
vocabulary was being served marked up in words it did not
|
|
1844
|
+
declare, 354 times per page.
|
|
1845
|
+
|
|
1846
|
+
Why declaring them is the right half of the fix rather than
|
|
1847
|
+
un-painting them: these are document structure, and under
|
|
1848
|
+
section 19 reading a document is a capability, not a side
|
|
1849
|
+
effect of having a screen. An agent with no screen navigates
|
|
1850
|
+
prose by heading; code says the text inside must be read
|
|
1851
|
+
verbatim rather than paraphrased. list and paragraph were
|
|
1852
|
+
already declared, so list-item and heading missing was half a
|
|
1853
|
+
family, which is why the count was in the tens of thousands.
|
|
1854
|
+
|
|
1855
|
+
All five are read-only: they go in _CLICK_NO_EVENT_ROLES
|
|
1856
|
+
below, never in the click family map, because putting a
|
|
1857
|
+
read-only role in that map would make click() promise a
|
|
1858
|
+
completion nobody emits. */
|
|
1859
|
+
'heading', 'list-item', 'code', 'code-inline', 'note'
|
|
1794
1860
|
]);
|
|
1795
1861
|
|
|
1796
1862
|
/* ---- Declared aliases (SPEC.md 1.5) ---------------------------
|
|
@@ -1911,7 +1977,7 @@
|
|
|
1911
1977
|
data-nac-role MUST match. Skip when DOM is not yet ready
|
|
1912
1978
|
(a deferred check runs on DOMContentLoaded). */
|
|
1913
1979
|
if (typeof document !== 'undefined' && document.body) {
|
|
1914
|
-
const domEl = document.querySelector('[data-nac-id="' + id + '"]');
|
|
1980
|
+
const domEl = document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
|
|
1915
1981
|
if (domEl) {
|
|
1916
1982
|
const domRole = domEl.getAttribute('data-nac-role');
|
|
1917
1983
|
if (domRole && role && domRole !== role) {
|
|
@@ -2272,7 +2338,7 @@
|
|
|
2272
2338
|
|
|
2273
2339
|
function edit_field(field_nac_id) {
|
|
2274
2340
|
if (!field_nac_id) throw NacError('invalid', 'edit_field requires a nac_id');
|
|
2275
|
-
const sourceEl = document.querySelector('[data-nac-id="' + field_nac_id + '"]');
|
|
2341
|
+
const sourceEl = document.querySelector('[data-nac-id="' + _nac_attrValue(field_nac_id) + '"]');
|
|
2276
2342
|
if (!sourceEl) throw NacError('not_found', 'edit_field: ' + field_nac_id + ' not in DOM');
|
|
2277
2343
|
if (sourceEl.tagName !== 'INPUT' && sourceEl.tagName !== 'TEXTAREA' && !sourceEl.isContentEditable) {
|
|
2278
2344
|
throw NacError('invalid', 'edit_field: ' + field_nac_id + ' is not an editable widget');
|
|
@@ -2296,7 +2362,18 @@
|
|
|
2296
2362
|
|
|
2297
2363
|
const head = document.createElement('div');
|
|
2298
2364
|
head.className = 'nac-editor-head';
|
|
2299
|
-
|
|
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);
|
|
2300
2377
|
modal.appendChild(head);
|
|
2301
2378
|
|
|
2302
2379
|
const toolbar = document.createElement('div');
|
|
@@ -2701,7 +2778,7 @@
|
|
|
2701
2778
|
/* Wait for the plugin root to mount, then apply.
|
|
2702
2779
|
Some plugins register before their DOM is mounted. */
|
|
2703
2780
|
function apply() {
|
|
2704
|
-
const root = document.querySelector('[data-nac-plugin="' + slug + '"]');
|
|
2781
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(slug) + '"]');
|
|
2705
2782
|
if (!root) {
|
|
2706
2783
|
/* Try once after DOMContentLoaded if root is not yet in DOM. */
|
|
2707
2784
|
if (document.readyState === 'loading') {
|
|
@@ -3215,8 +3292,8 @@
|
|
|
3215
3292
|
action: el.getAttribute('data-nac-action') || null,
|
|
3216
3293
|
error: el.getAttribute('data-nac-error') || null,
|
|
3217
3294
|
label: el.getAttribute('aria-label')
|
|
3218
|
-
|| (el.id && document.querySelector('label[for="' + el.id + '"]')
|
|
3219
|
-
? 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()
|
|
3220
3297
|
: null)
|
|
3221
3298
|
/* Fallback for KPI/feedback/static elements: look for an
|
|
3222
3299
|
inner labeled child by convention. Resolves the case
|
|
@@ -3494,7 +3571,7 @@
|
|
|
3494
3571
|
}
|
|
3495
3572
|
}
|
|
3496
3573
|
return {
|
|
3497
|
-
spec_version: '2.
|
|
3574
|
+
spec_version: '2.9',
|
|
3498
3575
|
canonical: Array.from(_KNOWN_ROLES_V22),
|
|
3499
3576
|
aliases: Object.assign({}, _ROLE_ALIASES),
|
|
3500
3577
|
registered: registered,
|
|
@@ -3794,6 +3871,8 @@
|
|
|
3794
3871
|
'breadcrumb', 'pagination-control',
|
|
3795
3872
|
'avatar', 'presence-indicator', 'skeleton', 'empty-state',
|
|
3796
3873
|
'list', 'row', 'menu', 'label', 'value', 'paragraph', 'canvas',
|
|
3874
|
+
/* v2.9.0: the five document roles. Read-only, every one. */
|
|
3875
|
+
'heading', 'list-item', 'code', 'code-inline', 'note',
|
|
3797
3876
|
]);
|
|
3798
3877
|
|
|
3799
3878
|
/* v1.6.4: field types whose click() act on a value (toggle).
|
|
@@ -4123,13 +4202,13 @@
|
|
|
4123
4202
|
/* Field-change events fire on the parent field when an option
|
|
4124
4203
|
is clicked; resolve those too. */
|
|
4125
4204
|
if (e.type === 'nac:field:changed' && d && d.nac_id) {
|
|
4126
|
-
var parentField = el.closest('[data-nac-id="' + d.nac_id + '"]');
|
|
4205
|
+
var parentField = el.closest('[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
|
|
4127
4206
|
if (parentField) return true;
|
|
4128
4207
|
/* Or: the element is a descendant of an element whose nac_id
|
|
4129
4208
|
matches the field that fired. */
|
|
4130
4209
|
var fieldHost = document.querySelector(
|
|
4131
|
-
'[data-nac-role="field"][data-nac-id="' + d.nac_id + '"], ' +
|
|
4132
|
-
'[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) + '"]');
|
|
4133
4212
|
if (fieldHost && fieldHost.contains(el)) return true;
|
|
4134
4213
|
/* v1.6.4-v1.6.5: combobox option click. The host's option
|
|
4135
4214
|
click handler emits nac:field:changed on the parent field
|
|
@@ -4153,7 +4232,7 @@
|
|
|
4153
4232
|
? optPluginNode.getAttribute('data-nac-plugin') : null;
|
|
4154
4233
|
}
|
|
4155
4234
|
var fieldElForPlugin = document.querySelector(
|
|
4156
|
-
'[data-nac-id="' + d.nac_id + '"]');
|
|
4235
|
+
'[data-nac-id="' + _nac_attrValue(d.nac_id) + '"]');
|
|
4157
4236
|
var fieldPluginNode = fieldElForPlugin
|
|
4158
4237
|
? fieldElForPlugin.closest('[data-nac-plugin]') : null;
|
|
4159
4238
|
var fieldPluginSlug = fieldPluginNode
|
|
@@ -4328,8 +4407,8 @@
|
|
|
4328
4407
|
}
|
|
4329
4408
|
/* Non-native select widget: try clicking the option element. */
|
|
4330
4409
|
const root = el.closest('[data-nac-plugin]') || document;
|
|
4331
|
-
const opt = root.querySelector('[data-nac-id="' + nac_id + '.' + option + '"]')
|
|
4332
|
-
|| 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) + '"]');
|
|
4333
4412
|
if (opt) { _focusElement(opt); opt.click(); return { ok: true }; }
|
|
4334
4413
|
throw NacError('not_found', 'option ' + option + ' not present in ' + nac_id);
|
|
4335
4414
|
}
|
|
@@ -4358,7 +4437,7 @@
|
|
|
4358
4437
|
if (tab_key === undefined && typeof plugin === 'string' && plugin.indexOf('.') >= 0) {
|
|
4359
4438
|
const bareId = plugin;
|
|
4360
4439
|
let tabEl = document.querySelector(
|
|
4361
|
-
'[data-nac-role="tab"][data-nac-id="' + bareId + '"]'
|
|
4440
|
+
'[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(bareId) + '"]'
|
|
4362
4441
|
);
|
|
4363
4442
|
/* H1.v7 (2026-05-21): strict resolution. If the bare id is not
|
|
4364
4443
|
in DOM, try the qualified-instance fallback ONLY when the
|
|
@@ -4435,10 +4514,10 @@
|
|
|
4435
4514
|
try { await wait_for('nac:tab:changed', 1500); } catch (e) { /* tolerated */ }
|
|
4436
4515
|
return { ok: true };
|
|
4437
4516
|
}
|
|
4438
|
-
const root = document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
4517
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
4439
4518
|
if (!root) throw NacError('not_found', 'plugin ' + plugin + ' not mounted');
|
|
4440
4519
|
const tabEl = root.querySelector(
|
|
4441
|
-
'[data-nac-role="tab"][data-nac-id="' + tab_key + '"]'
|
|
4520
|
+
'[data-nac-role="tab"][data-nac-id="' + _nac_attrValue(tab_key) + '"]'
|
|
4442
4521
|
);
|
|
4443
4522
|
if (!tabEl) throw NacError('not_found', 'tab ' + tab_key + ' missing');
|
|
4444
4523
|
/* v2.5 V24-04 OCC gate (two-arg path). */
|
|
@@ -4508,14 +4587,14 @@
|
|
|
4508
4587
|
Fall through to the DOM scan so we pick whichever qualified
|
|
4509
4588
|
instance is actually mounted. */
|
|
4510
4589
|
if (matched && matched.nac_id) {
|
|
4511
|
-
const probe = document.querySelector('[data-nac-id="' + matched.nac_id + '"]');
|
|
4590
|
+
const probe = document.querySelector('[data-nac-id="' + _nac_attrValue(matched.nac_id) + '"]');
|
|
4512
4591
|
if (!probe) matched = null;
|
|
4513
4592
|
}
|
|
4514
4593
|
|
|
4515
4594
|
if (!matched) {
|
|
4516
4595
|
/* Fallback: scan DOM within plugin scope for [data-nac-action]. */
|
|
4517
4596
|
const root = targetPlugin
|
|
4518
|
-
? document.querySelector('[data-nac-plugin="' + targetPlugin + '"]')
|
|
4597
|
+
? document.querySelector('[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]')
|
|
4519
4598
|
: document;
|
|
4520
4599
|
if (root) {
|
|
4521
4600
|
if (qualifier) {
|
|
@@ -4530,7 +4609,7 @@
|
|
|
4530
4609
|
SUFFIX after the "__" separator counts. Zero matches
|
|
4531
4610
|
throws no_matching_instance; multiple matches throw
|
|
4532
4611
|
ambiguous_qualifier. No silent resolution. */
|
|
4533
|
-
const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
|
|
4612
|
+
const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4534
4613
|
const exact = [];
|
|
4535
4614
|
for (let i = 0; i < cands.length; i++) {
|
|
4536
4615
|
const id = cands[i].getAttribute('data-nac-id') || '';
|
|
@@ -4583,14 +4662,14 @@
|
|
|
4583
4662
|
}
|
|
4584
4663
|
matched = { nac_id: exact[0].getAttribute('data-nac-id'), verb: verb };
|
|
4585
4664
|
} else if (qualifierOrdinal !== null) {
|
|
4586
|
-
const cands = root.querySelectorAll('[data-nac-action="' + verb + '"]');
|
|
4665
|
+
const cands = root.querySelectorAll('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4587
4666
|
const el = cands[qualifierOrdinal];
|
|
4588
4667
|
if (el && el.getAttribute('data-nac-id')) {
|
|
4589
4668
|
matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
|
|
4590
4669
|
}
|
|
4591
4670
|
} else {
|
|
4592
4671
|
/* Default: first match in DOM order. */
|
|
4593
|
-
const el = root.querySelector('[data-nac-action="' + verb + '"]');
|
|
4672
|
+
const el = root.querySelector('[data-nac-action="' + _nac_attrValue(verb) + '"]');
|
|
4594
4673
|
if (el && el.getAttribute('data-nac-id')) {
|
|
4595
4674
|
matched = { nac_id: el.getAttribute('data-nac-id'), verb: verb };
|
|
4596
4675
|
}
|
|
@@ -4911,7 +4990,7 @@
|
|
|
4911
4990
|
that humans wouldn't say aloud). Same two-tier strict logic. */
|
|
4912
4991
|
if (!matched) {
|
|
4913
4992
|
const root = document.querySelector(
|
|
4914
|
-
'[data-nac-plugin="' + targetPlugin + '"]');
|
|
4993
|
+
'[data-nac-plugin="' + _nac_attrValue(targetPlugin) + '"]');
|
|
4915
4994
|
if (root) {
|
|
4916
4995
|
const tabs = Array.prototype.slice.call(
|
|
4917
4996
|
root.querySelectorAll('[data-nac-role="tab"]'));
|
|
@@ -5000,7 +5079,7 @@
|
|
|
5000
5079
|
/* Best-effort: serialize the active plugin DOM to data URL.
|
|
5001
5080
|
For real screenshots, the runner uses Playwright's screenshot
|
|
5002
5081
|
primitive; this is a fallback for in-page operators. */
|
|
5003
|
-
const root = document.querySelector('[data-nac-plugin="' + _activePlugin() + '"]')
|
|
5082
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(_activePlugin()) + '"]')
|
|
5004
5083
|
|| document.body;
|
|
5005
5084
|
const xml = new XMLSerializer().serializeToString(root);
|
|
5006
5085
|
return 'data:image/svg+xml;base64,' +
|
|
@@ -5028,7 +5107,7 @@
|
|
|
5028
5107
|
function validate(plugin_slug) {
|
|
5029
5108
|
const m = _manifests[plugin_slug];
|
|
5030
5109
|
if (!m) return { ok: false, code: 'no_manifest' };
|
|
5031
|
-
const root = document.querySelector('[data-nac-plugin="' + plugin_slug + '"]');
|
|
5110
|
+
const root = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]');
|
|
5032
5111
|
if (!root) return { ok: false, code: 'plugin_not_mounted' };
|
|
5033
5112
|
const found = {};
|
|
5034
5113
|
const elemByNacId = {};
|
|
@@ -5219,8 +5298,8 @@
|
|
|
5219
5298
|
m.rows.cells.forEach(function (col) {
|
|
5220
5299
|
if (!col || !col.nac_id) return;
|
|
5221
5300
|
const cell = sampleRow.querySelector(
|
|
5222
|
-
'[data-nac-id$="' + col.nac_id + '"], '
|
|
5223
|
-
+ '[data-nac-cell="' + col.nac_id + '"]');
|
|
5301
|
+
'[data-nac-id$="' + _nac_attrValue(col.nac_id) + '"], '
|
|
5302
|
+
+ '[data-nac-cell="' + _nac_attrValue(col.nac_id) + '"]');
|
|
5224
5303
|
if (!cell) {
|
|
5225
5304
|
pushErr('error', 'row_cell_missing', col.nac_id,
|
|
5226
5305
|
'manifest declares row cell "' + col.nac_id
|
|
@@ -5237,7 +5316,7 @@
|
|
|
5237
5316
|
b.items.forEach(function (item) {
|
|
5238
5317
|
if (!item || !item.nac_id) return;
|
|
5239
5318
|
const el = root.querySelector(
|
|
5240
|
-
'[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) + '"]');
|
|
5241
5320
|
if (!el) {
|
|
5242
5321
|
pushErr('error', 'breadcrumb_item_missing', item.nac_id,
|
|
5243
5322
|
'breadcrumb item "' + item.nac_id
|
|
@@ -5306,7 +5385,7 @@
|
|
|
5306
5385
|
{
|
|
5307
5386
|
const sameSlug = Array.prototype.slice.call(
|
|
5308
5387
|
document.querySelectorAll(
|
|
5309
|
-
'[data-nac-plugin="' + plugin_slug + '"]'));
|
|
5388
|
+
'[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]'));
|
|
5310
5389
|
if (sameSlug.length > 1) {
|
|
5311
5390
|
const ids = sameSlug.map(function (r) {
|
|
5312
5391
|
return r.getAttribute('data-nac-plugin-id') || '';
|
|
@@ -5900,8 +5979,8 @@
|
|
|
5900
5979
|
/* ---------- v1.2: window chrome (min/max/restore) --------------- */
|
|
5901
5980
|
|
|
5902
5981
|
function _findPluginRoot(plugin) {
|
|
5903
|
-
return document.querySelector('[data-nac-plugin="' + plugin + '"]')
|
|
5904
|
-
|| 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) + '"]');
|
|
5905
5984
|
}
|
|
5906
5985
|
|
|
5907
5986
|
function _setPluginState(plugin, newState) {
|
|
@@ -6079,7 +6158,7 @@
|
|
|
6079
6158
|
|
|
6080
6159
|
function _genericReset(plugin_slug) {
|
|
6081
6160
|
const root = plugin_slug
|
|
6082
|
-
? document.querySelector('[data-nac-plugin="' + plugin_slug + '"]')
|
|
6161
|
+
? document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin_slug) + '"]')
|
|
6083
6162
|
: document;
|
|
6084
6163
|
if (!root) return false;
|
|
6085
6164
|
/* Clear every NAC-instrumented field. Honours
|
|
@@ -6159,7 +6238,7 @@
|
|
|
6159
6238
|
|
|
6160
6239
|
function _findSection(sectionId) {
|
|
6161
6240
|
return document.querySelector(
|
|
6162
|
-
'[data-nac-role="section"][data-nac-id="' + sectionId + '"]');
|
|
6241
|
+
'[data-nac-role="section"][data-nac-id="' + _nac_attrValue(sectionId) + '"]');
|
|
6163
6242
|
}
|
|
6164
6243
|
|
|
6165
6244
|
function list_sections() {
|
|
@@ -6270,7 +6349,7 @@
|
|
|
6270
6349
|
}
|
|
6271
6350
|
if (detail.plugin && detail.plugin_instance_id === undefined) {
|
|
6272
6351
|
const root = document.querySelector(
|
|
6273
|
-
'[data-nac-plugin="' + detail.plugin + '"]');
|
|
6352
|
+
'[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]');
|
|
6274
6353
|
detail.plugin_instance_id = root
|
|
6275
6354
|
? (root.getAttribute('data-nac-plugin-id') || null)
|
|
6276
6355
|
: null;
|
|
@@ -6297,9 +6376,9 @@
|
|
|
6297
6376
|
payload filtering. */
|
|
6298
6377
|
if (detail.plugin) {
|
|
6299
6378
|
const root = document.querySelector(
|
|
6300
|
-
'[data-nac-plugin="' + detail.plugin + '"]'
|
|
6379
|
+
'[data-nac-plugin="' + _nac_attrValue(detail.plugin) + '"]'
|
|
6301
6380
|
+ (detail.plugin_instance_id
|
|
6302
|
-
? '[data-nac-plugin-id="' + detail.plugin_instance_id + '"]'
|
|
6381
|
+
? '[data-nac-plugin-id="' + _nac_attrValue(detail.plugin_instance_id) + '"]'
|
|
6303
6382
|
: ''));
|
|
6304
6383
|
if (root && root.getAttribute('data-nac-plugin-bus') === 'enabled') {
|
|
6305
6384
|
root.dispatchEvent(new CustomEvent(name, {
|
|
@@ -6362,9 +6441,9 @@
|
|
|
6362
6441
|
exposure API. Falls back to document.querySelector when
|
|
6363
6442
|
the deep helper is unavailable (defensive). */
|
|
6364
6443
|
if (typeof _deepQuery === 'function') {
|
|
6365
|
-
return _deepQuery('[data-nac-id="' + id + '"]', document);
|
|
6444
|
+
return _deepQuery('[data-nac-id="' + _nac_attrValue(id) + '"]', document);
|
|
6366
6445
|
}
|
|
6367
|
-
return document.querySelector('[data-nac-id="' + id + '"]');
|
|
6446
|
+
return document.querySelector('[data-nac-id="' + _nac_attrValue(id) + '"]');
|
|
6368
6447
|
}
|
|
6369
6448
|
|
|
6370
6449
|
/* ---------- v1.3: toast / banner / confirm --------------------- */
|
|
@@ -6485,8 +6564,8 @@
|
|
|
6485
6564
|
_emit(answer ? 'nac:confirm:confirmed' : 'nac:confirm:cancelled', { id: id });
|
|
6486
6565
|
resolve(!!answer);
|
|
6487
6566
|
}
|
|
6488
|
-
card.querySelector('[data-nac-id="' + id + '.confirm"]').addEventListener('click', function () { done(true); });
|
|
6489
|
-
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); });
|
|
6490
6569
|
});
|
|
6491
6570
|
}
|
|
6492
6571
|
function list_pending_confirms() {
|
|
@@ -6559,7 +6638,7 @@
|
|
|
6559
6638
|
|
|
6560
6639
|
function _stepperRoot(stepper_id) {
|
|
6561
6640
|
return document.querySelector(
|
|
6562
|
-
'[data-nac-role="stepper"][data-nac-id="' + stepper_id + '"]');
|
|
6641
|
+
'[data-nac-role="stepper"][data-nac-id="' + _nac_attrValue(stepper_id) + '"]');
|
|
6563
6642
|
}
|
|
6564
6643
|
function _stepperSteps(stepper_id) {
|
|
6565
6644
|
const root = _stepperRoot(stepper_id);
|
|
@@ -6615,7 +6694,7 @@
|
|
|
6615
6694
|
|
|
6616
6695
|
function _treeNode(node_id) {
|
|
6617
6696
|
return document.querySelector(
|
|
6618
|
-
'[data-nac-role="treenode"][data-nac-id="' + node_id + '"]');
|
|
6697
|
+
'[data-nac-role="treenode"][data-nac-id="' + _nac_attrValue(node_id) + '"]');
|
|
6619
6698
|
}
|
|
6620
6699
|
function tree_expand(node_id) {
|
|
6621
6700
|
const n = _treeNode(node_id);
|
|
@@ -6674,7 +6753,7 @@
|
|
|
6674
6753
|
|
|
6675
6754
|
function _tagFieldRoot(field_id) {
|
|
6676
6755
|
const el = document.querySelector(
|
|
6677
|
-
'[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) + '"]');
|
|
6678
6757
|
return el;
|
|
6679
6758
|
}
|
|
6680
6759
|
function add_tag(field_id, value) {
|
|
@@ -6704,8 +6783,8 @@
|
|
|
6704
6783
|
|
|
6705
6784
|
function _drawer(id) {
|
|
6706
6785
|
return document.querySelector(
|
|
6707
|
-
'[data-nac-role="drawer"][data-nac-id="' + id + '"], ' +
|
|
6708
|
-
'[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) + '"]');
|
|
6709
6788
|
}
|
|
6710
6789
|
function open_drawer(id, position) {
|
|
6711
6790
|
const d = _drawer(id);
|
|
@@ -6732,14 +6811,14 @@
|
|
|
6732
6811
|
|
|
6733
6812
|
function calendar_view(cal_id, view) {
|
|
6734
6813
|
const c = document.querySelector(
|
|
6735
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6814
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6736
6815
|
if (!c) throw NacError('calendar_not_found', cal_id);
|
|
6737
6816
|
c.setAttribute('data-nac-view', view);
|
|
6738
6817
|
_emit('nac:calendar:view_changed', { calendar_id: cal_id, view: view });
|
|
6739
6818
|
}
|
|
6740
6819
|
function calendar_go_to(cal_id, date) {
|
|
6741
6820
|
const c = document.querySelector(
|
|
6742
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6821
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6743
6822
|
if (!c) throw NacError('calendar_not_found', cal_id);
|
|
6744
6823
|
c.setAttribute('data-nac-date', date);
|
|
6745
6824
|
_emit('nac:calendar:date_selected', { calendar_id: cal_id, date: date });
|
|
@@ -6756,7 +6835,7 @@
|
|
|
6756
6835
|
}
|
|
6757
6836
|
function calendar_list_events(cal_id /*, from, to */) {
|
|
6758
6837
|
const c = document.querySelector(
|
|
6759
|
-
'[data-nac-role="calendar"][data-nac-id="' + cal_id + '"]');
|
|
6838
|
+
'[data-nac-role="calendar"][data-nac-id="' + _nac_attrValue(cal_id) + '"]');
|
|
6760
6839
|
if (!c) return [];
|
|
6761
6840
|
const out = [];
|
|
6762
6841
|
c.querySelectorAll('[data-nac-role="calendar-event"]').forEach(function (e) {
|
|
@@ -6775,7 +6854,7 @@
|
|
|
6775
6854
|
|
|
6776
6855
|
function chart_data(chart_id) {
|
|
6777
6856
|
const c = document.querySelector(
|
|
6778
|
-
'[data-nac-role="chart"][data-nac-id="' + chart_id + '"]');
|
|
6857
|
+
'[data-nac-role="chart"][data-nac-id="' + _nac_attrValue(chart_id) + '"]');
|
|
6779
6858
|
if (!c) throw NacError('chart_not_found', chart_id);
|
|
6780
6859
|
const series = [];
|
|
6781
6860
|
c.querySelectorAll('[data-nac-role="chart-series"]').forEach(function (s) {
|
|
@@ -6799,7 +6878,7 @@
|
|
|
6799
6878
|
}
|
|
6800
6879
|
function chart_toggle_series(chart_id, series_id, on) {
|
|
6801
6880
|
const s = document.querySelector(
|
|
6802
|
-
'[data-nac-role="chart-series"][data-nac-id="' + series_id + '"]');
|
|
6881
|
+
'[data-nac-role="chart-series"][data-nac-id="' + _nac_attrValue(series_id) + '"]');
|
|
6803
6882
|
if (!s) throw NacError('chart_series_not_found', series_id);
|
|
6804
6883
|
const target = (typeof on === 'boolean') ? on : (s.getAttribute('data-nac-state') === 'hidden');
|
|
6805
6884
|
s.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
|
|
@@ -6813,7 +6892,7 @@
|
|
|
6813
6892
|
|
|
6814
6893
|
function map_focus(map_id, lat, lng, zoom) {
|
|
6815
6894
|
const m = document.querySelector(
|
|
6816
|
-
'[data-nac-role="map"][data-nac-id="' + map_id + '"]');
|
|
6895
|
+
'[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
|
|
6817
6896
|
if (!m) throw NacError('map_not_found', map_id);
|
|
6818
6897
|
m.setAttribute('data-nac-lat', String(lat));
|
|
6819
6898
|
m.setAttribute('data-nac-lng', String(lng));
|
|
@@ -6825,7 +6904,7 @@
|
|
|
6825
6904
|
}
|
|
6826
6905
|
function map_select_marker(marker_id) {
|
|
6827
6906
|
const mk = document.querySelector(
|
|
6828
|
-
'[data-nac-role="map-marker"][data-nac-id="' + marker_id + '"]');
|
|
6907
|
+
'[data-nac-role="map-marker"][data-nac-id="' + _nac_attrValue(marker_id) + '"]');
|
|
6829
6908
|
if (!mk) throw NacError('map_marker_not_found', marker_id);
|
|
6830
6909
|
mk.setAttribute('data-nac-state', 'selected');
|
|
6831
6910
|
const map_id = (mk.closest('[data-nac-role="map"]') || {}).getAttribute
|
|
@@ -6841,7 +6920,7 @@
|
|
|
6841
6920
|
}
|
|
6842
6921
|
function map_toggle_layer(map_id, layer_id, on) {
|
|
6843
6922
|
const ly = document.querySelector(
|
|
6844
|
-
'[data-nac-role="map-layer"][data-nac-id="' + layer_id + '"]');
|
|
6923
|
+
'[data-nac-role="map-layer"][data-nac-id="' + _nac_attrValue(layer_id) + '"]');
|
|
6845
6924
|
if (!ly) throw NacError('map_layer_not_found', layer_id);
|
|
6846
6925
|
const target = (typeof on === 'boolean') ? on : (ly.getAttribute('data-nac-state') === 'hidden');
|
|
6847
6926
|
ly.setAttribute('data-nac-state', target ? 'visible' : 'hidden');
|
|
@@ -6849,7 +6928,7 @@
|
|
|
6849
6928
|
}
|
|
6850
6929
|
function list_markers(map_id) {
|
|
6851
6930
|
const m = document.querySelector(
|
|
6852
|
-
'[data-nac-role="map"][data-nac-id="' + map_id + '"]');
|
|
6931
|
+
'[data-nac-role="map"][data-nac-id="' + _nac_attrValue(map_id) + '"]');
|
|
6853
6932
|
if (!m) return [];
|
|
6854
6933
|
const out = [];
|
|
6855
6934
|
m.querySelectorAll('[data-nac-role="map-marker"]').forEach(function (mk) {
|
|
@@ -6883,7 +6962,7 @@
|
|
|
6883
6962
|
|
|
6884
6963
|
function _breadcrumbContainer(crumb_id) {
|
|
6885
6964
|
return document.querySelector(
|
|
6886
|
-
'[data-nac-role="breadcrumb"][data-nac-id="' + crumb_id + '"]');
|
|
6965
|
+
'[data-nac-role="breadcrumb"][data-nac-id="' + _nac_attrValue(crumb_id) + '"]');
|
|
6887
6966
|
}
|
|
6888
6967
|
function _breadcrumbItems(rootEl) {
|
|
6889
6968
|
if (!rootEl) return [];
|
|
@@ -6918,7 +6997,7 @@
|
|
|
6918
6997
|
+ item_id + '"]');
|
|
6919
6998
|
if (!el) {
|
|
6920
6999
|
// fallback: any anchor whose label matches
|
|
6921
|
-
el = document.querySelector('a[data-nac-id="' + item_id + '"]');
|
|
7000
|
+
el = document.querySelector('a[data-nac-id="' + _nac_attrValue(item_id) + '"]');
|
|
6922
7001
|
}
|
|
6923
7002
|
if (!el) {
|
|
6924
7003
|
return Promise.reject(new NacError('not_found',
|
|
@@ -6944,7 +7023,7 @@
|
|
|
6944
7023
|
|
|
6945
7024
|
function _carousel(carousel_id) {
|
|
6946
7025
|
return document.querySelector(
|
|
6947
|
-
'[data-nac-role="carousel"][data-nac-id="' + carousel_id + '"]');
|
|
7026
|
+
'[data-nac-role="carousel"][data-nac-id="' + _nac_attrValue(carousel_id) + '"]');
|
|
6948
7027
|
}
|
|
6949
7028
|
function _carouselSlides(rootEl) {
|
|
6950
7029
|
if (!rootEl) return [];
|
|
@@ -7045,7 +7124,7 @@
|
|
|
7045
7124
|
|
|
7046
7125
|
function _timeline(timeline_id) {
|
|
7047
7126
|
return document.querySelector(
|
|
7048
|
-
'[data-nac-role="timeline"][data-nac-id="' + timeline_id + '"]');
|
|
7127
|
+
'[data-nac-role="timeline"][data-nac-id="' + _nac_attrValue(timeline_id) + '"]');
|
|
7049
7128
|
}
|
|
7050
7129
|
function _timelineItems(rootEl) {
|
|
7051
7130
|
if (!rootEl) return [];
|
|
@@ -7123,7 +7202,7 @@
|
|
|
7123
7202
|
'list not found: ' + list_id));
|
|
7124
7203
|
}
|
|
7125
7204
|
var item = list.querySelector(
|
|
7126
|
-
'[data-nac-role="draggable"][data-nac-id="' + item_id + '"]')
|
|
7205
|
+
'[data-nac-role="draggable"][data-nac-id="' + _nac_attrValue(item_id) + '"]')
|
|
7127
7206
|
|| _byId(item_id);
|
|
7128
7207
|
if (!item) {
|
|
7129
7208
|
return Promise.reject(new NacError('not_found',
|
|
@@ -8659,6 +8738,53 @@
|
|
|
8659
8738
|
}
|
|
8660
8739
|
}
|
|
8661
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
|
+
|
|
8662
8788
|
/* postmessage (verb): post a structured message to the iframe.contentWindow
|
|
8663
8789
|
of the target. `values` literal + `values_from_args` forward keys. */
|
|
8664
8790
|
function _v25_backend_postmessage(binding, args) {
|
|
@@ -8687,7 +8813,7 @@
|
|
|
8687
8813
|
}
|
|
8688
8814
|
}
|
|
8689
8815
|
try {
|
|
8690
|
-
iframe.contentWindow.postMessage(msg, binding
|
|
8816
|
+
iframe.contentWindow.postMessage(msg, _v25_targetOrigin(binding, iframe, 'postmessage'));
|
|
8691
8817
|
return Promise.resolve({ ok: true });
|
|
8692
8818
|
} catch (e) {
|
|
8693
8819
|
return Promise.reject(e);
|
|
@@ -8793,7 +8919,7 @@
|
|
|
8793
8919
|
MessageId: binding.message,
|
|
8794
8920
|
SendTime: Date.now(),
|
|
8795
8921
|
Values: wantValues,
|
|
8796
|
-
}, binding
|
|
8922
|
+
}, _v25_targetOrigin(binding, iframe, 'script-bridge'));
|
|
8797
8923
|
});
|
|
8798
8924
|
}
|
|
8799
8925
|
|
|
@@ -9960,7 +10086,7 @@
|
|
|
9960
10086
|
subtree. If plugin is omitted, fall back to global search. */
|
|
9961
10087
|
let root = document;
|
|
9962
10088
|
if (plugin) {
|
|
9963
|
-
const pluginRoot = document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
10089
|
+
const pluginRoot = document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
9964
10090
|
if (!pluginRoot) return null;
|
|
9965
10091
|
root = pluginRoot;
|
|
9966
10092
|
}
|
|
@@ -10022,7 +10148,7 @@
|
|
|
10022
10148
|
|
|
10023
10149
|
function _v25b_pluginRoot(plugin) {
|
|
10024
10150
|
if (!plugin) return null;
|
|
10025
|
-
return document.querySelector('[data-nac-plugin="' + plugin + '"]');
|
|
10151
|
+
return document.querySelector('[data-nac-plugin="' + _nac_attrValue(plugin) + '"]');
|
|
10026
10152
|
}
|
|
10027
10153
|
|
|
10028
10154
|
function context(plugin) {
|
|
@@ -10214,8 +10340,8 @@
|
|
|
10214
10340
|
|
|
10215
10341
|
global.NAC = {
|
|
10216
10342
|
__nac_v1_installed: true,
|
|
10217
|
-
version: '2.
|
|
10218
|
-
spec_version: '2.
|
|
10343
|
+
version: '2.9.1',
|
|
10344
|
+
spec_version: '2.9',
|
|
10219
10345
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
10220
10346
|
NAC.register throws on findings (manifest_role_unknown,
|
|
10221
10347
|
tab_id_manifest_role_drift, manifest_dom_role_mismatch).
|
|
@@ -10587,6 +10713,115 @@
|
|
|
10587
10713
|
diff: diff,
|
|
10588
10714
|
};
|
|
10589
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
|
+
|
|
10590
10825
|
/* v2.2.1: guard browser-only init so this module is importable in
|
|
10591
10826
|
Node / SSR / test contexts without crashing. */
|
|
10592
10827
|
if (typeof document !== 'undefined') {
|