{"_id":"@appmachina/core-wasm","_rev":"4-32f8c05c4a46ca09c3050c6ee344c7cf","name":"@appmachina/core-wasm","dist-tags":{"latest":"3.0.3"},"versions":{"0.0.1":{"name":"@appmachina/core-wasm","version":"0.0.1","_id":"@appmachina/core-wasm@0.0.1","maintainers":[{"name":"mikekhristo","email":"mike@layers.com"}],"dist":{"shasum":"ab7234fb313737a290846c6ce85975442c868fd8","tarball":"https://registry.npmjs.org/@appmachina/core-wasm/-/core-wasm-0.0.1.tgz","fileCount":2,"integrity":"sha512-JgvfeaUk9sG6GwjePfnjLzMKBBKQY7m+WCEaaRz0HFgAUO/907p4DVTQbOvnAwIXWKadsHy7DoPNqH6eG/3Wsw==","signatures":[{"sig":"MEUCIQDLDm3+ol4aCzg34xH6z3J7z2gq8CGvZVV4/KAAZa9vVgIgUYIKS6kx32raw80lyBQexW2y2YkQmw7YiwYnSOWzVjY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":186},"main":"index.js","access":"public","_npmUser":{"name":"mikekhristo","email":"mike@layers.com"},"_npmVersion":"10.9.4","description":"AppMachina SDK - core-wasm (placeholder)","directories":{},"_nodeVersion":"22.21.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/core-wasm_0.0.1_1775187833749_0.6403214387619838","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"@appmachina/core-wasm","version":"2.2.0","author":{"name":"AppMachina Team"},"license":"MIT","_id":"@appmachina/core-wasm@2.2.0","maintainers":[{"name":"mikekhristo","email":"mike@layers.com"}],"homepage":"https://github.com/appmachina/sdks#readme","bugs":{"url":"https://github.com/appmachina/sdks/issues"},"dist":{"shasum":"ab7af4c2c388852fdd90ec69a44d1fb0440a5f33","tarball":"https://registry.npmjs.org/@appmachina/core-wasm/-/core-wasm-2.2.0.tgz","fileCount":28,"integrity":"sha512-+BOCk9i6ZOi6ogZsViKqWbX1R1uJ/DCgEk72/CLuhiBjHKP0jWPEnoAH1ZBoMTCXW2rQb0WL+5qlDdFTWoDeQg==","signatures":[{"sig":"MEUCIDzP3kmI4ysMiohDZK+ZiKLjPto3DQ3gSddDO5cwmG+IAiEA5YKMkPW+LBbzolE7AI0kNpcLhQ1tIT8B7njUGuZ3Gi0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":809140},"main":"./dist/index.js","_from":"file:appmachina-core-wasm-2.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","browser":"./dist/browser.mjs","exports":{".":{"node":{"import":"./dist/index.mjs","require":"./dist/index.js"},"types":"./dist/index.d.ts","import":"./dist/browser.mjs","browser":"./dist/browser.mjs","default":"./dist/browser.js","require":"./dist/browser.js","react-native":"./dist/browser.js"},"./wasm":{"types":"./pkg/appmachina_core.d.ts","default":"./pkg/appmachina_core.js"},"./browser":{"types":"./dist/browser.d.ts","import":"./dist/browser.mjs","default":"./dist/browser.js"}},"scripts":{"build":"pnpm build:ts","build:ts":"tsdown src/index.ts src/browser.ts --format esm,cjs --dts","build:all":"pnpm build:wasm && pnpm build:ts","build:wasm":"wasm-pack build ../../core --target web --out-dir ../packages/wasm/pkg --out-name appmachina_core"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4c1aef2e-daf4-45cc-be52-af24fd2eff03"}},"_resolved":"/tmp/2b34ac07cf4b1c8471476cbdfdcced90/appmachina-core-wasm-2.2.0.tgz","_integrity":"sha512-+BOCk9i6ZOi6ogZsViKqWbX1R1uJ/DCgEk72/CLuhiBjHKP0jWPEnoAH1ZBoMTCXW2rQb0WL+5qlDdFTWoDeQg==","repository":{"url":"git+https://github.com/appmachina/sdks.git","type":"git","directory":"packages/wasm"},"_npmVersion":"11.12.1","description":"AppMachina SDK Rust core compiled to WASM with JS glue","directories":{},"sideEffects":false,"_nodeVersion":"22.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/core-wasm_2.2.0_1775193797023_0.05058626480789585","host":"s3://npm-registry-packages-npm-production"}},"3.0.2":{"name":"@appmachina/core-wasm","version":"3.0.2","author":{"name":"AppMachina Team"},"license":"MIT","_id":"@appmachina/core-wasm@3.0.2","maintainers":[{"name":"mikekhristo","email":"mike@layers.com"}],"homepage":"https://github.com/appmachina/sdks#readme","bugs":{"url":"https://github.com/appmachina/sdks/issues"},"dist":{"shasum":"6d41e8e1332e5adcccba6344499ba70fad0e6e02","tarball":"https://registry.npmjs.org/@appmachina/core-wasm/-/core-wasm-3.0.2.tgz","fileCount":28,"integrity":"sha512-v/QVGrGM1lvheY+oJ/ShMedyBnrmECCWTXhH2ohqa3lb8VANZQrJwqI1z+cnz4KVaXjn2iofjczED+u1oAgCnw==","signatures":[{"sig":"MEYCIQDV2bv/lJADI7r0dUWgMX82TZLBrvQAO5e1lhkVrKrY9AIhAOS8ig2LbnOxAJuyA9VFxuvwLNffNNXj/o0pqu2WqY2V","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":809140},"main":"./dist/index.js","_from":"file:appmachina-core-wasm-3.0.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","browser":"./dist/browser.mjs","exports":{".":{"node":{"import":"./dist/index.mjs","require":"./dist/index.js"},"types":"./dist/index.d.ts","import":"./dist/browser.mjs","browser":"./dist/browser.mjs","default":"./dist/browser.js","require":"./dist/browser.js","react-native":"./dist/browser.js"},"./wasm":{"types":"./pkg/appmachina_core.d.ts","default":"./pkg/appmachina_core.js"},"./browser":{"types":"./dist/browser.d.ts","import":"./dist/browser.mjs","default":"./dist/browser.js"}},"scripts":{"build":"pnpm build:ts","build:ts":"tsdown src/index.ts src/browser.ts --format esm,cjs --dts","build:all":"pnpm build:wasm && pnpm build:ts","build:wasm":"wasm-pack build ../../core --target web --out-dir ../packages/wasm/pkg --out-name appmachina_core"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4c1aef2e-daf4-45cc-be52-af24fd2eff03"}},"_resolved":"/tmp/4e943eedea40d2d1b5fe413b5be97034/appmachina-core-wasm-3.0.2.tgz","_integrity":"sha512-v/QVGrGM1lvheY+oJ/ShMedyBnrmECCWTXhH2ohqa3lb8VANZQrJwqI1z+cnz4KVaXjn2iofjczED+u1oAgCnw==","repository":{"url":"git+https://github.com/appmachina/sdks.git","type":"git","directory":"packages/wasm"},"_npmVersion":"11.12.1","description":"AppMachina SDK Rust core compiled to WASM with JS glue","directories":{},"sideEffects":false,"_nodeVersion":"22.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/core-wasm_3.0.2_1775443248586_0.7014002156694465","host":"s3://npm-registry-packages-npm-production"}},"3.0.3":{"name":"@appmachina/core-wasm","version":"3.0.3","publishConfig":{"access":"public"},"description":"AppMachina SDK Rust core compiled to WASM with JS glue","license":"MIT","repository":{"type":"git","url":"git+https://github.com/appmachina/sdks.git","directory":"packages/wasm"},"author":{"name":"AppMachina Team"},"main":"./dist/index.js","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","react-native":"./dist/browser.js","browser":"./dist/browser.mjs","node":{"import":"./dist/index.mjs","require":"./dist/index.js"},"import":"./dist/browser.mjs","require":"./dist/browser.js","default":"./dist/browser.js"},"./browser":{"types":"./dist/browser.d.ts","import":"./dist/browser.mjs","default":"./dist/browser.js"},"./wasm":{"types":"./pkg/appmachina_core.d.ts","default":"./pkg/appmachina_core.js"}},"browser":"./dist/browser.mjs","types":"./dist/index.d.ts","sideEffects":false,"scripts":{"build:wasm":"wasm-pack build ../../core --target web --out-dir ../packages/wasm/pkg --out-name appmachina_core","build:ts":"tsdown src/index.ts src/browser.ts --format esm,cjs --dts","build":"pnpm build:ts","build:all":"pnpm build:wasm && pnpm build:ts"},"_id":"@appmachina/core-wasm@3.0.3","bugs":{"url":"https://github.com/appmachina/sdks/issues"},"homepage":"https://github.com/appmachina/sdks#readme","_integrity":"sha512-yZ2cLS/CqK4VpHpQmK1W0neCqVToI5nmWhuatdutIUGlRlyjB0RlAryMO1EgMwmIzp+4lDx3LIcM6bDz7lAPyg==","_resolved":"/tmp/5b409373a4f4dcbea87fb8c2b7bcb7ab/appmachina-core-wasm-3.0.3.tgz","_from":"file:appmachina-core-wasm-3.0.3.tgz","_nodeVersion":"22.19.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-yZ2cLS/CqK4VpHpQmK1W0neCqVToI5nmWhuatdutIUGlRlyjB0RlAryMO1EgMwmIzp+4lDx3LIcM6bDz7lAPyg==","shasum":"5eb52738bc9bdf5e001d3ea334d7d749a7b52aae","tarball":"https://registry.npmjs.org/@appmachina/core-wasm/-/core-wasm-3.0.3.tgz","fileCount":28,"unpackedSize":809139,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFhgPNfLm1XUFoKYCH00PyuZcMPqnf/805+pC6+3SmWuAiEA6/64p+GYl6ugPWUA3ixTVTqz6sSfzmDiICbbalPKnWM="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4c1aef2e-daf4-45cc-be52-af24fd2eff03"}},"directories":{},"maintainers":[{"name":"mikekhristo","email":"mike@layers.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core-wasm_3.0.3_1776227384935_0.3395918620896259"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-03T03:43:53.669Z","modified":"2026-04-15T04:29:45.274Z","0.0.1":"2026-04-03T03:43:53.898Z","2.2.0":"2026-04-03T05:23:17.200Z","3.0.2":"2026-04-06T02:40:48.808Z","3.0.3":"2026-04-15T04:29:45.137Z"},"bugs":{"url":"https://github.com/appmachina/sdks/issues"},"author":{"name":"AppMachina Team"},"license":"MIT","homepage":"https://github.com/appmachina/sdks#readme","repository":{"type":"git","url":"git+https://github.com/appmachina/sdks.git","directory":"packages/wasm"},"description":"AppMachina SDK Rust core compiled to WASM with JS glue","maintainers":[{"name":"mikekhristo","email":"mike@layers.com"}],"readme":"# @appmachina/core-wasm\n\nRust analytics core compiled to WebAssembly with TypeScript wrappers. This is an **internal package** -- consumers should use [@appmachina/client](../client), [@appmachina/node](../node), or [@appmachina/react-native](../react-native).\n\n## Architecture\n\n```\n                  +---------------------------+\n                  |   Platform SDKs           |\n                  |  (client / node / RN)     |\n                  +------------+--------------+\n                               |\n                  +------------v--------------+\n                  |   @appmachina/core-wasm       |\n                  |   JS wrapper (AppMachinaCore) |\n                  +------------+--------------+\n                               |\n                  +------------v--------------+\n                  |   Rust / WASM binary      |\n                  |   (event queue, consent,  |\n                  |    rate limiting, session) |\n                  +---------------------------+\n```\n\nThe Rust/WASM core is the single source of truth for event acceptance, building, and queuing. When WASM is loaded, `track()`/`screen()` delegate entirely to Rust. The JS layer handles HTTP networking, persistence backends, retry with circuit breaker, periodic flush timers, and event hydration from persistence.\n\nWhen WASM is **not** available (e.g. environments where WASM cannot load), a pure-JS fallback builds events and manages its own queue with identical behavior.\n\n## Entry Points\n\n| Entry                             | Condition        | WASM loading                                                    |\n| --------------------------------- | ---------------- | --------------------------------------------------------------- |\n| `@appmachina/core-wasm` (default) | Node.js          | Sync via `fs.readFileSync` -- no async init needed              |\n| `@appmachina/core-wasm/browser`   | Browser bundlers | Async via `initWasm()` -- call before creating `AppMachinaCore` |\n\nBrowser bundlers (webpack, vite, esbuild) automatically resolve the `\"browser\"` export condition, which avoids importing `node:fs`.\n\n## API Reference\n\n### `AppMachinaCore.init(init: AppMachinaCoreInit): AppMachinaCore`\n\nCreate and initialize a new core instance.\n\n```ts\nimport { AppMachinaCore, FetchHttpClient, createDefaultPersistence } from '@appmachina/core-wasm';\n\nconst core = AppMachinaCore.init({\n  config: {\n    apiKey: 'your-api-key',\n    appId: 'your-app-id',\n    environment: 'production',\n    enableDebug: false,\n    flushThreshold: 20, // events before auto-flush (default: 20)\n    maxQueueSize: 10_000, // max queue depth (default: 10,000)\n    maxBatchSize: 1_000, // max events per HTTP batch (default: 1,000)\n    flushIntervalMs: 30_000 // periodic flush timer (default: 30s)\n  },\n  httpClient: new FetchHttpClient(),\n  persistence: createDefaultPersistence('your-app-id')\n});\n```\n\n### `core.track(eventName, properties?, userId?, anonymousId?)`\n\nRecord a custom analytics event. Delegates to the WASM core when available.\n\n### `core.screen(screenName, properties?, userId?, anonymousId?)`\n\nRecord a screen view event.\n\n### `core.identify(userId)`\n\nAssociate subsequent events with a user ID.\n\n### `core.setUserProperties(properties)`\n\nSet user-level properties that persist across sessions.\n\n### `core.setConsent(consent)`\n\nUpdate consent state. Pass `{ analytics: true/false, advertising: true/false }`.\n\n### `core.flush()`\n\nSynchronous flush -- drains the queue to persistence.\n\n### `core.flushAsync()`\n\nAsync flush -- sends events over HTTP with retry and circuit breaker.\n\n### `core.shutdown()`\n\nPersist remaining events and stop the flush timer.\n\n### `core.setDeviceContext(context)`\n\nSet device-level fields (platform, OS version, locale, etc.).\n\n### `core.getSessionId()`\n\nGet the current session ID. Sessions auto-rotate after 30 minutes of inactivity.\n\n### `core.startNewSession()`\n\nForce-start a new session.\n\n### `core.queueDepth()`\n\nReturn the number of queued events.\n\n## Persistence Backends\n\n| Backend                           | Use case                                                           |\n| --------------------------------- | ------------------------------------------------------------------ |\n| `LocalStoragePersistence`         | Browser environments (`window.localStorage`)                       |\n| `MemoryPersistence`               | SSR, tests, Node.js                                                |\n| `NullPersistence`                 | No persistence -- events only live in memory                       |\n| `createDefaultPersistence(appId)` | Auto-detects: localStorage if available, otherwise NullPersistence |\n\nCustom backends implement the `PersistenceBackend` interface:\n\n```ts\ninterface PersistenceBackend {\n  write(key: string, data: Uint8Array): void;\n  read(key: string): Uint8Array | null;\n  delete(key: string): void;\n  listKeys(prefix: string): string[];\n}\n```\n\n## HTTP Client\n\nThe included `FetchHttpClient` uses the Fetch API with configurable timeout (default 30s). Custom HTTP clients implement the `HttpClient` interface:\n\n```ts\ninterface HttpClient {\n  post(url: string, headers: [string, string][], body: Uint8Array): Promise<HttpResponse>;\n  get(url: string, headers: [string, string][]): Promise<HttpResponse>;\n}\n```\n\n## Error Handling\n\nAll errors are typed as `AppMachinaError` with a `code` field:\n\n```ts\nimport { AppMachinaError } from '@appmachina/core-wasm';\n\ntry {\n  core.track('event');\n} catch (e) {\n  if (e instanceof AppMachinaError) {\n    console.error(e.code, e.message); // e.g. 'INVALID_ARGUMENT', 'eventName must not be empty'\n  }\n}\n```\n\nError codes: `INVALID_CONFIG`, `INVALID_ARGUMENT`, `SHUT_DOWN`, `QUEUE_FULL`, `HTTP`, `CIRCUIT_OPEN`, `NETWORK`, `SERIALIZATION`, `RATE_LIMITED`, `CONSENT_NOT_GRANTED`, `PERSISTENCE`, `REMOTE_CONFIG`, `EVENT_DENIED`, `INTERNAL`.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}