@datadog/apps-frontend 0.0.9 → 0.0.10

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.
Files changed (31) hide show
  1. package/dist/src/_chunks/chunk-64RLSXHA.js +184 -0
  2. package/dist/src/_chunks/chunk-64RLSXHA.js.map +7 -0
  3. package/dist/src/_chunks/chunk-BWBMAWDD.js +235 -0
  4. package/dist/src/_chunks/{chunk-OEPH347K.js.map → chunk-BWBMAWDD.js.map} +3 -3
  5. package/dist/src/_chunks/chunk-E6L6DSL7.js +230 -0
  6. package/dist/src/_chunks/{chunk-LEEYMNMO.js.map → chunk-E6L6DSL7.js.map} +1 -1
  7. package/dist/src/_chunks/chunk-OF23NNWB.js +34 -0
  8. package/dist/src/_chunks/{chunk-XSHCFEOH.js.map → chunk-OF23NNWB.js.map} +1 -1
  9. package/dist/src/_chunks/chunk-ONCDAC2F.js +802 -0
  10. package/dist/src/_chunks/{chunk-EYBITW7J.js.map → chunk-ONCDAC2F.js.map} +2 -2
  11. package/dist/src/_chunks/chunk-SSORLL57.js +219 -0
  12. package/dist/src/_chunks/{chunk-D43RPVCF.js.map → chunk-SSORLL57.js.map} +1 -1
  13. package/dist/src/_chunks/chunk-VSZMABRM.js +54 -0
  14. package/dist/src/_chunks/{chunk-2V2HASKF.js.map → chunk-VSZMABRM.js.map} +1 -1
  15. package/dist/src/deep-links/react/index.js +8 -1
  16. package/dist/src/druids/react/index.js +25 -1
  17. package/dist/src/druids/react/index.js.map +1 -1
  18. package/dist/src/embedding/react/index.js +2908 -1
  19. package/dist/src/embedding/react/index.js.map +1 -1
  20. package/dist/src/inputs/published-definition.d.ts +13 -0
  21. package/dist/src/inputs/react/index.js +9 -1
  22. package/dist/src/inputs/schemas/index.js +15 -1
  23. package/package.json +2 -1
  24. package/dist/src/_chunks/chunk-2V2HASKF.js +0 -7
  25. package/dist/src/_chunks/chunk-D43RPVCF.js +0 -7
  26. package/dist/src/_chunks/chunk-DETZPDFA.js +0 -7
  27. package/dist/src/_chunks/chunk-DETZPDFA.js.map +0 -7
  28. package/dist/src/_chunks/chunk-EYBITW7J.js +0 -7
  29. package/dist/src/_chunks/chunk-LEEYMNMO.js +0 -7
  30. package/dist/src/_chunks/chunk-OEPH347K.js +0 -7
  31. package/dist/src/_chunks/chunk-XSHCFEOH.js +0 -7
