@nac3/runtime 2.2.0 → 2.2.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.1 -- 2026-05-12
4
+
5
+ ### Bug fix: importable in Node / SSR / test contexts
6
+
7
+ Pre-launch smoke test caught that `import '@nac3/runtime'` and
8
+ `import '@nac3/runtime/chat-client'` crashed in Node.js with
9
+ `ReferenceError: document is not defined`. The bundles had
10
+ top-level `document.dispatchEvent` and `document.addEventListener`
11
+ calls firing at module-evaluation time.
12
+
13
+ Fix: wrap browser-only init in `typeof document !== 'undefined'`
14
+ guards. In the browser the behaviour is unchanged (the events
15
+ still fire on install + the confirm listener still attaches). In
16
+ Node / SSR / Vitest / Jest the bundles now import as no-ops
17
+ instead of crashing.
18
+
19
+ Files patched (no API change):
20
+ - `dist/nac.{mjs,cjs,browser.js}` -- guarded `nac:installed`
21
+ dispatch + `_installA11yHintBridge()` call.
22
+ - `dist/nac-chat-client.{mjs,cjs,browser.js}` -- guarded
23
+ `nac:confirm:requested` listener attach.
24
+ - `dist/nac-v2-extensions.*` -- unchanged (it already early-bails
25
+ when the main runtime is not present).
26
+
27
+ Verified: all three entry points (`@nac3/runtime`,
28
+ `@nac3/runtime/extensions`, `@nac3/runtime/chat-client`) now
29
+ import cleanly under Node 22 ESM + CommonJS `require`.
30
+
3
31
  ## 2.2.0 -- 2026-05-10
4
32
 
5
33
  Same-day v2.2 ships the constructor-strict validator + action-ack
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // NAC CLI v2.2.0
2
+ // NAC CLI v2.2.1
3
3
  // Usage:
4
4
  // nac validate <url-or-dir> [--severity=error|warn|info]
5
5
  // nac --version
@@ -18,7 +18,7 @@ const args = process.argv.slice(2);
18
18
  const cmd = args[0];
19
19
 
20
20
  function showHelp() {
21
- console.log('NAC CLI v2.2.0');
21
+ console.log('NAC CLI v2.2.1');
22
22
  console.log('');
23
23
  console.log('Usage:');
24
24
  console.log(' nac validate <url-or-dir> [--severity=error|warn|info]');
@@ -27,7 +27,7 @@ function showHelp() {
27
27
  }
28
28
 
29
29
  function showVersion() {
30
- console.log('@nac3/runtime CLI 2.2.0 (Native Agent Contract v2.2)');
30
+ console.log('@nac3/runtime CLI 2.2.1 (Native Agent Contract v2.2)');
31
31
  }
32
32
 
33
33
  if (!cmd || cmd === '--help' || cmd === '-h') { showHelp(); process.exit(0); }
@@ -213,19 +213,23 @@
213
213
  botSpeak(isYes ? 'Confirmado.' : 'Cancelado.', { skipBubble: true });
214
214
  return true;
215
215
  }
216
- document.addEventListener('nac:confirm:requested', function (e) {
217
- try {
218
- var prompt = (e && e.detail && e.detail.prompt) || '';
219
- if (!prompt) return;
220
- var hints = {
221
- es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
222
- fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
223
- ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
224
- hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
225
- };
226
- botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
227
- } catch (_) {}
228
- }, true);
216
+ /* v2.2.1: guard browser-only listener so this bundle is importable in
217
+ Node / SSR / test contexts without crashing. */
218
+ if (typeof document !== 'undefined') {
219
+ document.addEventListener('nac:confirm:requested', function (e) {
220
+ try {
221
+ var prompt = (e && e.detail && e.detail.prompt) || '';
222
+ if (!prompt) return;
223
+ var hints = {
224
+ es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
225
+ fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
226
+ ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
227
+ hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
228
+ };
229
+ botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
230
+ } catch (_) {}
231
+ }, true);
232
+ }
229
233
 
230
234
  /* ---------- Locale switch (fix C7-bis) ---------- */
231
235
  function _maybeChangeLocaleLocally(text) {
@@ -214,19 +214,23 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
214
214
  botSpeak(isYes ? 'Confirmado.' : 'Cancelado.', { skipBubble: true });
215
215
  return true;
216
216
  }
