{"_id":"@bradensbay/globals","_rev":"2-88b75ed25c95de25be33d32869ff550a","name":"@bradensbay/globals","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.0":{"name":"@bradensbay/globals","version":"0.2.0","license":"MIT","_id":"@bradensbay/globals@0.2.0","maintainers":[{"name":"christiangrrogers","email":"christiangrrogers@gmail.com"}],"homepage":"https://github.com/christianGRogers/globals#readme","bugs":{"url":"https://github.com/christianGRogers/globals/issues"},"dist":{"shasum":"ed5966e2a8e59885d8567291969a49e34669354e","tarball":"https://registry.npmjs.org/@bradensbay/globals/-/globals-0.2.0.tgz","fileCount":39,"integrity":"sha512-jCxQLs4IEFYH5uBIVIXen8sWAVPNP/wHYp43jd/ud9dIj/7U92Ve29nKnHbmIazL/Pa4QeAM+k8Doql9cV8NFA==","signatures":[{"sig":"MEYCIQCCQ4IHNw0Jby7l79xuOcVDUG4Skb7w/qNlIFTB//GyxAIhAMX5vuNAAUxsTCnIw8lGlqoT82muHLu5o+Dui7eRHrvm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bradensbay%2fglobals@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":57999},"main":"./dist/src/index.js","type":"module","types":"./dist/src/index.d.ts","engines":{"node":">=20.11.0"},"exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"},"./preload":{"types":"./dist/src/native/renderer.d.ts","import":"./dist/src/native/renderer.js"}},"gitHead":"21dd602e24b18673ff60a164f2556eb927bb6596","_npmUser":{"name":"christiangrrogers","email":"christiangrrogers@gmail.com"},"repository":{"url":"git+https://github.com/christianGRogers/globals.git","type":"git","directory":"packages/electron"},"_npmVersion":"10.9.8","description":"Electron integration over the native transport: the owner in the main process, preload-mapped regions for trusted windows, and the asynchronous tier for windows that keep their sandbox.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"@bradensbay/globals-shm":"0.2.0","@bradensbay/globals-core":"0.2.0"},"_hasShrinkwrap":false,"peerDependencies":{"electron":">=28 <35"},"_npmOperationalInternal":{"tmp":"tmp/globals_0.2.0_1788028653050_0.8910197214433742","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@bradensbay/globals","version":"0.2.1","description":"Electron integration over the native transport: the owner in the main process, preload-mapped regions for trusted windows, and the asynchronous tier for windows that keep their sandbox.","type":"module","main":"./dist/src/index.js","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"},"./preload":{"types":"./dist/src/native/renderer.d.ts","import":"./dist/src/native/renderer.js"}},"engines":{"node":">=20.11.0"},"dependencies":{"@bradensbay/globals-core":"0.2.1","@bradensbay/globals-shm":"0.2.1"},"peerDependencies":{"electron":">=28 <45"},"sideEffects":false,"license":"MIT","repository":{"type":"git","url":"git+https://github.com/christianGRogers/globals.git","directory":"packages/electron"},"_id":"@bradensbay/globals@0.2.1","gitHead":"b64920872c82a9a84c5dca28dfa39a6bee9c3983","bugs":{"url":"https://github.com/christianGRogers/globals/issues"},"homepage":"https://github.com/christianGRogers/globals#readme","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-T/e9LoMPw1DTtv7TNnd0wb9ZR0kEe5uqGsP3oKliVfuaK2RTM58cbAQ15CGMd4UTxo1x4+Y9w9oMO6Rlt2Ck5A==","shasum":"11b6679b13b95522e55ec83c2442f6a7c5b8a6c3","tarball":"https://registry.npmjs.org/@bradensbay/globals/-/globals-0.2.1.tgz","fileCount":39,"unpackedSize":57999,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bradensbay%2fglobals@0.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCJRBx1gffmtFd/tEdv3CeaP0XgNHm1X0QsnMd9dvI5cQIhAJjTeS8n4C8nI3l+Ci0p41P9ReKsY5DFRA/c86uir4cK"}]},"_npmUser":{"name":"christiangrrogers","email":"christiangrrogers@gmail.com"},"directories":{},"maintainers":[{"name":"christiangrrogers","email":"christiangrrogers@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/globals_0.2.1_1788134556465_0.47847703316639656"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-29T18:37:32.857Z","modified":"2026-08-31T00:02:36.939Z","0.2.0":"2026-08-29T18:37:33.197Z","0.2.1":"2026-08-31T00:02:36.601Z"},"bugs":{"url":"https://github.com/christianGRogers/globals/issues"},"license":"MIT","homepage":"https://github.com/christianGRogers/globals#readme","repository":{"type":"git","url":"git+https://github.com/christianGRogers/globals.git","directory":"packages/electron"},"description":"Electron integration over the native transport: the owner in the main process, preload-mapped regions for trusted windows, and the asynchronous tier for windows that keep their sandbox.","maintainers":[{"name":"christiangrrogers","email":"christiangrrogers@gmail.com"}],"readme":"# @bradensbay/globals\n\nThe Electron integration for [Globals](https://github.com/christianGRogers/globals) over the\nnative transport ([ADR 0003](../../docs/adr/0003-native-transport.md)): the owner is a plain\nobject in the main process, trusted windows map one shared memory region from their preloads\nand read synchronously, and windows that keep their sandbox get the asynchronous tier.\n\nThe trade, first: **a window that maps the region runs with `sandbox: false`.** Context\nisolation stays on and the page gets no Node access, but the Chromium OS sandbox for that\nrenderer is off. A window that must keep its sandbox uses the asynchronous tier and never\nmaps anything.\n\n## Main process\n\n```ts\nimport { startNativeOwner } from \"@bradensbay/globals\";\n\nconst owner = await startNativeOwner({\n  initial: { count: 0, rows: [] },\n  operations: {\n    increment(draft, payload: { by: number }) {\n      draft.count += payload.by;\n    },\n  },\n  persistence: {}, // optional: rehydrate on boot, save commits under userData\n});\n\nowner.store.get();                 // the owner reads its own store synchronously\nawait owner.update((draft) => …);  // or writes it directly\n```\n\n## A trusted window's preload, with `sandbox: false`\n\n```ts\nimport { connectNative } from \"@bradensbay/globals/preload\";\n\nconst store = await connectNative();\nstore.get();                        // synchronous, never stale, never torn\nstore.select([\"rows\", 3, \"name\"]);\nawait store.dispatch(\"increment\", { by: 1 });\n```\n\nExpose whole operations to the page through `contextBridge`, not per-property reads: a\nbridge crossing costs about a microsecond, so the decode layer belongs on the preload side.\nThe [example application](../../examples/native-multi-window) shows the shape.\n\n## A sandboxed window\n\n```ts\n// main process\nimport { asyncPreloadPath } from \"@bradensbay/globals\";\nnew BrowserWindow({ webPreferences: { preload: asyncPreloadPath(), sandbox: true } });\n```\n\nThe page receives `window.globalsAsync`: `read(path?)`, `dispatch(operation, payload)`, and\n`subscribe(listener)`. There is no synchronous `get` on this tier, deliberately.\n\nFull guide: [docs/electron.md](../../docs/electron.md).\n","readmeFilename":"README.md"}