UNPKG

@aws-amplify/analytics

Version:

Analytics category of aws-amplify

1 lines • 1.81 kB
{"version":3,"file":"peekCtxArgs.mjs","sources":["../../../src/utils/peekCtxArgs.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isAmplifyContext } from '@aws-amplify/core';\n/**\n * Non-destructively inspects a public-API arguments array and separates the\n * optional leading {@link AmplifyContext} from the API input.\n *\n * Unlike core's `resolveCtxArgs`, this helper deliberately does NOT fall back\n * to the global context — `ctx` stays `undefined` when no explicit context was\n * supplied. Callers (e.g. `configureAutoTrack`) that only need the context at\n * emit time use this so the global context is resolved lazily: resolving it\n * eagerly would (a) throw when trackers are configured before\n * `Amplify.configure()` and (b) pin auto-tracked events to the configuration\n * snapshot captured at setup time after a later `configure()` call.\n *\n * @param args The raw arguments array of an overloaded public API.\n *\n * @returns `{ ctx?, input }` — `ctx` is set only when the first argument is a\n * branded `AmplifyContext`; `input` is the argument that follows it (or the\n * first argument when no context was passed).\n *\n * @internal\n */\nexport function peekCtxArgs(args) {\n return isAmplifyContext(args[0])\n ? { ctx: args[0], input: args[1] }\n : { ctx: undefined, input: args[0] };\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,IAAI,EAAE;AAClC,IAAI,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACnC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACxC,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE;AAC5C;;;;"}