@@ -0,0 +1,219 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ import {
7
+ b as u,
8
+ e as b,
9
+ h as v
10
+ } from "./chunk-ONCDAC2F.js";
11
+ import {
12
+ J as h,
13
+ K as f
14
+ } from "./chunk-E6L6DSL7.js";
15
+
16
+ // src/embedding/react/config.ts
17
+ var y = /* @__PURE__ */ Symbol(
18
+ "DatadogAppProviderModule"
19
+ );
20
+ function A(t, e, n) {
21
+ if (t.length === 0)
22
+ throw new Error("A Datadog App provider module requires an id.");
23
+ return Object.freeze({
24
+ id: t,
25
+ config: Object.freeze({ ...e }),
26
+ [y]: n
27
+ });
28
+ }
29
+ function k(t, e) {
30
+ try {
31
+ console.error(
32
+ `Installing the "${t}" Datadog App provider module failed; the remaining modules and the app still run.`,
33
+ e
34
+ );
35
+ } catch {
36
+ }
37
+ }
38
+ function F(t, e, n) {
39
+ let a = /* @__PURE__ */ new Set();
40
+ for (let o of t) {
41
+ if (a.has(o.id))
42
+ throw new Error(
43
+ `DatadogAppProvider received duplicate module "${o.id}".`
44
+ );
45
+ a.add(o.id);
46
+ }
47
+ let d = Object.freeze({
48
+ embedding: e,
49
+ disposeSignal: n
50
+ });
51
+ for (let o of t)
52
+ try {
53
+ o[y].install(d);
54
+ } catch (i) {
55
+ k(o.id, i);
56
+ }
57
+ }
58
+
59
+ // src/deep-links/internal/protocol.ts
60
+ var S = u(), D = b(), P = f({
61
+ identifier: "datadog.deep-links",
62
+ version: 2,
63
+ fields: {
64
+ setDeepLinkState: h.readOnly({
65
+ inputs: {
66
+ search: S,
67
+ fragment: S
68
+ },
69
+ result: D
70
+ })
71
+ }
72
+ }), T = v(
73
+ u(),
74
+ u()
75
+ ), _ = f({
76
+ identifier: "datadog.deep-links",
77
+ version: 1,
78
+ fields: {
79
+ setDeepLinkVariables: h.readOnly({
80
+ inputs: {
81
+ variables: T,
82
+ fragment: S
83
+ },
84
+ result: D
85
+ })
86
+ }
87
+ });
88
+
89
+ // src/deep-links/react/module-install.ts
90
+ var C = Object.freeze({
91
+ search: "",
92
+ fragment: ""
93
+ });
94
+ function M() {
95
+ return typeof globalThis.location > "u" ? C : Object.freeze({
96
+ search: globalThis.location.search,
97
+ fragment: globalThis.location.hash
98
+ });
99
+ }
100
+ function x(t, e) {
101
+ console.error(`[datadog-apps:deep-links] ${t}`, e ?? "");
102
+ }
103
+ var r = null;
104
+ function l() {
105
+ m();
106
+ }
107
+ function E({
108
+ search: t,
109
+ fragment: e
110
+ }) {
111
+ return JSON.stringify([t, e]);
112
+ }
113
+ function m(t = !1) {
114
+ let e = r;
115
+ if (e === null)
116
+ return;
117
+ let n = M(), a = E(n);
118
+ !t && e.lastPublishedFingerprint === a || (e.lastPublishedFingerprint = a, R(n));
119
+ }
120
+ function R(t) {
121
+ let e = r?.publishers;
122
+ if (e === void 0)
123
+ return;
124
+ let n = e.values().next();
125
+ n.done === !1 && n.value(t);
126
+ }
127
+ function I(t) {
128
+ let e = r?.publishers;
129
+ if (e === void 0)
130
+ return !1;
131
+ let n = e.values().next();
132
+ return n.done === !1 && n.value === t;
133
+ }
134
+ function w(t) {
135
+ if (r !== null)
136
+ return r.publishers.add(t), r;
137
+ let e = globalThis.history, n = e.pushState, a = e.replaceState, d = /* @__PURE__ */ new Set([t]), o = () => {
138
+ m();
139
+ }, i = function(s, c, g) {
140
+ n.call(e, s, c, g), o();
141
+ }, p = function(s, c, g) {
142
+ a.call(e, s, c, g), o();
143
+ };
144
+ try {
145
+ e.pushState = i, e.replaceState = p, globalThis.addEventListener("popstate", l), globalThis.addEventListener("hashchange", l);
146
+ } catch (s) {
147
+ throw e.replaceState === p && (e.replaceState = a), e.pushState === i && (e.pushState = n), globalThis.removeEventListener("popstate", l), globalThis.removeEventListener("hashchange", l), s;
148
+ }
149
+ return r = {
150
+ pushState: i,
151
+ replaceState: p,
152
+ originalPushState: n,
153
+ originalReplaceState: a,
154
+ publishers: d,
155
+ lastPublishedFingerprint: null
156
+ }, r;
157
+ }
158
+ function z(t) {
159
+ let e = r;
160
+ if (e === null || (e.publishers.delete(t), e.publishers.size > 0))
161
+ return;
162
+ let n = globalThis.history;
163
+ n.pushState === e.pushState && (n.pushState = e.originalPushState), n.replaceState === e.replaceState && (n.replaceState = e.originalReplaceState), globalThis.removeEventListener("popstate", l), globalThis.removeEventListener("hashchange", l), r = null;
164
+ }
165
+ function L({
166
+ embedding: t,
167
+ disposeSignal: e
168
+ }) {
169
+ if (e.aborted)
170
+ return;
171
+ let n = t.getClaim(P), a = ({ search: i, fragment: p }) => {
172
+ let s = n.getSnapshot();
173
+ s.status === "ready" && s.fields.setDeepLinkState({ search: i, fragment: p }).catch(
174
+ (c) => x(
175
+ "The app URL state could not be synchronized to the embedding host.",
176
+ c
177
+ )
178
+ );
179
+ }, d = (i) => {
180
+ i.status === "ready" && I(a) && m(!0);
181
+ }, o = n.subscribe(() => {
182
+ d(n.getSnapshot());
183
+ });
184
+ try {
185
+ w(a);
186
+ } catch (i) {
187
+ throw o(), i;
188
+ }
189
+ d(n.getSnapshot()), e.addEventListener(
190
+ "abort",
191
+ () => {
192
+ o(), z(a);
193
+ },
194
+ { once: !0 }
195
+ );
196
+ }
197
+
198
+ // src/deep-links/react/index.ts
199
+ var O = Object.freeze({});
200
+ function J() {
201
+ return A(
202
+ "datadog.deep-links",
203
+ O,
204
+ {
205
+ install({
206
+ embedding: t,
207
+ disposeSignal: e
208
+ }) {
209
+ L({ embedding: t, disposeSignal: e });
210
+ }
211
+ }
212
+ );
213
+ }
214
+
215
+ export {
216
+ F as a,
217
+ J as b
218
+ };
219
+ //# sourceMappingURL=chunk-SSORLL57.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/embedding/react/config.ts", "../../../src/deep-links/internal/protocol.ts", "../../../src/deep-links/react/module-install.ts", "../../../src/deep-links/react/index.ts"],
4
4
  "sourcesContent": ["import type { AppEmbedding } from '../types';\n\nconst providerModuleImplementation: unique symbol = Symbol(\n 'DatadogAppProviderModule',\n);\n\nexport interface DatadogAppProviderModule<\n TId extends string = string,\n TConfig extends Readonly<Record<string, unknown>> = Readonly<\n Record<string, unknown>\n >,\n> {\n readonly id: TId;\n /** This module's readonly settings, as passed to its factory. */\n readonly config: TConfig;\n readonly [providerModuleImplementation]: DatadogAppProviderModuleImplementation;\n}\n\n/**\n * Everything a module receives when the provider installs it on a mount.\n *\n * Deliberately neutral plumbing, made only of things the provider already\n * owns: the shared embedding connection and this mount's dispose signal. The\n * core knows nothing else about modules -- no module-specific fields, and no\n * DOM knowledge at all.\n */\nexport interface DatadogAppProviderModuleHandle {\n /**\n * The embedding connection shared by every mount of this package. A\n * module claims its contracts and subscribes to claim stores from here.\n */\n readonly embedding: AppEmbedding;\n /**\n * Aborted when this mount unmounts, or when React re-runs the provider's\n * effects (StrictMode double-invokes them in development). Modules clean\n * up by listening for this signal.\n */\n readonly disposeSignal: AbortSignal;\n}\n\nexport interface DatadogAppProviderModuleImplementation {\n /**\n * Installs this module's capability for one provider mount.\n *\n * Synchronous: `install` returns once the module's synchronous setup is\n * done. A module owns any async work it starts and must end it when\n * `disposeSignal` aborts.\n *\n * Re-runnable: `install -> dispose -> install` on the same mount is legal\n * and does happen (StrictMode), so a module's install must work again\n * after its dispose path has run.\n */\n install(handle: DatadogAppProviderModuleHandle): undefined;\n}\n\n/** Creates one opaque, configured provider module for package capabilities. */\nexport function createDatadogAppProviderModule<\n const TId extends string,\n const TConfig extends Readonly<Record<string, unknown>>,\n>(\n id: TId,\n config: TConfig,\n implementation: DatadogAppProviderModuleImplementation,\n): DatadogAppProviderModule<TId, TConfig> {\n if (id.length === 0) {\n throw new Error('A Datadog App provider module requires an id.');\n }\n return Object.freeze({\n id,\n config: Object.freeze({ ...config }) as TConfig,\n [providerModuleImplementation]: implementation,\n });\n}\n\n/** Reports an isolated install failure. Guarded like the composite's warn():\n * a hostile console implementation must never break the isolation promise. */\nfunction reportInstallFailure(moduleId: string, error: unknown): void {\n try {\n console.error(\n `Installing the \"${moduleId}\" Datadog App provider module failed; the remaining modules and the app still run.`,\n error,\n );\n } catch {\n // Nothing more can be done here; the remaining modules still install.\n }\n}\n\n/**\n * Installs modules on one provider mount, in list order, and nothing more.\n *\n * Duplicate ids are a wiring bug, not a runtime condition: they throw before\n * anything is installed. Individual install failures are the opposite -- they\n * are isolated and reported, and the remaining modules still install. That\n * asymmetry is deliberate: duplicates mean the author wired the same\n * capability twice and must hear about it immediately, while a failing\n * default module must not take down the app or its sibling modules.\n */\nexport function installDatadogAppProviderModules(\n modules: readonly DatadogAppProviderModule[],\n embedding: AppEmbedding,\n disposeSignal: AbortSignal,\n): void {\n const moduleIds = new Set<string>();\n for (const module of modules) {\n if (moduleIds.has(module.id)) {\n throw new Error(\n `DatadogAppProvider received duplicate module \"${module.id}\".`,\n );\n }\n moduleIds.add(module.id);\n }\n const handle: DatadogAppProviderModuleHandle = Object.freeze({\n embedding,\n disposeSignal,\n });\n for (const module of modules) {\n try {\n module[providerModuleImplementation].install(handle);\n } catch (error: unknown) {\n reportInstallFailure(module.id, error);\n }\n }\n}\n", "import * as z from 'zod/mini';\n\nimport { defineContract, fn } from '../../embedding/contract';\nimport type {\n Contract,\n FunctionField,\n ValueSchema,\n} from '../../embedding/types';\n\nconst stringSchema: ValueSchema<string> = z.string();\nconst undefinedSchema: ValueSchema<undefined> = z.undefined();\n\n/**\n * A one-way mirror of the embedded app's query string and fragment. The host\n * stores the snapshot under `app-links-${id}` and seeds the iframe's starting\n * URL before first navigation. There is no host-to-app value field or ongoing\n * inbound synchronization.\n *\n * V2 carries `location.search` verbatim rather than a dictionary, preserving\n * repeated parameters, ordering, empty values, and encoding.\n */\nexport const datadogAppDeepLinksContract: Contract<{\n setDeepLinkState: FunctionField<\n Readonly<{\n search: ValueSchema<string>;\n fragment: ValueSchema<string>;\n }>,\n ValueSchema<undefined>\n >;\n}> = defineContract({\n identifier: 'datadog.deep-links',\n version: 2,\n fields: {\n setDeepLinkState: fn.readOnly({\n inputs: {\n search: stringSchema,\n fragment: stringSchema,\n },\n result: undefinedSchema,\n }),\n },\n});\n\nconst variablesSchema: ValueSchema<Readonly<Record<string, string>>> = z.record(\n z.string(),\n z.string(),\n);\n\n/** Retained for apps built with the original scalar-query guest runtime. */\nexport const datadogAppDeepLinksV1Contract: Contract<{\n setDeepLinkVariables: FunctionField<\n Readonly<{\n variables: ValueSchema<Readonly<Record<string, string>>>;\n fragment: ValueSchema<string>;\n }>,\n ValueSchema<undefined>\n >;\n}> = defineContract({\n identifier: 'datadog.deep-links',\n version: 1,\n fields: {\n setDeepLinkVariables: fn.readOnly({\n inputs: {\n variables: variablesSchema,\n fragment: stringSchema,\n },\n result: undefinedSchema,\n }),\n },\n});\n", "import type { AppEmbedding, ClaimState } from '../../embedding/types';\nimport { datadogAppDeepLinksContract } from '../internal/protocol';\n\ninterface AppLocationState {\n readonly search: string;\n readonly fragment: string;\n}\n\nconst EMPTY_LOCATION_STATE: AppLocationState = Object.freeze({\n search: '',\n fragment: '',\n});\n\n/**\n * There is no ambient `location` outside a browser (or this guest's iframe\n * realm), so reading it unconditionally would throw. Install only ever runs\n * from a provider effect in a browser, but a non-browser embedding\n * implementation is not forbidden from calling in, so the read stays guarded.\n */\nfunction currentLocationState(): AppLocationState {\n if (typeof globalThis.location === 'undefined') {\n return EMPTY_LOCATION_STATE;\n }\n return Object.freeze({\n search: globalThis.location.search,\n fragment: globalThis.location.hash,\n });\n}\n\nfunction reportDeepLinksError(message: string, error?: unknown): void {\n console.error(`[datadog-apps:deep-links] ${message}`, error ?? '');\n}\n\ntype Publish = (state: AppLocationState) => void;\n\n/**\n * Ref-counted, per-realm history patch. Sibling provider mounts share one\n * embedding connection but each installs this runtime; without coordination,\n * two patches would publish twice and an out-of-order unmount could restore\n * a stale method. One patch is installed on the first install and torn down\n * on the last dispose; every live install's publisher is kept in an ordered\n * set, so a navigation uses the first live claim and disposing that claim\n * falls back to the next remaining one rather than going silent.\n */\ninterface PatchState {\n readonly pushState: History['pushState'];\n readonly replaceState: History['replaceState'];\n readonly originalPushState: History['pushState'];\n readonly originalReplaceState: History['replaceState'];\n /** Live publishers in install order; the first is the active publisher. */\n readonly publishers: Set<Publish>;\n lastPublishedFingerprint: string | null;\n}\nlet patchState: PatchState | null = null;\n\n/**\n * One stable handler, registered once, that publishes through one claim.\n * Fragment-changing history traversal can emit both `popstate` and\n * `hashchange`; the shared location fingerprint suppresses the second event.\n */\nfunction onLocationChange(): void {\n publishCurrentLocation();\n}\n\nfunction locationStateFingerprint({\n search,\n fragment,\n}: AppLocationState): string {\n return JSON.stringify([search, fragment]);\n}\n\nfunction publishCurrentLocation(force = false): void {\n const state = patchState;\n if (state === null) {\n return;\n }\n const locationState = currentLocationState();\n const fingerprint = locationStateFingerprint(locationState);\n if (!force && state.lastPublishedFingerprint === fingerprint) {\n return;\n }\n state.lastPublishedFingerprint = fingerprint;\n publishToActivePublisher(locationState);\n}\n\n/**\n * Publish to the first live publisher only. Sibling provider mounts share\n * one embedding connection and therefore one claim store, so every live\n * publisher holds the same callable -- invoking more than one would publish\n * the same navigation twice. Deleting the active publisher (on its dispose)\n * lets `Set` iteration fall back to the next remaining one, so a navigation\n * is never dropped and never duplicated.\n */\nfunction publishToActivePublisher(state: AppLocationState): void {\n const publishers = patchState?.publishers;\n if (publishers === undefined) {\n return;\n }\n const next = publishers.values().next();\n if (next.done === false) {\n (next.value as Publish)(state);\n }\n}\n\n/**\n * True when `publish` is the active (first) live publisher. Used to gate the\n * per-install ready publication so a startup publication goes out once across\n * siblings, not once per sibling -- the same single-publisher rule the\n * singleton applies to navigation.\n */\nfunction isActivePublisher(publish: Publish): boolean {\n const publishers = patchState?.publishers;\n if (publishers === undefined) {\n return false;\n }\n const next = publishers.values().next();\n return next.done === false && next.value === publish;\n}\n\nfunction acquireHistoryPatch(publish: Publish): PatchState {\n if (patchState !== null) {\n patchState.publishers.add(publish);\n return patchState;\n }\n const history = globalThis.history;\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n const publishers = new Set<Publish>([publish]);\n const publishLocalState = (): void => {\n publishCurrentLocation();\n };\n const patchedPushState: History['pushState'] = function (\n data,\n unused,\n url,\n ): void {\n originalPushState.call(history, data, unused, url);\n publishLocalState();\n };\n const patchedReplaceState: History['replaceState'] = function (\n data,\n unused,\n url,\n ): void {\n originalReplaceState.call(history, data, unused, url);\n publishLocalState();\n };\n try {\n history.pushState = patchedPushState;\n history.replaceState = patchedReplaceState;\n globalThis.addEventListener('popstate', onLocationChange);\n globalThis.addEventListener('hashchange', onLocationChange);\n } catch (error) {\n // Acquisition is all-or-nothing. If a hardened realm rejects one of\n // the method assignments after the other succeeded, restore whatever\n // this attempt installed before surfacing the failure.\n if (history.replaceState === patchedReplaceState) {\n history.replaceState = originalReplaceState;\n }\n if (history.pushState === patchedPushState) {\n history.pushState = originalPushState;\n }\n globalThis.removeEventListener('popstate', onLocationChange);\n globalThis.removeEventListener('hashchange', onLocationChange);\n throw error;\n }\n patchState = {\n pushState: patchedPushState,\n replaceState: patchedReplaceState,\n originalPushState,\n originalReplaceState,\n publishers,\n lastPublishedFingerprint: null,\n };\n return patchState;\n}\n\nfunction releaseHistoryPatch(publish: Publish): void {\n const state = patchState;\n if (state === null) {\n return;\n }\n state.publishers.delete(publish);\n if (state.publishers.size > 0) {\n return;\n }\n const history = globalThis.history;\n // Restore only our own still-installed methods: an out-of-order dispose\n // of a sibling that patched later would have overwritten these, and\n // blindly restoring the originals would drop that sibling's patch. The\n // identity check guarantees we only undo our own installation.\n if (history.pushState === state.pushState) {\n history.pushState = state.originalPushState;\n }\n if (history.replaceState === state.replaceState) {\n history.replaceState = state.originalReplaceState;\n }\n globalThis.removeEventListener('popstate', onLocationChange);\n globalThis.removeEventListener('hashchange', onLocationChange);\n patchState = null;\n}\n\nexport interface InstallDatadogAppDeepLinksOptions {\n /** The embedding connection shared by every mount of this package. */\n readonly embedding: AppEmbedding;\n /** Aborted when this mount disposes; all cleanup keys off it. */\n readonly disposeSignal: AbortSignal;\n}\n\n/**\n * Installs the deep-links guest runtime for one provider mount.\n *\n * A one-way mirror the app drives onto the host page URL. The app owns its\n * query string and fragment; this runtime watches them -- patching `history`\n * once per realm and listening for `popstate` and `hashchange` -- and, whenever\n * they change, calls the host's `setDeepLinkState` with the current\n * snapshot. On each transition of the deep-links claim to `ready`, including\n * after an embedding reconnect, it publishes the current snapshot immediately.\n * The host's outer URL therefore reflects the app's state even before the app\n * navigates. There is no inbound apply and no remembered baseline: the host\n * seeded the iframe's starting URL before first navigation, and after that the\n * app's URL is its own state -- this runtime only reports it outward.\n *\n * When the claim is not `ready` (no host-side deep-links counterpart, or the\n * handshake still in flight) publishing is a no-op, so a default install is\n * inert rather than broken. Re-runnable: `install -> dispose -> install` on\n * the same mount is legal (StrictMode double-invokes provider effects), so\n * the patch acquisition, claim subscription, and abort listener all clean up\n * on `disposeSignal` and tolerate a second install.\n */\nexport function installDatadogAppDeepLinks({\n embedding,\n disposeSignal,\n}: InstallDatadogAppDeepLinksOptions): void {\n if (disposeSignal.aborted) {\n return;\n }\n\n const store = embedding.getClaim(datadogAppDeepLinksContract);\n\n const publish: Publish = ({ search, fragment }) => {\n const claim = store.getSnapshot();\n if (claim.status !== 'ready') {\n return;\n }\n claim.fields\n .setDeepLinkState({ search, fragment })\n .catch((error: unknown) =>\n reportDeepLinksError(\n 'The app URL state could not be synchronized to the embedding host.',\n error,\n ),\n );\n };\n\n // Publish the current snapshot on each transition of the claim to\n // `ready`. A reconnect produces a fresh claim (new callable), so\n // publishing per-ready (rather than once per install) keeps the host in\n // sync after a reconnect and reconciles the one-shot overlay with the\n // app's effective URL even when it never navigates. An unseeded app also\n // publishes any authored params so the outer URL gains a shareable link.\n const publishIfReady = (\n claim: ClaimState<typeof datadogAppDeepLinksContract>,\n ): void => {\n if (claim.status === 'ready' && isActivePublisher(publish)) {\n // Force each ready transition through even when its URL state is\n // unchanged: a reconnect supplies a fresh host callable that has\n // not received the current snapshot yet.\n publishCurrentLocation(true);\n }\n };\n const unsubscribe = store.subscribe(() => {\n publishIfReady(store.getSnapshot());\n });\n\n try {\n acquireHistoryPatch(publish);\n } catch (error) {\n unsubscribe();\n throw error;\n }\n\n // The claim may already be `ready` when this install runs (a sibling\n // mount claimed the same contract, or a reconnect raced the install\n // effect), so check once up front in addition to listening for changes.\n publishIfReady(store.getSnapshot());\n\n disposeSignal.addEventListener(\n 'abort',\n () => {\n unsubscribe();\n releaseHistoryPatch(publish);\n },\n { once: true },\n );\n}\n", "/**\n * The npm-facing React entry point for deep links. The provider module is a\n * startup capability: the provider installs it by id and knows nothing about\n * what it does. Nothing is rendered on the module's behalf -- the guest\n * runtime is framework-neutral install code over the shared embedding\n * connection.\n */\nimport { createDatadogAppProviderModule } from '../../embedding/react/config';\nimport type {\n DatadogAppProviderModule,\n DatadogAppProviderModuleHandle,\n} from '../../embedding/react/config';\n\nimport { installDatadogAppDeepLinks } from './module-install';\n\n/** Deep links take no module configuration today. */\nexport type DatadogAppDeepLinksConfig = Readonly<Record<string, never>>;\n\nexport type DatadogAppDeepLinksProviderModule = DatadogAppProviderModule<\n 'datadog.deep-links',\n DatadogAppDeepLinksConfig\n>;\n\nconst EMPTY_DEEP_LINKS_CONFIG: DatadogAppDeepLinksConfig = Object.freeze({});\n\n/**\n * Starts deep links with the provider. Installing this module mirrors the\n * app's query and fragment state onto the embedding host's page URL (under\n * the host's opaque id), so an app's navigations become shareable links. App\n * authors pass it through the composite provider's `modules` list (or get it\n * as a default); with no host-side deep-links counterpart the claim stays\n * pending and the module is inert.\n */\nexport function datadogAppDeepLinks(): DatadogAppDeepLinksProviderModule {\n return createDatadogAppProviderModule(\n 'datadog.deep-links',\n EMPTY_DEEP_LINKS_CONFIG,\n {\n install({\n embedding,\n disposeSignal,\n }: DatadogAppProviderModuleHandle): undefined {\n installDatadogAppDeepLinks({ embedding, disposeSignal });\n },\n },\n );\n}\n"],