217
- document.addEventListener('nac:confirm:requested', function (e) {
218
- try {
219
- var prompt = (e && e.detail && e.detail.prompt) || '';
220
- if (!prompt) return;
221
- var hints = {
222
- es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
223
- fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
224
- ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
225
- hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
226
- };
227
- botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
228
- } catch (_) {}
229
- }, true);
217
+ /* v2.2.1: guard browser-only listener so this bundle is importable in
218
+ Node / SSR / test contexts without crashing. */
219
+ if (typeof document !== 'undefined') {
220
+ document.addEventListener('nac:confirm:requested', function (e) {
221
+ try {
222
+ var prompt = (e && e.detail && e.detail.prompt) || '';
223
+ if (!prompt) return;
224
+ var hints = {
225
+ es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
226
+ fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
227
+ ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
228
+ hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
229
+ };
230
+ botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
231
+ } catch (_) {}
232
+ }, true);
233
+ }
230
234
 
231
235
  /* ---------- Locale switch (fix C7-bis) ---------- */
232
236
  function _maybeChangeLocaleLocally(text) {
@@ -214,19 +214,23 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
214
214
  botSpeak(isYes ? 'Confirmado.' : 'Cancelado.', { skipBubble: true });
215
215
  return true;
216
216
  }
217
- document.addEventListener('nac:confirm:requested', function (e) {
218
- try {
219
- var prompt = (e && e.detail && e.detail.prompt) || '';
220
- if (!prompt) return;
221
- var hints = {
222
- es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
223
- fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
224
- ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
225
- hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
226
- };
227
- botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
228
- } catch (_) {}
229
- }, true);
217
+ /* v2.2.1: guard browser-only listener so this bundle is importable in
218
+ Node / SSR / test contexts without crashing. */
219
+ if (typeof document !== 'undefined') {
220
+ document.addEventListener('nac:confirm:requested', function (e) {
221
+ try {
222
+ var prompt = (e && e.detail && e.detail.prompt) || '';
223
+ if (!prompt) return;
224
+ var hints = {
225
+ es: 'Decime si o no.', en: 'Say yes or no.', pt: 'Diga sim ou nao.',
226
+ fr: 'Dites oui ou non.', it: 'Dimmi si o no.', de: 'Sag ja oder nein.',
227
+ ja: 'はい か いいえ で答えて。', zh: '请说 是 或 否。',
228
+ hi: 'haan ya nahin.', ar: 'قل نعم او لا.'
229
+ };
230
+ botSpeak(prompt + ' ' + (hints[NacChat._lang] || hints.es), { skipBubble: true });
231
+ } catch (_) {}
232
+ }, true);
233
+ }
230
234
 
231
235
  /* ---------- Locale switch (fix C7-bis) ---------- */
232
236
  function _maybeChangeLocaleLocally(text) {
@@ -222,10 +222,14 @@
222
222
  document.addEventListener(n, handler, { capture: true, passive: true });
223
223
  });
224
224
  }
225
- if (document.readyState === 'loading') {
226
- document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
227
- } else {
228
- _captureGestureFromDom();
225
+ /* v2.2.1: guard browser-only DOM hookup so this bundle is
226
+ importable in Node / SSR / test contexts. */
227
+ if (typeof document !== 'undefined') {
228
+ if (document.readyState === 'loading') {
229
+ document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
230
+ } else {
231
+ _captureGestureFromDom();
232
+ }
229
233
  }
230
234
 
231
235
  /* v2.0-rc3: _readGestureAttested now requires the element being
@@ -2089,8 +2093,12 @@
2089
2093
  NAC.version_v2 = '2.1.0-rc1';
2090
2094
  NAC.spec_version_v2 = '2.1';
2091
2095
 
2092
- document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2093
- detail: { version: '2.0.0' }, bubbles: true
2094
- }));
2096
+ /* v2.2.1: guard browser-only dispatch so this bundle is importable
2097
+ in Node / SSR / test contexts. */
2098
+ if (typeof document !== 'undefined') {
2099
+ document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2100
+ detail: { version: '2.0.0' }, bubbles: true
2101
+ }));
2102
+ }
2095
2103
  })(typeof window !== 'undefined' ? window : globalThis);
2096
2104
 
@@ -223,10 +223,14 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
223
223
  document.addEventListener(n, handler, { capture: true, passive: true });
224
224
  });
225
225
  }
