@ikas/bp-storefront 1.4.0-beta.192 → 1.4.0-beta.194

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 (50) hide show
  1. package/dist/analytics/analytics-functions/addToCart.js +1 -1
  2. package/dist/analytics/analytics-functions/completeRegistration.js +1 -1
  3. package/dist/analytics/analytics-functions/contactForm.js +1 -1
  4. package/dist/analytics/analytics-functions/createEmailSubscription.js +1 -1
  5. package/dist/analytics/analytics-functions/customerLogin.js +1 -1
  6. package/dist/analytics/analytics-functions/pageView.js +1 -1
  7. package/dist/analytics/analytics-functions/productView.js +1 -1
  8. package/dist/analytics/ikas/analytics.js +1 -1
  9. package/dist/analytics/openai/addToCart.d.ts +2 -0
  10. package/dist/analytics/openai/addToCart.js +1 -0
  11. package/dist/analytics/openai/completeRegistration.d.ts +1 -0
  12. package/dist/analytics/openai/completeRegistration.js +1 -0
  13. package/dist/analytics/openai/contactForm.d.ts +1 -0
  14. package/dist/analytics/openai/contactForm.js +1 -0
  15. package/dist/analytics/openai/initAdvancedMatching.d.ts +12 -0
  16. package/dist/analytics/openai/initAdvancedMatching.js +1 -0
  17. package/dist/analytics/openai/pageView.d.ts +1 -0
  18. package/dist/analytics/openai/pageView.js +1 -0
  19. package/dist/analytics/openai/productView.d.ts +2 -0
  20. package/dist/analytics/openai/productView.js +1 -0
  21. package/dist/analytics/openai/utils.d.ts +26 -0
  22. package/dist/analytics/openai/utils.js +1 -0
  23. package/dist/analytics/utils.d.ts +1 -0
  24. package/dist/analytics/utils.js +1 -1
  25. package/dist/ext/tslib/tslib.es6.mjs.js +1 -1
  26. package/dist/functions/api/customer/index.d.ts +5 -0
  27. package/dist/functions/api/customer/index.js +1 -1
  28. package/dist/functions/stores/cart/index.js +1 -1
  29. package/dist/functions/stores/customer/index.d.ts +149 -2
  30. package/dist/functions/stores/customer/index.js +1 -1
  31. package/dist/index.d.ts +0 -1
  32. package/dist/index.js +1 -1
  33. package/dist/packages/storefront-api/src/__api/mutations/unlinkExternalAccount.js +1 -0
  34. package/dist/packages/storefront-api/src/__api/queries/getExternalAccountLink.js +1 -0
  35. package/dist/packages/storefront-api/src/__api/queries/getMilesSmilesDetails.js +1 -0
  36. package/dist/packages/storefront-config/src/theme-globals.js +1 -1
  37. package/dist/storefront-api/src/__api/mutations/unlinkExternalAccount.d.ts +6 -0
  38. package/dist/storefront-api/src/__api/queries/getExternalAccountLink.d.ts +6 -0
  39. package/dist/storefront-api/src/__api/queries/getMilesSmilesDetails.d.ts +3 -0
  40. package/dist/storefront-api/src/__api/types/index.d.ts +18 -0
  41. package/dist/storefront-config/src/index.d.ts +2 -0
  42. package/dist/storefront-config/src/theme-globals.d.ts +24 -1
  43. package/dist/storefront-models/src/models/payment-gateway/index.d.ts +2 -0
  44. package/dist/storefront-models/src/models/storefront/index.d.ts +1 -0
  45. package/dist/theme/settings/index.d.ts +4 -1
  46. package/dist/utils/helper.d.ts +1 -0
  47. package/dist/utils/helper.js +1 -1
  48. package/package.json +1 -1
  49. package/dist/utils/loop-guard.d.ts +0 -43
  50. package/dist/utils/loop-guard.js +0 -1
@@ -30,6 +30,7 @@ export type CustomerAttributePermissionEnum = "CustomerAttributePermissionEnum"
30
30
  export type CustomerAttributeRegisterPageRequirementEnum = "CustomerAttributeRegisterPageRequirementEnum" | "INVISIBLE" | "MANDATORY" | "OPTIONAL";
31
31
  export type CustomerAttributeTypeEnum = "CustomerAttributeTypeEnum" | "BOOLEAN" | "CHOICE" | "DATE" | "DATETIME" | "MULTIPLE_CHOICE" | "NUMERIC" | "TEXT";