5
- "mappings": "qGAEA,IAAMA,EAA8C,OAChD,0BACJ,EAoDO,SAASC,EAIZC,EACAC,EACAC,EACsC,CACtC,GAAIF,EAAG,SAAW,EACd,MAAM,IAAI,MAAM,+CAA+C,EAEnE,OAAO,OAAO,OAAO,CACjB,GAAAA,EACA,OAAQ,OAAO,OAAO,CAAE,GAAGC,CAAO,CAAC,EACnC,CAACH,CAA4B,EAAGI,CACpC,CAAC,CACL,CAIA,SAASC,EAAqBC,EAAkBC,EAAsB,CAClE,GAAI,CACA,QAAQ,MACJ,mBAAmBD,CAAQ,qFAC3BC,CACJ,CACJ,MAAQ,CAER,CACJ,CAYO,SAASC,EACZC,EACAC,EACAC,EACI,CACJ,IAAMC,EAAY,IAAI,IACtB,QAAWC,KAAUJ,EAAS,CAC1B,GAAIG,EAAU,IAAIC,EAAO,EAAE,EACvB,MAAM,IAAI,MACN,iDAAiDA,EAAO,EAAE,IAC9D,EAEJD,EAAU,IAAIC,EAAO,EAAE,CAC3B,CACA,IAAMC,EAAyC,OAAO,OAAO,CACzD,UAAAJ,EACA,cAAAC,CACJ,CAAC,EACD,QAAWE,KAAUJ,EACjB,GAAI,CACAI,EAAOb,CAA4B,EAAE,QAAQc,CAAM,CACvD,OAASP,EAAgB,CACrBF,EAAqBQ,EAAO,GAAIN,CAAK,CACzC,CAER,CCjHA,IAAMQ,EAAsCC,EAAO,EAC7CC,EAA4CC,EAAU,EAW/CC,EAQRC,EAAe,CAChB,WAAY,qBACZ,QAAS,EACT,OAAQ,CACJ,iBAAkBC,EAAG,SAAS,CAC1B,OAAQ,CACJ,OAAQN,EACR,SAAUA,CACd,E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;AAUpE,SAASC,IAAyD;AACrE,SAAOC;AAAA,IACH;AAAA,IACAF;AAAA,IACA;AAAA,MACI,QAAQ;AAAA,QACJ,WAAAG;AAAA,QACA,eAAAC;AAAA,MACJ,GAA8C;AAC1C,QAAAC,EAA2B,EAAE,WAAAF,GAAW,eAAAC,EAAc,CAAC;AAAA,MAC3D;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": ["providerModuleImplementation", "createDatadogAppProviderModule", "id", "config", "implementation", "reportInstallFailure", "moduleId", "error", "installDatadogAppProviderModules", "modules", "embedding", "disposeSignal", "moduleIds", "module", "handle", "stringSchema", "string", "undefinedSchema", "_undefined", "datadogAppDeepLinksContract", "defineContract", "fn", "variablesSchema", "record", "datadogAppDeepLinksV1Contract", "EMPTY_LOCATION_STATE", "currentLocationState", "reportDeepLinksError", "message", "error", "patchState", "onLocationChange", "publishCurrentLocation", "locationStateFingerprint", "search", "fragment", "force", "state", "locationState", "fingerprint", "publishToActivePublisher", "publishers", "next", "isActivePublisher", "publish", "acquireHistoryPatch", "history", "originalPushState", "originalReplaceState", "publishLocalState", "patchedPushState", "data", "unused", "url", "patchedReplaceState", "releaseHistoryPatch", "installDatadogAppDeepLinks", "embedding", "disposeSignal", "store", "datadogAppDeepLinksContract", "claim", "publishIfReady", "unsubscribe", "EMPTY_DEEP_LINKS_CONFIG", "datadogAppDeepLinks", "createDatadogAppProviderModule", "embedding", "disposeSignal", "installDatadogAppDeepLinks"]
7
7
  }