226
- if (document.readyState === 'loading') {
227
- document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
228
- } else {
229
- _captureGestureFromDom();
226
+ /* v2.2.1: guard browser-only DOM hookup so this bundle is
227
+ importable in Node / SSR / test contexts. */
228
+ if (typeof document !== 'undefined') {
229
+ if (document.readyState === 'loading') {
230
+ document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
231
+ } else {
232
+ _captureGestureFromDom();
233
+ }
230
234
  }
231
235
 
232
236
  /* v2.0-rc3: _readGestureAttested now requires the element being
@@ -2090,9 +2094,13 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
2090
2094
  NAC.version_v2 = '2.1.0-rc1';
2091
2095
  NAC.spec_version_v2 = '2.1';
2092
2096
 
2093
- document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2094
- detail: { version: '2.0.0' }, bubbles: true
2095
- }));
2097
+ /* v2.2.1: guard browser-only dispatch so this bundle is importable
2098
+ in Node / SSR / test contexts. */
2099
+ if (typeof document !== 'undefined') {
2100
+ document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2101
+ detail: { version: '2.0.0' }, bubbles: true
2102
+ }));
2103
+ }
2096
2104
  })(typeof window !== 'undefined' ? window : globalThis);
2097
2105
 
2098
2106
  module.exports = _g.NAC || _g.NACv2 || _g.NacChat;
@@ -223,10 +223,14 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
223
223
  document.addEventListener(n, handler, { capture: true, passive: true });
224
224
  });
225
225
  }
226
- if (document.readyState === 'loading') {
227
- document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
228
- } else {
229
- _captureGestureFromDom();
226
+ /* v2.2.1: guard browser-only DOM hookup so this bundle is
227
+ importable in Node / SSR / test contexts. */
228
+ if (typeof document !== 'undefined') {
229
+ if (document.readyState === 'loading') {
230
+ document.addEventListener('DOMContentLoaded', _captureGestureFromDom);
231
+ } else {
232
+ _captureGestureFromDom();
233
+ }
230
234
  }
231
235
 
232
236
  /* v2.0-rc3: _readGestureAttested now requires the element being
@@ -2090,9 +2094,13 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
2090
2094
  NAC.version_v2 = '2.1.0-rc1';
2091
2095
  NAC.spec_version_v2 = '2.1';
2092
2096
 
2093
- document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2094
- detail: { version: '2.0.0' }, bubbles: true
2095
- }));
2097
+ /* v2.2.1: guard browser-only dispatch so this bundle is importable
2098
+ in Node / SSR / test contexts. */
2099
+ if (typeof document !== 'undefined') {
2100
+ document.dispatchEvent(new CustomEvent('nac:v2_installed', {
2101
+ detail: { version: '2.0.0' }, bubbles: true
2102
+ }));
2103
+ }
2096
2104
  })(typeof window !== 'undefined' ? window : globalThis);
2097
2105
 
2098
2106
  export default _g.NAC || _g.NACv2 || _g.NacChat || _g[Object.keys(_g).find(k => /^NA[Cc]/.test(k))];
@@ -5007,7 +5007,7 @@
5007
5007
 