32
32
  export type CustomerEmailSubscriptionStatusesEnum = "CustomerEmailSubscriptionStatusesEnum" | "NOT_SUBSCRIBED" | "PENDING_CONFIRMATION" | "SUBSCRIBED";
33
+ export type CustomerExternalAccountLinkProviderEnum = "CustomerExternalAccountLinkProviderEnum" | "miles_smiles";
33
34
  export type CustomerGenderTypeEnum = "CustomerGenderTypeEnum" | "FEMALE" | "MALE" | "OTHER";
34
35
  export type CustomerPriceListRuleFilterTypeEnum = "CustomerPriceListRuleFilterTypeEnum" | "CATEGORY" | "PRODUCT" | "PRODUCT_BRAND" | "PRODUCT_TAG";
35
36
  export type CustomerPriceListRuleValueTypeEnum = "CustomerPriceListRuleValueTypeEnum" | "DISCOUNT_AMOUNT" | "DISCOUNT_RATE" | "FIXED_PRICE";
@@ -1052,6 +1053,17 @@ export interface GetAvailableStockLocationAddressCountry {
1052
1053
  export interface GetAvailableStockLocationsResponse {
1053
1054
  stockLocations: GetAvailableStockLocation[];
1054
1055
  }
1056
+ export interface ExternalAccountLink {
1057
+ externalId: string;
1058
+ linkedAt: any;
1059
+ provider: CustomerExternalAccountLinkProviderEnum;
1060
+ }
1061
+ export interface MilesSmilesDetailsResponse {
1062
+ availableMiles: number;
1063
+ firstName: string | null;
1064
+ lastName: string | null;
1065
+ memberId: string;
1066
+ }
1055
1067
  export interface GetCustomerCouponResponse {
1056
1068
  campaign: Campaign;
1057
1069
  code: string;
@@ -1784,6 +1796,7 @@ export interface PaymentGateway {
1784
1796
  isPassive: boolean | null;
1785
1797
  logoUrl: string | null;
1786
1798
  masterPassClientId: string | null;
1799
+ milesSmilesEnabled: boolean | null;
1787
1800
  name: string;
1788
1801
  paymentGatewayProviderId: string | null;
1789
1802
  paymentMethodType: PaymentMethodTypeEnum;
@@ -3134,6 +3147,7 @@ export interface CreateSaleTransactionWithCartInput {
3134
3147
  cartId: string;
3135
3148
  masterPassDetail?: CreateSaleTransactionMasterPassPaymentMethodDetail | null;
3136
3149
  metadata?: any | null;
3150
+ milesSmiles?: MilesSmilesPaymentInput | null;
3137
3151
  paymentGatewayId: string;
3138
3152
  paymentMethodDetail?: PaymentMethodDetailInput | null;
3139
3153
  }
@@ -3141,6 +3155,7 @@ export interface CreateSaleTransactionWithCheckoutInput {
3141
3155
  checkoutId: string;
3142
3156
  masterPassDetail?: CreateSaleTransactionMasterPassPaymentMethodDetail | null;
3143
3157
  metadata?: any | null;
3158
+ milesSmiles?: MilesSmilesPaymentInput | null;
3144
3159
  paymentGatewayId: string;
3145
3160
  paymentMethodDetail?: PaymentMethodDetailInput | null;
3146
3161
  }
@@ -3190,6 +3205,9 @@ export interface DateFilterInput {
3190
3205
  ne?: any | null;
3191
3206
  nin?: any[] | null;
3192
3207
  }
3208
+ export interface MilesSmilesPaymentInput {
3209
+ miles: number;
3210
+ }
3193
3211
  export interface GetCustomerCouponsInput {
3194
3212
  customerId: string;
3195
3213
  }
@@ -27,6 +27,7 @@ export declare class IkasStorefrontConfig {
27
27
  static universalAnalyticsId?: string;
28
28
  static pickUpStockLocationIds?: string[] | null;
29
29
  static tiktokPixelId?: string;
30
+ static openAiPixelId?: string;
30
31
  static stockPreference?: IkasThemeStockPreference;
31
32
  static translations: Record<string, any>;
32
33
  static themeGlobals: ThemeGlobals;
@@ -101,6 +102,7 @@ export type IkasStorefrontConfigParams = {
101
102
  universalAnalyticsId?: string;
102
103
  pickUpStockLocationIds?: string[] | null;
103
104
  tiktokPixelId?: string;
105
+ openAiPixelId?: string;
104
106
  stockPreference?: IkasThemeStockPreference;
105
107
  translations: Record<string, any>;
106
108
  themeGlobals: ThemeGlobals;
@@ -10,7 +10,7 @@ export declare function cssVarCamelCase(str: string): string;
10
10
  * {@link serializeThemeGlobals}, and returned by the CLI/MCP `list-theme-globals` reader.
11
11
  */
12
12
  /** Global-variable value kinds, mirrored from the editor sidebar `GlobalVariableType`. */
13
- export type GlobalVariableType = "TEXT" | "RICH_TEXT" | "IMAGE" | "COLOR" | "NUMBER" | "BOOLEAN" | "BORDER" | "SHADOW";
13
+ export type GlobalVariableType = "TEXT" | "RICH_TEXT" | "IMAGE" | "COLOR" | "NUMBER" | "BOOLEAN" | "BORDER" | "SHADOW" | "ENUM";
14
14
  /** A theme "global variable" (Theme Settings panel). `name` is the stable runtime key. */
15
15
  export type ThemeSetting = {
16
16
  /** Stable runtime key — the variable's `variableName` (e.g. `_6Q0KV7VGGM`). */
@@ -25,8 +25,21 @@ export type ThemeSetting = {
25
25
  * `.url` field — resolve to a URL with `getDefaultSrc(value)` / `getSrc(value, size)`
26
26
  * from `@ikas/bp-storefront`, never read `value.url`.
27
27
  * - BORDER/SHADOW → object, or `null` when unset.
28
+ * - ENUM → the selected option VALUE string (one of `Object.values(options)`, never a label),
29
+ * or `null` when unset or when that option no longer exists on the enum.
28
30
  */
29
31
  value: any;
32
+ /**
33
+ * ENUM only — id of the project enum type (`project.types[].id`) this setting selects from. It is
34
+ * the same id an ENUM component prop carries as `enumTypeId`; matching ids are what make a prop
35
+ * bindable to the setting.
36
+ */
37
+ enumTypeId?: string;
38
+ /**
39
+ * ENUM only — the enum's options at serialize time, `{ [label]: value }`. `value` above is always
40
+ * one of these VALUES or `null`. Empty when the enum type could not be found in the project.
41
+ */
42
+ options?: Record<string, string>;
30
43
  };
31
44
  /** A single-value design token (color). `cssVar` resolves the live, scheme-aware value. */
32
45
  export type DesignToken = {
@@ -216,15 +229,25 @@ type VariableLike = {
216
229
  variableName?: string;
217
230
  displayName?: string;
218
231
  variableType?: string;
232
+ /** Blueprint type id. For an ENUM global this is the enum type's id (`project.types[].id`). */
233
+ typeId?: string;
219
234
  defaultValue?: any;
220
235
  isGlobal?: boolean;
221
236
  };
237
+ /** The slice of a project `IType` an ENUM setting reads: its id and its `{ label: value }` options. */
238
+ type TypeLike = {
239
+ id: string;
240
+ type?: unknown;
241
+ enumOptions?: Record<string, any> | null;
242
+ };
222
243
  export type SerializableProject = {
223
244
  globalsBlueprint?: {
224
245
  module?: {
225
246
  variables?: VariableLike[];
226
247
  };
227
248
  };
249
+ /** Project custom types; only enum entries are read, to resolve ENUM settings' options. */
250
+ types?: TypeLike[];
228
251
  theme?: {
229
252
  breakpoints?: BreakpointLike[];
230
253
  keyframes?: KeyframeLike[];
@@ -12,6 +12,8 @@ export type IkasPaymentGateway = {
12
12
  description: string | null;
13
13
  logoUrl: string | null;
14
14
  masterPassClientId: string | null;
15
+ /** True when Miles&Smiles can be redeemed on this (TK_PAY) gateway. */
16
+ milesSmilesEnabled?: boolean | null;
15
17
  name: string;
16
18
  paymentGatewayProviderId: string | null;
17
19
  supportedCurrencies: string[] | null;
@@ -20,6 +20,7 @@ export type IkasStorefront = {
20
20
  analytics4Id: string | null;
21
21
  universalAnalyticsId: string | null;
22
22
  tiktokPixelId: string | null;
23
+ openAiPixelId?: string | null;
23
24
  token: string | null;
24
25
  type: IkasStorefrontType;
25
26
  metaTemplates: IkasStorefontMetaTemplates[] | null;
@@ -13,7 +13,10 @@ export declare function getThemeSettings(): ThemeSetting[];
13
13
  * The returned `value` is the live blueprint value when available, else the default.
14
14
  * Its shape is discriminated by `type` (see {@link ThemeSetting.value}); note an
15
15
  * IMAGE setting's value is an image REFERENCE (no `.url`) — resolve with
16
- * `getDefaultSrc`/`getSrc`.
16
+ * `getDefaultSrc`/`getSrc`. An ENUM setting's `value` is one of its enum's option VALUES
17
+ * (or null) and the setting also carries `enumTypeId` and `options` (`{ label: value }`);
18
+ * in a code component prefer the typed `themeValue("_key")` from `./global-types`, which
19
+ * narrows the value to the enum's union.
17
20
  */
18
21
  export declare function getThemeSetting(name: string): ThemeSetting | undefined;
19
22
  /** Convenience: the resolved value of a global variable, or `undefined` if not found. */
@@ -7,6 +7,7 @@ export declare function capitalize(value: string): string;
7
7
  export declare function tryForEach(items: any[], callback: (item: any, index: number) => void, printErrors?: boolean): void;
8
8
  export declare function formatDate(date: Date): string;
9
9
  export declare function getCookieValue(cookieName: string): string | null;
10
+ export declare function getOpenAiAttributionMetadata(): Record<string, string>;
10
11
  export declare function isClient(): boolean;
11
12
  export declare function isServer(): boolean;
12
13
  export declare function getQueryParams(): URLSearchParams | undefined;
@@ -1 +1 @@
1
- import{__spreadArray as r}from'./../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../packages/storefront-config/src/index.js";import{reaction as t}from'./../ext/mobx/dist/mobx.esm.js';var e=function(r){return/^\+?\d+$/.test(r)},o=function(r){r=(r=r.replace(/^\s+|\s+$/g,"")).toLocaleLowerCase("tr-TR");for(var n="àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;",t=0;t<31;t++)r=r.replace(new RegExp(n.charAt(t),"g"),"aaaaeeeeiiiiioooouuuuncsg------".charAt(t));return r=r.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},a=function(r){return!(r.length>320)&&/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r)};function i(r){return!!new Intl.DateTimeFormat(r,{hour:"numeric"}).format(0).match(/\s/)}function u(r,n,t){void 0===t&&(t=!1),r.forEach(function(r,e){try{n(r,e)}catch(r){t&&console.error(r)}})}function c(r){var t={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",hour12:!1},e=n.getCurrentLocale();return"undefined"!=typeof navigator?t.hour12=i(navigator.language):t.hour12=i(e),new Intl.DateTimeFormat(e,t).format(r)}function f(r){var n=document.cookie.split(";").find(function(n){return n.trim().startsWith("".concat(r,"="))});return n?n.split("=")[1]:null}function s(){return"undefined"!=typeof window}function l(){return!s()}function m(){if(s())return new URLSearchParams(location.search)}function p(){return!!s()&&(performance.getEntriesByType?"back_forward"===performance.getEntriesByType("navigation")[0].type:performance.navigation.type===performance.navigation.TYPE_BACK_FORWARD)}function g(r,n){void 0===n&&(n={arrayFormat:"comma"});for(var t=[],e=function(r,e){if(null==e)return"continue";Array.isArray(e)?"comma"===n.arrayFormat&&e.length>0?t.push("".concat(r,"=").concat(e.join(","))):e.forEach(function(n){return t.push("".concat(r,"=").concat(n))}):t.push("".concat(r,"=").concat(e))},o=0,a=Object.entries(r);o<a.length;o++){var i=a[o];e(i[0],i[1])}return t.length>0?"".concat(t.join("&")):""}function h(r){return null==r?r:JSON.parse(JSON.stringify(r))}function y(r,n){if(!r||!Array.isArray(r))return{};for(var t={},e=0,o=r;e<o.length;e++){var a=o[e],i=void 0;t[i=String("string"==typeof n?a[n]:"function"==typeof n?n(a):a)]||(t[i]=[]),t[i].push(a)}return t}function v(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n&&Array.isArray(n)?(0===t.length&&(t=[function(r){return r}]),r([],n,!0).sort(function(r,n){for(var e=0,o=t;e<o.length;e++){var a=o[e],i=void 0,u=void 0;if("string"==typeof a?(i=r[a],u=n[a]):"function"==typeof a?(i=a(r),u=a(n)):(i=r,u=n),null!=i||null!=u){if(null==i)return 1;if(null==u)return-1;if(i<u)return-1;if(i>u)return 1}}return 0})):[]}function d(r,n){var t;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];clearTimeout(t),t=setTimeout(function(){return r.apply(void 0,e)},n)}}function A(r,n){return t(r,n)}export{h as cloneDeep,d as debounce,c as formatDate,f as getCookieValue,m as getQueryParams,y as groupBy,p as isBackNavigation,s as isClient,l as isServer,A as reaction,v as sortBy,o as stringToSlug,g as stringifyQueryParams,u as tryForEach,a as validateEmail,e as validatePhoneNumber};
1
+ import{__spreadArray as r,__assign as n}from'./../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as t}from"../packages/storefront-config/src/index.js";import{reaction as e}from'./../ext/mobx/dist/mobx.esm.js';var o=function(r){return/^\+?\d+$/.test(r)},a=function(r){r=(r=r.replace(/^\s+|\s+$/g,"")).toLocaleLowerCase("tr-TR");for(var n="àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;",t=0;t<31;t++)r=r.replace(new RegExp(n.charAt(t),"g"),"aaaaeeeeiiiiioooouuuuncsg------".charAt(t));return r=r.replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")},i=function(r){return!(r.length>320)&&/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r)};function u(r){return!!new Intl.DateTimeFormat(r,{hour:"numeric"}).format(0).match(/\s/)}function c(r,n,t){void 0===t&&(t=!1),r.forEach(function(r,e){try{n(r,e)}catch(r){t&&console.error(r)}})}function f(r){var n={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",hour12:!1},e=t.getCurrentLocale();return"undefined"!=typeof navigator?n.hour12=u(navigator.language):n.hour12=u(e),new Intl.DateTimeFormat(e,n).format(r)}function s(r){var n=document.cookie.split(";").find(function(n){return n.trim().startsWith("".concat(r,"="))});return n?n.split("=")[1]:null}function l(){var r=s("__oppref"),t=s("__obref");return n(n({},r?{oppref:r}:{}),t?{obref:t}:{})}function m(){return"undefined"!=typeof window}function p(){return!m()}function g(){if(m())return new URLSearchParams(location.search)}function h(){return!!m()&&(performance.getEntriesByType?"back_forward"===performance.getEntriesByType("navigation")[0].type:performance.navigation.type===performance.navigation.TYPE_BACK_FORWARD)}function v(r,n){void 0===n&&(n={arrayFormat:"comma"});for(var t=[],e=function(r,e){if(null==e)return"continue";Array.isArray(e)?"comma"===n.arrayFormat&&e.length>0?t.push("".concat(r,"=").concat(e.join(","))):e.forEach(function(n){return t.push("".concat(r,"=").concat(n))}):t.push("".concat(r,"=").concat(e))},o=0,a=Object.entries(r);o<a.length;o++){var i=a[o];e(i[0],i[1])}return t.length>0?"".concat(t.join("&")):""}function y(r){return null==r?r:JSON.parse(JSON.stringify(r))}function d(r,n){if(!r||!Array.isArray(r))return{};for(var t={},e=0,o=r;e<o.length;e++){var a=o[e],i=void 0;t[i=String("string"==typeof n?a[n]:"function"==typeof n?n(a):a)]||(t[i]=[]),t[i].push(a)}return t}function A(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n&&Array.isArray(n)?(0===t.length&&(t=[function(r){return r}]),r([],n,!0).sort(function(r,n){for(var e=0,o=t;e<o.length;e++){var a=o[e],i=void 0,u=void 0;if("string"==typeof a?(i=r[a],u=n[a]):"function"==typeof a?(i=a(r),u=a(n)):(i=r,u=n),null!=i||null!=u){if(null==i)return 1;if(null==u)return-1;if(i<u)return-1;if(i>u)return 1}}return 0})):[]}function _(r,n){var t;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];clearTimeout(t),t=setTimeout(function(){return r.apply(void 0,e)},n)}}function b(r,n){return e(r,n)}export{y as cloneDeep,_ as debounce,f as formatDate,s as getCookieValue,l as getOpenAiAttributionMetadata,g as getQueryParams,d as groupBy,h as isBackNavigation,m as isClient,p as isServer,b as reaction,A as sortBy,a as stringToSlug,v as stringifyQueryParams,c as tryForEach,i as validateEmail,o as validatePhoneNumber};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/bp-storefront",
3
- "version": "1.4.0-beta.192",
3
+ "version": "1.4.0-beta.194",
4
4
  "description": "A framework for the ikas blueprint storefronts.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -1,43 +0,0 @@
1
- /**
2
- * Guard against theme code that loops without ever yielding to the event loop.
3
- *
4
- * A MutationObserver callback that mutates the subtree it observes, a `queueMicrotask` chain, or a
5
- * `setState` inside a deps-less `useLayoutEffect` all re-queue themselves before the current task
6
- * ends, so the tab hard-freezes: no paint, no input. In the editor canvas that takes the whole
7
- * editor down with it; on a live store it takes the page down.
8
- *
9
- * The guard is installed by the HOST (storefront page entry, editor canvas) and never kills
10
- * anything: past the limit the work is DEMOTED to a macrotask. The endless loop becomes a loop that
11
- * yields, nothing is dropped, and a false positive costs a few milliseconds — which is what makes
12
- * it safe to put in front of third-party scripts too.
13
- *
14
- * Not covered, because there is nothing to intercept: `await` / promise-chain loops and plain
15
- * synchronous loops.
16
- */
17
- export declare const LOOP_GUARD_LIMIT = 1000;
18
- export declare const RENDER_LOOP_LIMIT = 100;
19
- export type LoopGuardTrip = {
20
- kind: "observer-loop" | "microtask-loop" | "render-loop";
21
- ownerName?: string;
22
- ownerId?: string;
23
- /**
24
- * Where the loop lives in the page — the observed node (observer-loop) or the component's root
25
- * (render-loop). The owner of the CODE may be a shared chunk; the DOM names the component.
26
- */
27
- element?: Element | null;
28
- };
29
- export type LoopGuardPair = [typeof MutationObserver, (callback: () => void) => void];
30
- type GuardWindow = {
31
- MutationObserver: typeof MutationObserver;
32
- MessageChannel: typeof MessageChannel;
33
- queueMicrotask: (callback: () => void) => void;
34
- setTimeout: (callback: () => void, ms: number) => unknown;
35
- };
36
- type PreactOptions = {
37
- __r?: (vnode: any) => void;
38
- };
39
- export declare function createLoopGuard(win: GuardWindow, onTrip: (trip: LoopGuardTrip) => void): {
40
- pair: (ownerName?: string, ownerId?: string) => LoopGuardPair;
41
- renders: (options: PreactOptions) => void;
42
- };
43
- export {};
@@ -1 +0,0 @@
1
- import{__extends as e}from'./../ext/tslib/tslib.es6.mjs.js';var n=1e3,t=100;function r(t,r){var o,a,i=t.MutationObserver,u=t.queueMicrotask.bind(t),c=t.setTimeout.bind(t),s=new t.MessageChannel,f=0,l=!1;s.port1.onmessage=function(){f+=1,l=!1},null===(a=(o=s.port1).unref)||void 0===a||a.call(o);var d=function(){return l||(l=!0,s.port2.postMessage(0)),f},v=0,p=function(e,n){var t=v;v=n;try{e()}finally{v=t}};return{pair:function(t,o){var a=!1;return[function(a){function i(e){var i,u=this,s=-1,f=0,l=!1;return(u=a.call(this,function(a,u){if(!l){var v=d();if(v!==s&&(s=v,f=0),(f+=1)<=n)return void e.call(u,a,u);l=!0,r({kind:"observer-loop",ownerName:t,ownerId:o,element:i})}c(function(){return e.call(u,a,u)},0)})||this).observe=function(e,n){i=1===e.nodeType?e:e.parentElement,a.prototype.observe.call(u,e,n)},u}return e(i,a),i}(i),function(e){var i=v+1;i<=n?u(function(){return p(e,i)}):(a||(a=!0,r({kind:"microtask-loop",ownerName:t,ownerId:o})),c(function(){return p(e,0)},0))}]},renders:function(e){var n=new WeakMap,t=new WeakSet,o=new WeakSet,a=e.__r;e.__r=function(e){var i=e.__c;if(i&&!t.has(i)){var u=d(),s=n.get(i);if(s&&s.epoch===u||(s={epoch:u,count:0},n.set(i,s)),s.count+=1,s.count>100){var f=[];t.add(i),i.setState=function(e,n){f.push([e,n])},o.has(i)||(o.add(i),r({kind:"render-loop",element:i.base})),c(function(){t.delete(i),delete i.setState,f.forEach(function(e){var n=e[0],t=e[1];return i.setState(n,t)})},0)}}a&&a(e)}}}}export{n as LOOP_GUARD_LIMIT,t as RENDER_LOOP_LIMIT,r as createLoopGuard};