@@ -0,0 +1,54 @@
1
+ /* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0.
2
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ * Copyright 2019-Present Datadog, Inc.
4
+ */
5
+
6
+ // src/embedding/react/start-lease.ts
7
+ var n = /* @__PURE__ */ new WeakMap(), o = 3e4;
8
+ function l(e) {
9
+ let t = n.get(e);
10
+ if (t)
11
+ return t.cleanupTimer !== void 0 && (globalThis.clearTimeout(t.cleanupTimer), t.cleanupTimer = void 0), t;
12
+ let r = { release: e.start() };
13
+ return n.set(e, r), r;
14
+ }
15
+ function p(e) {
16
+ let t = n.get(e);
17
+ return t ? (n.delete(e), t.cleanupTimer !== void 0 && globalThis.clearTimeout(t.cleanupTimer), t.release) : e.start();
18
+ }
19
+ function c(e, t) {
20
+ n.get(e) !== t || t.cleanupTimer !== void 0 || (t.cleanupTimer = globalThis.setTimeout(() => {
21
+ n.get(e) === t && (n.delete(e), t.release());
22
+ }, o));
23
+ }
24
+
25
+ // src/embedding/react/context.ts
26
+ import { createContext as a, createElement as s, useContext as u, useEffect as d } from "react";
27
+ var i = a(null);
28
+ function g(e) {
29
+ return function({
30
+ children: r
31
+ }) {
32
+ return d(() => p(e), []), s(
33
+ i.Provider,
34
+ { value: e },
35
+ r
36
+ );
37
+ };
38
+ }
39
+ function A() {
40
+ let e = u(i);
41
+ if (!e)
42
+ throw new Error(
43
+ "Datadog App hooks must be used within DatadogAppProvider."
44
+ );
45
+ return e;
46
+ }
47
+
48
+ export {
49
+ l as a,
50
+ c as b,
51
+ g as c,
52
+ A as d
53
+ };
54
+ //# sourceMappingURL=chunk-VSZMABRM.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/embedding/react/start-lease.ts", "../../../src/embedding/react/context.ts"],
4
4
  "sourcesContent": ["import type { AppEmbedding, Unsubscribe } from '../types';\n\ninterface SuspenseStartLease {\n readonly release: Unsubscribe;\n cleanupTimer?: ReturnType<typeof globalThis.setTimeout>;\n}\n\nconst suspenseStartLeases = new WeakMap<AppEmbedding, SuspenseStartLease>();\nconst UNADOPTED_LEASE_GRACE_MS = 30_000;\n\n/** Starts an embedding while a descendant is suspended before effects commit. */\nexport function startAppEmbeddingForSuspense(\n embedding: AppEmbedding,\n): SuspenseStartLease {\n const existing = suspenseStartLeases.get(embedding);\n if (existing) {\n if (existing.cleanupTimer !== undefined) {\n globalThis.clearTimeout(existing.cleanupTimer);\n existing.cleanupTimer = undefined;\n }\n return existing;\n }\n\n const created = { release: embedding.start() };\n suspenseStartLeases.set(embedding, created);\n return created;\n}\n\n/** Gives the provider ownership of a render-time lease, or starts a new one. */\nexport function acquireAppEmbeddingLease(embedding: AppEmbedding): Unsubscribe {\n const suspenseLease = suspenseStartLeases.get(embedding);\n if (!suspenseLease) {\n return embedding.start();\n }\n\n suspenseStartLeases.delete(embedding);\n if (suspenseLease.cleanupTimer !== undefined) {\n globalThis.clearTimeout(suspenseLease.cleanupTimer);\n }\n return suspenseLease.release;\n}\n\n/** Releases a settled render-time lease if its provider was abandoned. */\nexport function scheduleUnadoptedLeaseCleanup(\n embedding: AppEmbedding,\n suspenseLease: SuspenseStartLease,\n): void {\n if (\n suspenseStartLeases.get(embedding) !== suspenseLease ||\n suspenseLease.cleanupTimer !== undefined\n ) {\n return;\n }\n\n suspenseLease.cleanupTimer = globalThis.setTimeout(() => {\n if (suspenseStartLeases.get(embedding) === suspenseLease) {\n suspenseStartLeases.delete(embedding);\n suspenseLease.release();\n }\n }, UNADOPTED_LEASE_GRACE_MS);\n}\n", "import { createContext, createElement, useContext, useEffect } from 'react';\nimport type {\n ComponentType,\n Context,\n PropsWithChildren,\n ReactElement,\n} from 'react';\n\nimport type { AppEmbedding } from '../types';\n\nimport { acquireAppEmbeddingLease } from './start-lease';\n\nconst appEmbeddingContext: Context<AppEmbedding | null> =\n createContext<AppEmbedding | null>(null);\n\nexport function createDatadogAppProvider(\n embedding: AppEmbedding,\n): ComponentType<PropsWithChildren> {\n return function DatadogAppProvider({\n children,\n }: PropsWithChildren): ReactElement {\n // `embedding` is captured from the factory, not a prop, so it is fixed\n // for the lifetime of this component type. The empty dependency list is\n // deliberate: the connection must start once per mount and tear down on\n // unmount, never restart mid-life.\n useEffect(() => acquireAppEmbeddingLease(embedding), []);\n return createElement(\n appEmbeddingContext.Provider,\n { value: embedding },\n children,\n );\n };\n}\n\nexport function useAppEmbedding(): AppEmbedding {\n const embedding = useContext(appEmbeddingContext);\n if (!embedding) {\n throw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AAI,CAACG;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAEJ,SAAOA;AACX;",
6
6
  "names": ["suspenseStartLeases", "UNADOPTED_LEASE_GRACE_MS", "startAppEmbeddingForSuspense", "embedding", "existing", "created", "acquireAppEmbeddingLease", "suspenseLease", "scheduleUnadoptedLeaseCleanup", "createContext", "createElement", "useContext", "useEffect", "appEmbeddingContext", "createContext", "createDatadogAppProvider", "embedding", "children", "useEffect", "acquireAppEmbeddingLease", "createElement", "useAppEmbedding", "useContext"]
7
7
  }
