@pack/hydrogen 3.2.8 → 3.3.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/dist/index.d.ts CHANGED
@@ -116,8 +116,10 @@ interface PackCustomizerMeta {
116
116
  version?: string;
117
117
  };
118
118
  previewContext?: {
119
+ linkName?: string;
119
120
  locale?: string;
120
121
  releaseId?: string;
122
+ releaseName?: string;
121
123
  pageDraft?: string;
122
124
  siteSettingsDraft?: string;
123
125
  testHandle?: string;
@@ -226,4 +228,85 @@ declare function useAbTestHandle(): string | undefined;
226
228
  declare function useAbTestVariantId(): string | undefined;
227
229
  declare function useAbTestVariantHandle(): string | undefined;
228
230
 
229
- export { type Pack, PackSession, PackTestContext, PackTestProvider, PackTestRoute, PackTestSession, createPackClient, handleRequest, action as previewModeAction, loader as previewModeLoader, useAbTest, useAbTestHandle, useAbTestId, useAbTestSessionId, useAbTestVariantHandle, useAbTestVariantId, usePackCookies, usePackTestContext };
231
+ /**
232
+ * The identity signals audience conditions evaluate against. Built once per SSR
233
+ * request and passed to the resolver; every condition reads from this bundle
234
+ * rather than re-parsing the request.
235
+ *
236
+ * Two population levels:
237
+ * - request-only (handleRequest / A/B): everything except customer identity;
238
+ * - request + customer (root loader / Personalization): also `shopifyCustomerId`.
239
+ * All fields are optional; customer-keyed conditions simply don't match at the
240
+ * request-only level.
241
+ */
242
+ interface IdentityBundle {
243
+ shopifyCustomerId?: string;
244
+ ga4ClientId?: string;
245
+ amplitudeDeviceId?: string;
246
+ amplitudeUserId?: string;
247
+ klaviyoProfileId?: string;
248
+ segmentAnonymousId?: string;
249
+ cookies: Record<string, string>;
250
+ hasConsent: boolean;
251
+ userAgent?: string;
252
+ deviceType: "mobile" | "tablet" | "desktop";
253
+ geo: {
254
+ country?: string;
255
+ region?: string;
256
+ };
257
+ url: {
258
+ path: string;
259
+ query: Record<string, string>;
260
+ host?: string;
261
+ };
262
+ referrer?: string;
263
+ }
264
+ interface BuildIdentityBundleOptions {
265
+ /** Shopify customer id, when resolved (loader-level / Personalization). */
266
+ shopifyCustomerId?: string;
267
+ }
268
+ /**
269
+ * Builds an IdentityBundle from an SSR request (headers + cookies) and, when
270
+ * available, the resolved Shopify customer. Pure and synchronous — safe to call
271
+ * once per request and memoize.
272
+ */
273
+ declare function buildIdentityBundle(request: Request, options?: BuildIdentityBundleOptions): IdentityBundle;
274
+
275
+ type ConditionEvaluator = (config: Record<string, any> | null | undefined, identity: IdentityBundle) => boolean | Promise<boolean>;
276
+ declare function registerConditionEvaluator(type: string, evaluate: ConditionEvaluator): void;
277
+ declare function getConditionEvaluator(type: string): ConditionEvaluator | undefined;
278
+ declare function isConditionRegistered(type: string): boolean;
279
+
280
+ type RuleGroupOperator = "AND" | "OR" | "NOT";
281
+ interface RuleGroupNode {
282
+ op: RuleGroupOperator;
283
+ children: AudienceRuleNode[];
284
+ }
285
+ interface RuleConditionNode {
286
+ type: string;
287
+ provider?: string | null;
288
+ config?: Record<string, any> | null;
289
+ negate?: boolean | null;
290
+ }
291
+ type AudienceRuleNode = RuleGroupNode | RuleConditionNode;
292
+ type AudienceRulesTree = AudienceRuleNode | Record<string, never>;
293
+
294
+ interface MatchedCondition {
295
+ type: string;
296
+ provider?: string | null;
297
+ config?: Record<string, any> | null;
298
+ negate?: boolean | null;
299
+ }
300
+ interface AudienceResolution {
301
+ matches: boolean;
302
+ matchedConditions: MatchedCondition[];
303
+ }
304
+ /**
305
+ * Evaluates an audience rules tree against an IdentityBundle at SSR. AND/OR
306
+ * short-circuit; NOT ("none of these") matches when none of its children match;
307
+ * leaves dispatch to their registered evaluator (with leaf `negate` applied). An
308
+ * empty tree matches everyone. Unknown types + evaluator errors fail closed.
309
+ */
310
+ declare function resolveRulesTree(rules: AudienceRulesTree | null | undefined, identity: IdentityBundle): Promise<AudienceResolution>;
311
+
312
+ export { type AudienceResolution, type AudienceRuleNode, type AudienceRulesTree, type BuildIdentityBundleOptions, type ConditionEvaluator, type IdentityBundle, type MatchedCondition, type Pack, PackSession, PackTestContext, PackTestProvider, PackTestRoute, PackTestSession, type RuleConditionNode, type RuleGroupNode, type RuleGroupOperator, buildIdentityBundle, createPackClient, getConditionEvaluator, handleRequest, isConditionRegistered, action as previewModeAction, loader as previewModeLoader, registerConditionEvaluator, resolveRulesTree, useAbTest, useAbTestHandle, useAbTestId, useAbTestSessionId, useAbTestVariantHandle, useAbTestVariantId, usePackCookies, usePackTestContext };