@preprio/toolkit 0.5.0-rc.1 → 0.6.0-alpha.0
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.
- package/README.md +300 -19
- package/dist/astro/chunk-3UVUDDNY.js +173 -0
- package/dist/astro/graphql.cjs +983 -0
- package/dist/astro/graphql.d.cts +231 -0
- package/dist/astro/graphql.d.ts +231 -0
- package/dist/astro/graphql.js +893 -0
- package/dist/astro/index-XT_z-RYT.d.cts +130 -0
- package/dist/astro/index-XT_z-RYT.d.ts +130 -0
- package/dist/astro/index.cjs +14 -1
- package/dist/astro/index.d.cts +1 -120
- package/dist/astro/index.d.ts +1 -120
- package/dist/astro/index.js +15 -153
- package/dist/{chunk-4JNKYIEV.js → chunk-BJ2LBLWO.js} +69 -268
- package/dist/chunk-DGZA7KX7.js +172 -0
- package/dist/chunk-YR7P4IWE.js +187 -0
- package/dist/graphql.cjs +894 -0
- package/dist/graphql.d.cts +231 -0
- package/dist/graphql.d.ts +231 -0
- package/dist/graphql.js +787 -0
- package/dist/index.cjs +74 -111
- package/dist/index.d.cts +11 -62
- package/dist/index.d.ts +11 -62
- package/dist/index.js +23 -167
- package/dist/nextjs/chunk-U4HXENF7.js +231 -0
- package/dist/nextjs/components.cjs +188 -114
- package/dist/nextjs/components.d.cts +33 -2
- package/dist/nextjs/components.d.ts +33 -2
- package/dist/nextjs/components.js +132 -4
- package/dist/nextjs/graphql.cjs +1315 -0
- package/dist/nextjs/graphql.d.cts +361 -0
- package/dist/nextjs/graphql.d.ts +361 -0
- package/dist/nextjs/graphql.js +1218 -0
- package/dist/nextjs/index.cjs +126 -6
- package/dist/nextjs/index.d.cts +53 -141
- package/dist/nextjs/index.d.ts +53 -141
- package/dist/nextjs/index.js +113 -203
- package/dist/nextjs/server-CjpELYvq.d.cts +156 -0
- package/dist/nextjs/server-CjpELYvq.d.ts +156 -0
- package/dist/nuxt/chunk-P6ENNAEE.js +417 -0
- package/dist/nuxt/graphql.cjs +990 -0
- package/dist/nuxt/graphql.d.cts +228 -0
- package/dist/nuxt/graphql.d.ts +228 -0
- package/dist/nuxt/graphql.js +894 -0
- package/dist/nuxt/index.cjs +14 -1
- package/dist/nuxt/index.d.cts +3 -148
- package/dist/nuxt/index.d.ts +3 -148
- package/dist/nuxt/index.js +15 -391
- package/dist/nuxt/server-8v6OHbsw.d.cts +158 -0
- package/dist/nuxt/server-8v6OHbsw.d.ts +158 -0
- package/dist/pixel-DwW7cXJm.d.cts +49 -0
- package/dist/pixel-DwW7cXJm.d.ts +49 -0
- package/dist/react/components.cjs +86 -112
- package/dist/react/components.js +86 -112
- package/dist/server-Brr1UgtW.d.ts +59 -0
- package/dist/server-DJuS3YU0.d.cts +59 -0
- package/dist/sveltekit/chunk-FSARVMG5.js +413 -0
- package/dist/sveltekit/graphql.cjs +996 -0
- package/dist/sveltekit/graphql.d.cts +233 -0
- package/dist/sveltekit/graphql.d.ts +233 -0
- package/dist/sveltekit/graphql.js +900 -0
- package/dist/sveltekit/index.cjs +14 -1
- package/dist/sveltekit/index.d.cts +3 -88
- package/dist/sveltekit/index.d.ts +3 -88
- package/dist/sveltekit/index.js +15 -387
- package/dist/sveltekit/server-CO847mEV.d.cts +98 -0
- package/dist/sveltekit/server-CO847mEV.d.ts +98 -0
- package/dist/{pixel-e1fUWl2Y.d.cts → types-BYH9XqmN.d.cts} +2 -50
- package/dist/{pixel-e1fUWl2Y.d.ts → types-BYH9XqmN.d.ts} +2 -50
- package/package.json +31 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
interface PreprSegment {
|
|
2
|
+
readonly _id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
|
|
7
|
+
* form leaves room for per-feature options later without a breaking change.
|
|
8
|
+
*/
|
|
9
|
+
type PreprFeatureConfig = boolean | {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
|
|
13
|
+
interface PreprFeatures {
|
|
14
|
+
/** Segment picker, `Prepr-Segments` header and its cookie/query param. */
|
|
15
|
+
segments?: PreprFeatureConfig;
|
|
16
|
+
/** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
|
|
17
|
+
abTesting?: PreprFeatureConfig;
|
|
18
|
+
/**
|
|
19
|
+
* The site's own click-to-edit: the toolbar's Edit mode control, the stega
|
|
20
|
+
* tooltip/overlay and the close-edit pill.
|
|
21
|
+
*
|
|
22
|
+
* NOT a security control, and NOT the Prepr editor's live preview. When the
|
|
23
|
+
* site is framed by the editor, `prepr:initVE` still activates edit mode —
|
|
24
|
+
* that is the CMS operating inside its own iframe, not an affordance offered
|
|
25
|
+
* to visitors. See iframe-bridge.ts.
|
|
26
|
+
*/
|
|
27
|
+
editMode?: PreprFeatureConfig;
|
|
28
|
+
}
|
|
29
|
+
interface PreprToolbarProps {
|
|
30
|
+
/**
|
|
31
|
+
* Server-resolved active segment. Optional: omit it with `segments`
|
|
32
|
+
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
33
|
+
* the persisted cookie is used.
|
|
34
|
+
*/
|
|
35
|
+
readonly activeSegment?: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Server-resolved active A/B variant. Optional: omit it with `abTesting`
|
|
38
|
+
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
39
|
+
* the persisted cookie is used.
|
|
40
|
+
*/
|
|
41
|
+
readonly activeVariant?: string | null;
|
|
42
|
+
/** Available segments to personalize on. */
|
|
43
|
+
readonly segments?: readonly PreprSegment[];
|
|
44
|
+
/** @deprecated Alias for `segments`. */
|
|
45
|
+
readonly data?: readonly PreprSegment[];
|
|
46
|
+
}
|
|
47
|
+
type PreprVariant = 'A' | 'B';
|
|
48
|
+
interface PreprHeaders {
|
|
49
|
+
readonly 'prepr-customer-id'?: string;
|
|
50
|
+
readonly 'Prepr-Segments'?: string;
|
|
51
|
+
readonly 'Prepr-ABtesting'?: PreprVariant;
|
|
52
|
+
readonly 'Prepr-Preview-Bar'?: 'true';
|
|
53
|
+
readonly 'Prepr-Context-utm_source'?: string;
|
|
54
|
+
readonly 'Prepr-Context-utm_medium'?: string;
|
|
55
|
+
readonly 'Prepr-Context-utm_term'?: string;
|
|
56
|
+
readonly 'Prepr-Context-utm_content'?: string;
|
|
57
|
+
readonly 'Prepr-Context-utm_campaign'?: string;
|
|
58
|
+
readonly 'Prepr-Context-initial_referral'?: string;
|
|
59
|
+
readonly 'Prepr-Visitor-IP'?: string;
|
|
60
|
+
readonly 'Prepr-Hubspot-Id'?: string;
|
|
61
|
+
readonly 'Prepr-Customer-Id-Created'?: 'true';
|
|
62
|
+
/** The visitor's browser User-Agent, used by the API for device detection. */
|
|
63
|
+
readonly 'User-Agent'?: string;
|
|
64
|
+
/** @deprecated Never populated; the visitor's value is under `User-Agent`. */
|
|
65
|
+
readonly 'Prepr-User-Agent'?: string;
|
|
66
|
+
readonly 'Prepr-Package'?: string;
|
|
67
|
+
}
|
|
68
|
+
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR' | 'GRAPHQL_ERROR' | 'INVALID_DOCUMENT';
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether a Prepr GraphQL response differs per visitor, read from its `Vary`
|
|
72
|
+
* header. Use it when fetching with your own GraphQL client; the toolkit's
|
|
73
|
+
* `createPreprClient` already returns it as `personalized`.
|
|
74
|
+
*
|
|
75
|
+
* Never throws; a response without `Vary` is not personalized.
|
|
76
|
+
*/
|
|
77
|
+
declare function isPersonalizedResponse(source: Response | Headers): boolean;
|
|
78
|
+
|
|
79
|
+
/** Error thrown by the token helpers and the segments fetch. */
|
|
80
|
+
declare class PreprError extends Error {
|
|
81
|
+
readonly code: PreprErrorCode;
|
|
82
|
+
readonly context?: string | undefined;
|
|
83
|
+
readonly originalError?: Error | undefined;
|
|
84
|
+
constructor(message: string, code: PreprErrorCode, context?: string | undefined, originalError?: Error | undefined);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Asserts `token` is the full `https://graphql.prepr.io/<token>` URL.
|
|
88
|
+
* @throws PreprError if the token is missing or not an HTTPS URL.
|
|
89
|
+
*/
|
|
90
|
+
declare function validatePreprToken(token: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Pulls the access token out of a GraphQL URL: `https://graphql.prepr.io/abc123`
|
|
93
|
+
* -> `abc123`.
|
|
94
|
+
* @throws PreprError if the URL is not a valid `graphql.prepr.io` URL.
|
|
95
|
+
*/
|
|
96
|
+
declare function extractAccessToken(graphqlUrl: string): string;
|
|
97
|
+
|
|
98
|
+
export { type PreprHeaders as P, PreprError as a, type PreprFeatures as b, type PreprToolbarProps as c, extractAccessToken as e, isPersonalizedResponse as i, validatePreprToken as v };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
interface PreprSegment {
|
|
2
|
+
readonly _id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
|
|
7
|
+
* form leaves room for per-feature options later without a breaking change.
|
|
8
|
+
*/
|
|
9
|
+
type PreprFeatureConfig = boolean | {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
|
|
13
|
+
interface PreprFeatures {
|
|
14
|
+
/** Segment picker, `Prepr-Segments` header and its cookie/query param. */
|
|
15
|
+
segments?: PreprFeatureConfig;
|
|
16
|
+
/** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
|
|
17
|
+
abTesting?: PreprFeatureConfig;
|
|
18
|
+
/**
|
|
19
|
+
* The site's own click-to-edit: the toolbar's Edit mode control, the stega
|
|
20
|
+
* tooltip/overlay and the close-edit pill.
|
|
21
|
+
*
|
|
22
|
+
* NOT a security control, and NOT the Prepr editor's live preview. When the
|
|
23
|
+
* site is framed by the editor, `prepr:initVE` still activates edit mode —
|
|
24
|
+
* that is the CMS operating inside its own iframe, not an affordance offered
|
|
25
|
+
* to visitors. See iframe-bridge.ts.
|
|
26
|
+
*/
|
|
27
|
+
editMode?: PreprFeatureConfig;
|
|
28
|
+
}
|
|
29
|
+
interface PreprToolbarProps {
|
|
30
|
+
/**
|
|
31
|
+
* Server-resolved active segment. Optional: omit it with `segments`
|
|
32
|
+
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
33
|
+
* the persisted cookie is used.
|
|
34
|
+
*/
|
|
35
|
+
readonly activeSegment?: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Server-resolved active A/B variant. Optional: omit it with `abTesting`
|
|
38
|
+
* disabled, where there is nothing to resolve. When enabled and omitted,
|
|
39
|
+
* the persisted cookie is used.
|
|
40
|
+
*/
|
|
41
|
+
readonly activeVariant?: string | null;
|
|
42
|
+
/** Available segments to personalize on. */
|
|
43
|
+
readonly segments?: readonly PreprSegment[];
|
|
44
|
+
/** @deprecated Alias for `segments`. */
|
|
45
|
+
readonly data?: readonly PreprSegment[];
|
|
46
|
+
}
|
|
47
|
+
type PreprVariant = 'A' | 'B';
|
|
48
|
+
interface PreprHeaders {
|
|
49
|
+
readonly 'prepr-customer-id'?: string;
|
|
50
|
+
readonly 'Prepr-Segments'?: string;
|
|
51
|
+
readonly 'Prepr-ABtesting'?: PreprVariant;
|
|
52
|
+
readonly 'Prepr-Preview-Bar'?: 'true';
|
|
53
|
+
readonly 'Prepr-Context-utm_source'?: string;
|
|
54
|
+
readonly 'Prepr-Context-utm_medium'?: string;
|
|
55
|
+
readonly 'Prepr-Context-utm_term'?: string;
|
|
56
|
+
readonly 'Prepr-Context-utm_content'?: string;
|
|
57
|
+
readonly 'Prepr-Context-utm_campaign'?: string;
|
|
58
|
+
readonly 'Prepr-Context-initial_referral'?: string;
|
|
59
|
+
readonly 'Prepr-Visitor-IP'?: string;
|
|
60
|
+
readonly 'Prepr-Hubspot-Id'?: string;
|
|
61
|
+
readonly 'Prepr-Customer-Id-Created'?: 'true';
|
|
62
|
+
/** The visitor's browser User-Agent, used by the API for device detection. */
|
|
63
|
+
readonly 'User-Agent'?: string;
|
|
64
|
+
/** @deprecated Never populated; the visitor's value is under `User-Agent`. */
|
|
65
|
+
readonly 'Prepr-User-Agent'?: string;
|
|
66
|
+
readonly 'Prepr-Package'?: string;
|
|
67
|
+
}
|
|
68
|
+
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR' | 'GRAPHQL_ERROR' | 'INVALID_DOCUMENT';
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether a Prepr GraphQL response differs per visitor, read from its `Vary`
|
|
72
|
+
* header. Use it when fetching with your own GraphQL client; the toolkit's
|
|
73
|
+
* `createPreprClient` already returns it as `personalized`.
|
|
74
|
+
*
|
|
75
|
+
* Never throws; a response without `Vary` is not personalized.
|
|
76
|
+
*/
|
|
77
|
+
declare function isPersonalizedResponse(source: Response | Headers): boolean;
|
|
78
|
+
|
|
79
|
+
/** Error thrown by the token helpers and the segments fetch. */
|
|
80
|
+
declare class PreprError extends Error {
|
|
81
|
+
readonly code: PreprErrorCode;
|
|
82
|
+
readonly context?: string | undefined;
|
|
83
|
+
readonly originalError?: Error | undefined;
|
|
84
|
+
constructor(message: string, code: PreprErrorCode, context?: string | undefined, originalError?: Error | undefined);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Asserts `token` is the full `https://graphql.prepr.io/<token>` URL.
|
|
88
|
+
* @throws PreprError if the token is missing or not an HTTPS URL.
|
|
89
|
+
*/
|
|
90
|
+
declare function validatePreprToken(token: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Pulls the access token out of a GraphQL URL: `https://graphql.prepr.io/abc123`
|
|
93
|
+
* -> `abc123`.
|
|
94
|
+
* @throws PreprError if the URL is not a valid `graphql.prepr.io` URL.
|
|
95
|
+
*/
|
|
96
|
+
declare function extractAccessToken(graphqlUrl: string): string;
|
|
97
|
+
|
|
98
|
+
export { type PreprHeaders as P, PreprError as a, type PreprFeatures as b, type PreprToolbarProps as c, extractAccessToken as e, isPersonalizedResponse as i, validatePreprToken as v };
|
|
@@ -132,54 +132,6 @@ interface PreprHeaders {
|
|
|
132
132
|
readonly 'Prepr-User-Agent'?: string;
|
|
133
133
|
readonly 'Prepr-Package'?: string;
|
|
134
134
|
}
|
|
135
|
-
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR';
|
|
135
|
+
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR' | 'GRAPHQL_ERROR' | 'INVALID_DOCUMENT';
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
* Loader + typed facade for Prepr's CDN tracking pixel, so consumers don't have
|
|
139
|
-
* to paste a `<script>` tag. The pixel itself lives on the CDN; this only sets
|
|
140
|
-
* up the handoff.
|
|
141
|
-
*
|
|
142
|
-
* The CDN script expects a queue stub to already exist when it loads, so the
|
|
143
|
-
* contract must be reproduced exactly:
|
|
144
|
-
* - `window.prepr` pushes `arguments` onto `.queue` until the real script
|
|
145
|
-
* lands and replaces `.process`.
|
|
146
|
-
* - `.t` must be a `Date.now()` timestamp.
|
|
147
|
-
* - The tag is inserted async, `src` cache-busted every 24h via
|
|
148
|
-
* `Math.ceil(Date.now() / cacheTime) * cacheTime`.
|
|
149
|
-
*/
|
|
150
|
-
/** Config accepted by the CDN pixel. */
|
|
151
|
-
interface PreprPixelConfig {
|
|
152
|
-
destinations?: {
|
|
153
|
-
googleTagManager?: boolean;
|
|
154
|
-
};
|
|
155
|
-
variantImpressionThreshold?: number;
|
|
156
|
-
}
|
|
157
|
-
type PreprQueueArgs = unknown[];
|
|
158
|
-
interface PreprQueueFn {
|
|
159
|
-
(...args: PreprQueueArgs): void;
|
|
160
|
-
queue: PreprQueueArgs[];
|
|
161
|
-
t: number;
|
|
162
|
-
process?: (...args: PreprQueueArgs) => void;
|
|
163
|
-
}
|
|
164
|
-
declare global {
|
|
165
|
-
interface Window {
|
|
166
|
-
prepr?: PreprQueueFn;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Install the queue stub, inject the pixel script, then queue
|
|
171
|
-
* `('init', trackingId, config?)` and `('event', 'pageload')` in that order.
|
|
172
|
-
*
|
|
173
|
-
* Idempotent, and a no-op outside a browser.
|
|
174
|
-
*/
|
|
175
|
-
declare function loadTrackingPixel(trackingId: string, config?: PreprPixelConfig): void;
|
|
176
|
-
/**
|
|
177
|
-
* Send a tracking event through `window.prepr`. Only depends on `window.prepr`
|
|
178
|
-
* existing, never on how it got installed. Warns once and returns quietly when
|
|
179
|
-
* no pixel is present.
|
|
180
|
-
*/
|
|
181
|
-
declare function trackEvent(name: string, data?: string | Record<string, unknown>): void;
|
|
182
|
-
/** Loader-independent like `trackEvent`; warns once if no pixel is installed. */
|
|
183
|
-
declare function setTrackingParam(key: string, value: string): void;
|
|
184
|
-
|
|
185
|
-
export { type Locale as L, type PreprFeatures as P, type ResolvedPreprFeatures as R, type PreprSegment as a, type PreprVariant as b, type PreprToolbarProps as c, type PreprPreviewOptions as d, type PreprErrorCode as e, type PreprHeaders as f, type PreprEnvironment as g, type PreprEventType as h, type PreprFeatureConfig as i, type PreprHeaderName as j, type PreprPixelConfig as k, type PreprToolbarComponentProps as l, type PreprToolbarOptions as m, loadTrackingPixel as n, setTrackingParam as s, trackEvent as t };
|
|
137
|
+
export type { Locale as L, PreprHeaders as P, ResolvedPreprFeatures as R, PreprErrorCode as a, PreprFeatures as b, PreprSegment as c, PreprVariant as d, PreprToolbarProps as e, PreprPreviewOptions as f, PreprEnvironment as g, PreprEventType as h, PreprFeatureConfig as i, PreprHeaderName as j, PreprToolbarComponentProps as k, PreprToolbarOptions as l };
|
|
@@ -132,54 +132,6 @@ interface PreprHeaders {
|
|
|
132
132
|
readonly 'Prepr-User-Agent'?: string;
|
|
133
133
|
readonly 'Prepr-Package'?: string;
|
|
134
134
|
}
|
|
135
|
-
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR';
|
|
135
|
+
type PreprErrorCode = 'INVALID_TOKEN' | 'MISSING_TOKEN' | 'HTTP_ERROR' | 'FETCH_ERROR' | 'INVALID_RESPONSE' | 'CONTEXT_ERROR' | 'GRAPHQL_ERROR' | 'INVALID_DOCUMENT';
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
* Loader + typed facade for Prepr's CDN tracking pixel, so consumers don't have
|
|
139
|
-
* to paste a `<script>` tag. The pixel itself lives on the CDN; this only sets
|
|
140
|
-
* up the handoff.
|
|
141
|
-
*
|
|
142
|
-
* The CDN script expects a queue stub to already exist when it loads, so the
|
|
143
|
-
* contract must be reproduced exactly:
|
|
144
|
-
* - `window.prepr` pushes `arguments` onto `.queue` until the real script
|
|
145
|
-
* lands and replaces `.process`.
|
|
146
|
-
* - `.t` must be a `Date.now()` timestamp.
|
|
147
|
-
* - The tag is inserted async, `src` cache-busted every 24h via
|
|
148
|
-
* `Math.ceil(Date.now() / cacheTime) * cacheTime`.
|
|
149
|
-
*/
|
|
150
|
-
/** Config accepted by the CDN pixel. */
|
|
151
|
-
interface PreprPixelConfig {
|
|
152
|
-
destinations?: {
|
|
153
|
-
googleTagManager?: boolean;
|
|
154
|
-
};
|
|
155
|
-
variantImpressionThreshold?: number;
|
|
156
|
-
}
|
|
157
|
-
type PreprQueueArgs = unknown[];
|
|
158
|
-
interface PreprQueueFn {
|
|
159
|
-
(...args: PreprQueueArgs): void;
|
|
160
|
-
queue: PreprQueueArgs[];
|
|
161
|
-
t: number;
|
|
162
|
-
process?: (...args: PreprQueueArgs) => void;
|
|
163
|
-
}
|
|
164
|
-
declare global {
|
|
165
|
-
interface Window {
|
|
166
|
-
prepr?: PreprQueueFn;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Install the queue stub, inject the pixel script, then queue
|
|
171
|
-
* `('init', trackingId, config?)` and `('event', 'pageload')` in that order.
|
|
172
|
-
*
|
|
173
|
-
* Idempotent, and a no-op outside a browser.
|
|
174
|
-
*/
|
|
175
|
-
declare function loadTrackingPixel(trackingId: string, config?: PreprPixelConfig): void;
|
|
176
|
-
/**
|
|
177
|
-
* Send a tracking event through `window.prepr`. Only depends on `window.prepr`
|
|
178
|
-
* existing, never on how it got installed. Warns once and returns quietly when
|
|
179
|
-
* no pixel is present.
|
|
180
|
-
*/
|
|
181
|
-
declare function trackEvent(name: string, data?: string | Record<string, unknown>): void;
|
|
182
|
-
/** Loader-independent like `trackEvent`; warns once if no pixel is installed. */
|
|
183
|
-
declare function setTrackingParam(key: string, value: string): void;
|
|
184
|
-
|
|
185
|
-
export { type Locale as L, type PreprFeatures as P, type ResolvedPreprFeatures as R, type PreprSegment as a, type PreprVariant as b, type PreprToolbarProps as c, type PreprPreviewOptions as d, type PreprErrorCode as e, type PreprHeaders as f, type PreprEnvironment as g, type PreprEventType as h, type PreprFeatureConfig as i, type PreprHeaderName as j, type PreprPixelConfig as k, type PreprToolbarComponentProps as l, type PreprToolbarOptions as m, loadTrackingPixel as n, setTrackingParam as s, trackEvent as t };
|
|
137
|
+
export type { Locale as L, PreprHeaders as P, ResolvedPreprFeatures as R, PreprErrorCode as a, PreprFeatures as b, PreprSegment as c, PreprVariant as d, PreprToolbarProps as e, PreprPreviewOptions as f, PreprEnvironment as g, PreprEventType as h, PreprFeatureConfig as i, PreprHeaderName as j, PreprToolbarComponentProps as k, PreprToolbarOptions as l };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preprio/toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.0",
|
|
4
4
|
"description": "Prepr personalization, A/B testing and preview toolkit for React, Next.js, Nuxt, Astro, SvelteKit and Express",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Prepr B.V. (https://prepr.io)",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"import": "./dist/index.js",
|
|
40
40
|
"require": "./dist/index.cjs"
|
|
41
41
|
},
|
|
42
|
+
"./graphql": {
|
|
43
|
+
"types": "./dist/graphql.d.ts",
|
|
44
|
+
"import": "./dist/graphql.js",
|
|
45
|
+
"require": "./dist/graphql.cjs"
|
|
46
|
+
},
|
|
42
47
|
"./react": {
|
|
43
48
|
"types": "./dist/react/index.d.ts",
|
|
44
49
|
"import": "./dist/react/index.js",
|
|
@@ -54,6 +59,11 @@
|
|
|
54
59
|
"import": "./dist/nextjs/index.js",
|
|
55
60
|
"require": "./dist/nextjs/index.cjs"
|
|
56
61
|
},
|
|
62
|
+
"./nextjs/graphql": {
|
|
63
|
+
"types": "./dist/nextjs/graphql.d.ts",
|
|
64
|
+
"import": "./dist/nextjs/graphql.js",
|
|
65
|
+
"require": "./dist/nextjs/graphql.cjs"
|
|
66
|
+
},
|
|
57
67
|
"./json-script": {
|
|
58
68
|
"types": "./dist/json-script.d.ts",
|
|
59
69
|
"import": "./dist/json-script.js",
|
|
@@ -74,18 +84,33 @@
|
|
|
74
84
|
"import": "./dist/astro/index.js",
|
|
75
85
|
"require": "./dist/astro/index.cjs"
|
|
76
86
|
},
|
|
87
|
+
"./astro/graphql": {
|
|
88
|
+
"types": "./dist/astro/graphql.d.ts",
|
|
89
|
+
"import": "./dist/astro/graphql.js",
|
|
90
|
+
"require": "./dist/astro/graphql.cjs"
|
|
91
|
+
},
|
|
77
92
|
"./astro/components/*": "./src/astro/*.astro",
|
|
78
93
|
"./sveltekit": {
|
|
79
94
|
"types": "./dist/sveltekit/index.d.ts",
|
|
80
95
|
"import": "./dist/sveltekit/index.js",
|
|
81
96
|
"require": "./dist/sveltekit/index.cjs"
|
|
82
97
|
},
|
|
98
|
+
"./sveltekit/graphql": {
|
|
99
|
+
"types": "./dist/sveltekit/graphql.d.ts",
|
|
100
|
+
"import": "./dist/sveltekit/graphql.js",
|
|
101
|
+
"require": "./dist/sveltekit/graphql.cjs"
|
|
102
|
+
},
|
|
83
103
|
"./sveltekit/components/*": "./src/sveltekit/*.svelte",
|
|
84
104
|
"./nuxt": {
|
|
85
105
|
"types": "./dist/nuxt/index.d.ts",
|
|
86
106
|
"import": "./dist/nuxt/index.js",
|
|
87
107
|
"require": "./dist/nuxt/index.cjs"
|
|
88
108
|
},
|
|
109
|
+
"./nuxt/graphql": {
|
|
110
|
+
"types": "./dist/nuxt/graphql.d.ts",
|
|
111
|
+
"import": "./dist/nuxt/graphql.js",
|
|
112
|
+
"require": "./dist/nuxt/graphql.cjs"
|
|
113
|
+
},
|
|
89
114
|
"./nuxt/components/*": "./src/nuxt/*.vue"
|
|
90
115
|
},
|
|
91
116
|
"files": [
|
|
@@ -109,6 +134,7 @@
|
|
|
109
134
|
"preact": "^10.29.7"
|
|
110
135
|
},
|
|
111
136
|
"peerDependencies": {
|
|
137
|
+
"graphql": ">=16",
|
|
112
138
|
"next": ">=13",
|
|
113
139
|
"react": ">=17",
|
|
114
140
|
"react-dom": ">=17",
|
|
@@ -116,6 +142,9 @@
|
|
|
116
142
|
"vue": ">=3.3"
|
|
117
143
|
},
|
|
118
144
|
"peerDependenciesMeta": {
|
|
145
|
+
"graphql": {
|
|
146
|
+
"optional": true
|
|
147
|
+
},
|
|
119
148
|
"next": {
|
|
120
149
|
"optional": true
|
|
121
150
|
},
|
|
@@ -137,6 +166,7 @@
|
|
|
137
166
|
"@types/react": "^19.2.17",
|
|
138
167
|
"@types/react-dom": "^19.2.3",
|
|
139
168
|
"browserslist": "^4.28.7",
|
|
169
|
+
"graphql": "^16.14.2",
|
|
140
170
|
"happy-dom": "^20.11.1",
|
|
141
171
|
"lightningcss": "^1.33.0",
|
|
142
172
|
"next": "^16.2.12",
|