@@ -3,5 +3,12 @@
3
3
  * Copyright 2019-Present Datadog, Inc.
4
4
  */
5
5
 
6
- import{b as a}from"../../_chunks/chunk-D43RPVCF.js";import"../../_chunks/chunk-EYBITW7J.js";import"../../_chunks/chunk-LEEYMNMO.js";export{a as datadogAppDeepLinks};
6
+ import {
7
+ b as a
8
+ } from "../../_chunks/chunk-SSORLL57.js";
9
+ import "../../_chunks/chunk-ONCDAC2F.js";
10
+ import "../../_chunks/chunk-E6L6DSL7.js";
11
+ export {
12
+ a as datadogAppDeepLinks
13
+ };
7
14
  //# sourceMappingURL=index.js.map
@@ -3,5 +3,29 @@
3
3
  * Copyright 2019-Present Datadog, Inc.
4
4
  */
5
5
 
6
- import{a as r}from"../../_chunks/chunk-XSHCFEOH.js";import"../../_chunks/chunk-2V2HASKF.js";import{a as t}from"../../_chunks/chunk-DETZPDFA.js";import"../../_chunks/chunk-EYBITW7J.js";import"../../_chunks/chunk-OEPH347K.js";import"../../_chunks/chunk-LEEYMNMO.js";import{DruidsEnvironment as i}from"@datadog/druids/layout/DruidsEnvironment";import{createElement as s}from"react";function u(n){let{defaultThemePreference:m,...o}=n,e=r(t),p=e.status==="ready"?e.fields.theme:m;return s(i,{...o,defaultThemePreference:p})}export{u as DruidsEnvironmentWithThemeInput};
6
+ import {
7
+ a as r
8
+ } from "../../_chunks/chunk-OF23NNWB.js";
9
+ import "../../_chunks/chunk-VSZMABRM.js";
10
+ import {
11
+ a as t
12
+ } from "../../_chunks/chunk-64RLSXHA.js";
13
+ import "../../_chunks/chunk-ONCDAC2F.js";
14
+ import "../../_chunks/chunk-BWBMAWDD.js";
15
+ import "../../_chunks/chunk-E6L6DSL7.js";
16
+
17
+ // src/druids/react/druids-environment-with-theme-input.ts
18
+ import { DruidsEnvironment as i } from "@datadog/druids/layout/DruidsEnvironment";
19
+ import { createElement as s } from "react";
20
+ function u(n) {
21
+ let { defaultThemePreference: m, ...o } = n, e = r(t), p = e.status === "ready" ? e.fields.theme : m;
22
+ return s(i, {
23
+ ...o,
24
+ // `preference` is `'light' | 'dark'`; only the enum wrapper differs.
25
+ defaultThemePreference: p
26
+ });
27
+ }
28
+ export {
29
+ u as DruidsEnvironmentWithThemeInput
30
+ };
7
31
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/druids/react/druids-environment-with-theme-input.ts"],
4
4
  "sourcesContent": ["import { DruidsEnvironment } from '@datadog/druids/layout/DruidsEnvironment';\nimport { createElement } from 'react';\nimport type { ComponentProps, ReactElement } from 'react';\n\nimport { useDatadogAppInput } from '../../inputs/react/index';\nimport { datadogTheme } from '../../inputs/schemas/index';\nimport type { DatadogAppTheme } from '../../inputs/schemas/index';\n\ntype DruidsEnvironmentProps = ComponentProps<typeof DruidsEnvironment>;\n\n/**\n * `SavedThemes` is the type `DruidsEnvironment` expects for its preference\n * props, but `@datadog/druids` does not export it. Recover it structurally --\n * its runtime values are exactly `'light' | 'dark' | 'system'`, so accepting\n * the cast below is only teaching the compiler that correspondence.\n */\ntype DruidsThemePreference = DruidsEnvironmentProps['defaultThemePreference'];\n\n/**\n * Everything {@link DruidsEnvironment} accepts, except the two\n * theme-preference props this component owns: the initial preference arrives\n * as a plain `'light' | 'dark'` and the live one comes from the\n * `datadog.theme` input, so neither can be forwarded by callers.\n */\nexport type DruidsEnvironmentWithThemeInputProps = Omit<\n DruidsEnvironmentProps,\n 'defaultThemePreference' | 'fallbackThemePreference'\n> & {\n /**\n * Theme rendered until the `datadog.theme` input claims -- and whenever it\n * cannot (the claim is pending, the host offers no such input, or the\n * claim failed). The host's live theme replaces it the moment it arrives.\n */\n defaultThemePreference: DatadogAppTheme;\n};\n\n/**\n * `DruidsEnvironment` driven by the host's live `datadog.theme` input.\n *\n * A drop-in for `@datadog/druids/layout/DruidsEnvironment`: every other prop\n * is forwarded unchanged. The first render applies `defaultThemePreference`,\n * and as soon as the `datadog.theme` input claims, the host's actual theme\n * takes over and live-updates whenever the user switches it. Until then --\n * and whenever the input never resolves -- your initial preference stays\n * applied. That keeps the app deterministic instead of falling back to\n * DRUIDS' own cookie and iframe detection, which forces light mode inside the\n * iframe every Datadog App runs in, and means the worst case is a brief\n * initial paint in your default theme.\n *\n * Must be rendered below `DatadogAppProvider`\n * (`@datadog/apps-frontend/embedding/react`), like every Datadog App hook.\n *\n * To opt out of the input -- for example to keep DRUIDS' own cookie-based\n * preference handling -- render `DruidsEnvironment` directly instead. This\n * subpath is the only entry that requires `@datadog/druids` (an optional peer\n * dependency): apps that do not import it do not bundle DRUIDS.\n */\nexport function DruidsEnvironmentWithThemeInput(\n props: DruidsEnvironmentWithThemeInputProps,\n): ReactElement {\n const { defaultThemePreference, ...druidsEnvironmentProps } = props;\n const themeInput = useDatadogAppInput(datadogTheme);\n const preference: DatadogAppTheme =\n themeInput.status === 'ready'\n ? themeInput.fields.theme\n : defaultThemePreference;\n\n return createElement(DruidsEnvironment, {\n ...druidsEnvironmentProps,\n // `preference` is `'light' | 'dark'`; only the enum wrapper differs.\n defaultThemePreference: preference as DruidsThemePreference,\n });\n}\n"],
