Sample
@tanstack/query-core 5.90.20: onlineManager
Verified sample for npm @tanstack/query-core 5.90.20: onlineManager. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:d75713a86088ef88d6eecfef1a5ec8c18971bb299808aaa412eb1f0a0525c1a0
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-03 |
Case
HOW- Goal
- verify pkg:npm/%40tanstack/query-core@5.90.20
- Packages
- Symbols
-
- onlineManager
- Created
- 2026-09-03T08:48:37Z
Contract
- assert onlineManager isOnline returns true by default in node environment
- assert onlineManager setOnline updates online state and notifies subscribed listeners
- assert onlineManager setOnline deduplicates notifications when state is unchanged
- assert onlineManager unsubscribe stops listener notifications on subsequent online changes
- assert onlineManager setEventListener enables custom event listener configuration
- assert onlineManager cleans up event listener when all subscribers unsubscribe
Files
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/%40tanstack/query-core@5.90.20
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40tanstack/query-core@5.90.20
Demonstrate these symbols/APIs:
- onlineManager
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:89004be95522b2609f770ec8bb849dc41743d3a5f69cdf0708b7801de76079f3","contract":["assert onlineManager isOnline returns true by default in node environment","assert onlineManager setOnline updates online state and notifies subscribed listeners","assert onlineManager setOnline deduplicates notifications when state is unchanged","assert onlineManager unsubscribe stops listener notifications on subsequent online changes","assert onlineManager setEventListener enables custom event listener configuration","assert onlineManager cleans up event listener when all subscribers unsubscribe"],"goal":"verify pkg:npm/%40tanstack/query-core@5.90.20","kind":"HOW","packages":["pkg:npm/%40tanstack/query-core@5.90.20"],"schemaVersion":1,"symbols":["onlineManager"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40tanstack/query-core@5.90.20"],"schemaVersion":1,"subject":"pkg:npm/%40tanstack/query-core@5.90.20","symbols":["onlineManager"],"verifierAdapter":"node-typescript@1"}
import { onlineManager } from '@tanstack/query-core';
/**
* Returns whether the onlineManager currently considers the environment online.
*
* @returns {boolean}
*/
export function isCurrentlyOnline() {
return onlineManager.isOnline();
}
/**
* Explicitly sets the online state.
*
* @param {boolean} online
*/
export function setOnlineState(online) {
onlineManager.setOnline(online);
}
/**
* Subscribes a listener to online state changes.
*
* @param {Function} listener
* @returns {Function} Unsubscribe function
*/
export function subscribeToOnline(listener) {
return onlineManager.subscribe(listener);
}
/**
* Configures a custom event listener setup function.
*
* @param {Function} setup
*/
export function configureOnlineEventListener(setup) {
onlineManager.setEventListener(setup);
}
export { onlineManager };
export default onlineManager;
{
"name": "sample-query-core-verify",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-query-core-verify",
"version": "1.0.0",
"dependencies": {
"@tanstack/query-core": "5.90.20"
}
},
"node_modules/@tanstack/query-core": {
"version": "5.90.20",
"resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.20.tgz",
"integrity": "sha512-OMD2HLpNouXEfZJWcKeVKUgQ5n+n3A2JFmBaScpNDUqSrQSjiveC7dKMe53uJUg1nDG16ttFPz2xfilz6i2uVg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
}
}
}
}
{
"name": "sample-query-core-verify",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"@tanstack/query-core": "5.90.20"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40tanstack/query-core@5.90.20",
"kind": "HOW",
"packages": [
"pkg:npm/%40tanstack/query-core@5.90.20"
],
"symbols": [
"onlineManager"
]
}
import assert from 'node:assert/strict';
import {
onlineManager,
isCurrentlyOnline,
setOnlineState,
subscribeToOnline,
configureOnlineEventListener,
} from '../index.mjs';
// 1. assert onlineManager isOnline returns true by default in node environment
{
assert.strictEqual(typeof onlineManager.isOnline, 'function');
assert.strictEqual(typeof onlineManager.setOnline, 'function');
assert.strictEqual(typeof onlineManager.subscribe, 'function');
assert.strictEqual(typeof onlineManager.setEventListener, 'function');
assert.strictEqual(isCurrentlyOnline(), true);
}
// 2. assert onlineManager setOnline updates online state and notifies subscribed listeners
{
let notifiedState = null;
let callCount = 0;
const unsubscribe = subscribeToOnline((online) => {
callCount++;
notifiedState = online;
});
setOnlineState(false);
assert.strictEqual(isCurrentlyOnline(), false);
assert.strictEqual(callCount, 1);
assert.strictEqual(notifiedState, false);
setOnlineState(true);
assert.strictEqual(isCurrentlyOnline(), true);
assert.strictEqual(callCount, 2);
assert.strictEqual(notifiedState, true);
unsubscribe();
}
// 3. assert onlineManager setOnline deduplicates notifications when state is unchanged
{
let callCount = 0;
const unsubscribe = subscribeToOnline(() => {
callCount++;
});
setOnlineState(true);
assert.strictEqual(callCount, 0);
setOnlineState(false);
assert.strictEqual(callCount, 1);
setOnlineState(false);
assert.strictEqual(callCount, 1);
unsubscribe();
setOnlineState(true);
}
// 4. assert onlineManager unsubscribe stops listener notifications on subsequent online changes
{
let callCount = 0;
const unsubscribe = subscribeToOnline(() => {
callCount++;
});
setOnlineState(false);
assert.strictEqual(callCount, 1);
unsubscribe();
setOnlineState(true);
assert.strictEqual(callCount, 1);
}
// 5. assert onlineManager setEventListener enables custom event listener configuration
{
let cleanupCalled = false;
let customTrigger = null;
configureOnlineEventListener((onOnline) => {
customTrigger = onOnline;
return () => {
cleanupCalled = true;
};
});
assert.strictEqual(typeof customTrigger, 'function');
let listenerState = null;
const unsubscribe = subscribeToOnline((online) => {
listenerState = online;
});
customTrigger(false);
assert.strictEqual(isCurrentlyOnline(), false);
assert.strictEqual(listenerState, false);
customTrigger(true);
assert.strictEqual(isCurrentlyOnline(), true);
assert.strictEqual(listenerState, true);
unsubscribe();
configureOnlineEventListener(() => () => {});
assert.strictEqual(cleanupCalled, true);
setOnlineState(true);
}
// 6. assert onlineManager cleans up event listener when all subscribers unsubscribe
{
let cleanupCalls = 0;
let setupCalls = 0;
configureOnlineEventListener((onOnline) => {
setupCalls++;
return () => {
cleanupCalls++;
};
});
const unsub1 = subscribeToOnline(() => {});
const unsub2 = subscribeToOnline(() => {});
assert.strictEqual(cleanupCalls, 0);
unsub1();
assert.strictEqual(cleanupCalls, 0);
unsub2();
assert.strictEqual(cleanupCalls, 1);
configureOnlineEventListener(() => () => {});
setOnlineState(true);
}
console.log('All onlineManager contract assertions passed.');
Origin Seeder
anonymous