5008
5008
  global.NAC = {
5009
5009
  __nac_v1_installed: true,
5010
- version: '2.2.0',
5010
+ version: '2.2.1',
5011
5011
  spec_version: '2.2',
5012
5012
  /* v2.2.0 (V22-01) -- strict validation toggle. When true,
5013
5013
  NAC.register throws on findings (manifest_role_unknown,
@@ -5193,15 +5193,19 @@
5193
5193
  NacError: NacError,
5194
5194
  };
5195
5195
 
5196
- document.dispatchEvent(new CustomEvent('nac:installed', {
5197
- detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5198
- }));
5196
+ /* v2.2.1: guard browser-only init so this module is importable in
5197
+ Node / SSR / test contexts without crashing. */
5198
+ if (typeof document !== 'undefined') {
5199
+ document.dispatchEvent(new CustomEvent('nac:installed', {
5200
+ detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5201
+ }));
5199
5202
 
5200
- /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5201
- screen readers actually consume the hints today (sec 3.1).
5202
- Runs after install so existing host-level aria-describedby
5203
- values are preserved (we append, not overwrite). */
5204
- _installA11yHintBridge();
5203
+ /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5204
+ screen readers actually consume the hints today (sec 3.1).
5205
+ Runs after install so existing host-level aria-describedby
5206
+ values are preserved (we append, not overwrite). */
5207
+ _installA11yHintBridge();
5208
+ }
5205
5209
 
5206
5210
  /* v1.9.0: auto-replay any window.__NAC_PENDING__ buffer the
5207
5211
  host staged before the runtime loaded (sec 13.11). The host
package/dist/nac.cjs CHANGED
@@ -5008,7 +5008,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5008
5008
 
5009
5009
  global.NAC = {
5010
5010
  __nac_v1_installed: true,
5011
- version: '2.2.0',
5011
+ version: '2.2.1',
5012
5012
  spec_version: '2.2',
5013
5013
  /* v2.2.0 (V22-01) -- strict validation toggle. When true,
5014
5014
  NAC.register throws on findings (manifest_role_unknown,
@@ -5194,15 +5194,19 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5194
5194
  NacError: NacError,
5195
5195
  };
5196
5196
 
5197
- document.dispatchEvent(new CustomEvent('nac:installed', {
5198
- detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5199
- }));
5197
+ /* v2.2.1: guard browser-only init so this module is importable in
5198
+ Node / SSR / test contexts without crashing. */
5199
+ if (typeof document !== 'undefined') {
5200
+ document.dispatchEvent(new CustomEvent('nac:installed', {
5201
+ detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5202
+ }));
5200
5203
 
5201
- /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5202
- screen readers actually consume the hints today (sec 3.1).
5203
- Runs after install so existing host-level aria-describedby
5204
- values are preserved (we append, not overwrite). */
5205
- _installA11yHintBridge();
5204
+ /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5205
+ screen readers actually consume the hints today (sec 3.1).
5206
+ Runs after install so existing host-level aria-describedby
5207
+ values are preserved (we append, not overwrite). */
5208
+ _installA11yHintBridge();
5209
+ }
5206
5210
 
5207
5211
  /* v1.9.0: auto-replay any window.__NAC_PENDING__ buffer the
5208
5212
  host staged before the runtime loaded (sec 13.11). The host
package/dist/nac.mjs CHANGED
@@ -5008,7 +5008,7 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5008
5008
 
5009
5009
  global.NAC = {
5010
5010
  __nac_v1_installed: true,
5011
- version: '2.2.0',
5011
+ version: '2.2.1',
5012
5012
  spec_version: '2.2',
5013
5013
  /* v2.2.0 (V22-01) -- strict validation toggle. When true,
5014
5014
  NAC.register throws on findings (manifest_role_unknown,
@@ -5194,15 +5194,19 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
5194
5194
  NacError: NacError,
5195
5195
  };
5196
5196
 
5197
- document.dispatchEvent(new CustomEvent('nac:installed', {
5198
- detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5199
- }));
5197
+ /* v2.2.1: guard browser-only init so this module is importable in
5198
+ Node / SSR / test contexts without crashing. */
5199
+ if (typeof document !== 'undefined') {
5200
+ document.dispatchEvent(new CustomEvent('nac:installed', {
5201
+ detail: { version: global.NAC.version, spec: global.NAC.spec_version },
5202
+ }));
5200
5203
 
5201
- /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5202
- screen readers actually consume the hints today (sec 3.1).
5203
- Runs after install so existing host-level aria-describedby
5204
- values are preserved (we append, not overwrite). */
5205
- _installA11yHintBridge();
5204
+ /* v1.9.0: install the ARIA bridge for data-nac-a11y-hint so
5205
+ screen readers actually consume the hints today (sec 3.1).
5206
+ Runs after install so existing host-level aria-describedby
5207
+ values are preserved (we append, not overwrite). */
5208
+ _installA11yHintBridge();
5209
+ }
5206
5210
 
5207
5211
  /* v1.9.0: auto-replay any window.__NAC_PENDING__ buffer the
5208
5212
  host staged before the runtime loaded (sec 13.11). The host
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nac3/runtime",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Native Agent Contract -- spec + reference runtime that lets web UIs be driven by AI agents, voice runners, and accessibility tools.",
5
5
  "keywords": [
6
6
  "nac",
@@ -17,11 +17,11 @@
17
17
  "homepage": "https://yujin.app/nac-spec/",
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/pkuschnirof/rpaforce-crm.git",
21
- "directory": "packages/nac"
20
+ "url": "https://github.com/yujinapp/nac-spec.git",
21
+ "directory": "runtime"
22
22
  },
23
- "bugs": "https://github.com/pkuschnirof/rpaforce-crm/issues",
24
- "author": "Yujin (https://rpaforce.com)",
23
+ "bugs": "https://github.com/yujinapp/nac-spec/issues",
24
+ "author": "Yujin (https://yujin.app)",
25
25
  "license": "Apache-2.0",
26
26
  "type": "module",
27
27
  "main": "./dist/nac.cjs",