5
- "mappings": "wQAAA,OAAS,qBAAAA,MAAyB,2CAClC,OAAS,iBAAAC,MAAqB,QAwDvB,SAASC,EACZC,EACY,CACZ,GAAM,CAAE,uBAAAC,EAAwB,GAAGC,CAAuB,EAAIF,EACxDG,EAAaC,EAAmBC,CAAY,EAC5CC,EACFH,EAAW,SAAW,QAChBA,EAAW,OAAO,MAClBF,EAEV,OAAOM,EAAcC,EAAmB,CACpC,GAAGN,EAEH,uBAAwBI,CAC5B,CAAC,CACL",
5
+ "mappings": ";;;;;;;;;;;;AAAA,SAAS,qBAAAA,SAAyB;AAClC,SAAS,iBAAAC,SAAqB;AAwDvB,SAASC,EACZC,GACY;AACZ,MAAM,EAAE,wBAAAC,GAAwB,GAAGC,EAAuB,IAAIF,GACxDG,IAAaC,EAAmBC,CAAY,GAC5CC,IACFH,EAAW,WAAW,UAChBA,EAAW,OAAO,QAClBF;AAEV,SAAOM,EAAcC,GAAmB;AAAA,IACpC,GAAGN;AAAA;AAAA,IAEH,wBAAwBI;AAAA,EAC5B,CAAC;AACL;",
6
6
  "names": ["DruidsEnvironment", "createElement", "DruidsEnvironmentWithThemeInput", "props", "defaultThemePreference", "druidsEnvironmentProps", "themeInput", "useDatadogAppInput", "datadogTheme", "preference", "createElement", "DruidsEnvironment"]
7
7
  }