@preprio/prepr-nextjs 2.0.0-alpha.9 → 2.0.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.
@@ -1,4 +1,5 @@
1
1
  import { ClassValue } from 'clsx';
2
+ import { PreprEventType } from '../types/index.cjs';
2
3
 
3
4
  declare const StegaError: {
4
5
  readonly DECODE_FAILED: "STEGA_DECODE_FAILED";
@@ -75,12 +76,16 @@ declare class DOMService {
75
76
  */
76
77
  type DebugArg = string | number | boolean | null | undefined | object;
77
78
  interface DebugOptions {
78
- enabled: boolean;
79
+ enabled?: boolean;
79
80
  prefix?: string;
80
81
  }
81
82
  declare class DebugLogger {
82
83
  private options;
83
84
  constructor(options: DebugOptions);
85
+ /**
86
+ * Check if debug is enabled - checks both local and global state
87
+ */
88
+ private isEnabled;
84
89
  /**
85
90
  * Log a debug message if debug is enabled
86
91
  */
@@ -119,20 +124,45 @@ declare function debugWarn(message: string, ...args: DebugArg[]): void;
119
124
  */
120
125
  declare function debugError(message: string, ...args: DebugArg[]): void;
121
126
  /**
122
- * Create a scoped debug logger
127
+ * Create a scoped debug logger that dynamically checks global debug state
123
128
  */
124
129
  declare function createScopedLogger(scopeName: string): DebugLogger;
125
130
 
126
- declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): T;
131
+ /**
132
+ * Throttled function with cancellation support
133
+ */
134
+ interface ThrottledFunction<T extends (...args: any[]) => any> {
135
+ (...args: Parameters<T>): void;
136
+ cancel(): void;
137
+ }
138
+ /**
139
+ * Improved throttle function with better memory management and cancellation
140
+ * @param func - The function to throttle
141
+ * @param delay - The delay in milliseconds
142
+ * @returns Throttled function with cancel method
143
+ */
144
+ declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): ThrottledFunction<T>;
145
+ /**
146
+ * Debounce function with cancellation support
147
+ * @param func - The function to debounce
148
+ * @param delay - The delay in milliseconds
149
+ * @returns Debounced function with cancel method
150
+ */
151
+ declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): ThrottledFunction<T>;
127
152
  declare function createElementCache<T extends Element = Element>(query: string, ttl?: number): () => NodeListOf<T>;
128
153
 
129
154
  declare function cn(...inputs: ClassValue[]): string;
130
155
  interface PreprEventData {
131
- segment?: string;
132
- variant?: string;
133
- editMode?: boolean;
134
- [key: string]: string | boolean | number | undefined;
156
+ readonly segment?: string;
157
+ readonly variant?: string;
158
+ readonly editMode?: boolean;
159
+ readonly [key: string]: string | boolean | number | undefined;
135
160
  }
136
- declare function sendPreprEvent(event: string, data?: PreprEventData): void;
161
+ /**
162
+ * Sends a Prepr event to the parent window
163
+ * @param event - The event type to send
164
+ * @param data - Optional event data
165
+ */
166
+ declare function sendPreprEvent(event: PreprEventType, data?: PreprEventData): void;
137
167
 
138
- export { DOMService, type DebugArg, type ErrorAdditionalData, type ErrorInfo, type PreprEventData, StegaError, type StegaErrorType, cn, createElementCache, createErrorInfo, createScopedLogger, debugError, debugLog, debugWarn, getDebugLogger, handleContextError, handleDOMError, handleStegaError, initDebugLogger, sendPreprEvent, throttle };
168
+ export { DOMService, type DebugArg, type ErrorAdditionalData, type ErrorInfo, type PreprEventData, StegaError, type StegaErrorType, type ThrottledFunction, cn, createElementCache, createErrorInfo, createScopedLogger, debounce, debugError, debugLog, debugWarn, getDebugLogger, handleContextError, handleDOMError, handleStegaError, initDebugLogger, sendPreprEvent, throttle };
@@ -1,4 +1,5 @@
1
1
  import { ClassValue } from 'clsx';
2
+ import { PreprEventType } from '../types/index.js';
2
3
 
3
4
  declare const StegaError: {
4
5
  readonly DECODE_FAILED: "STEGA_DECODE_FAILED";
@@ -75,12 +76,16 @@ declare class DOMService {
75
76
  */
76
77
  type DebugArg = string | number | boolean | null | undefined | object;
77
78
  interface DebugOptions {
78
- enabled: boolean;
79
+ enabled?: boolean;
79
80
  prefix?: string;
80
81
  }
81
82
  declare class DebugLogger {
82
83
  private options;
83
84
  constructor(options: DebugOptions);
85
+ /**
86
+ * Check if debug is enabled - checks both local and global state
87
+ */
88
+ private isEnabled;
84
89
  /**
85
90
  * Log a debug message if debug is enabled
86
91
  */
@@ -119,20 +124,45 @@ declare function debugWarn(message: string, ...args: DebugArg[]): void;
119
124
  */
120
125
  declare function debugError(message: string, ...args: DebugArg[]): void;
121
126
  /**
122
- * Create a scoped debug logger
127
+ * Create a scoped debug logger that dynamically checks global debug state
123
128
  */
124
129
  declare function createScopedLogger(scopeName: string): DebugLogger;
125
130
 
126
- declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): T;
131
+ /**
132
+ * Throttled function with cancellation support
133
+ */
134
+ interface ThrottledFunction<T extends (...args: any[]) => any> {
135
+ (...args: Parameters<T>): void;
136
+ cancel(): void;
137
+ }
138
+ /**
139
+ * Improved throttle function with better memory management and cancellation
140
+ * @param func - The function to throttle
141
+ * @param delay - The delay in milliseconds
142
+ * @returns Throttled function with cancel method
143
+ */
144
+ declare function throttle<T extends (...args: any[]) => any>(func: T, delay: number): ThrottledFunction<T>;
145
+ /**
146
+ * Debounce function with cancellation support
147
+ * @param func - The function to debounce
148
+ * @param delay - The delay in milliseconds
149
+ * @returns Debounced function with cancel method
150
+ */
151
+ declare function debounce<T extends (...args: any[]) => any>(func: T, delay: number): ThrottledFunction<T>;
127
152
  declare function createElementCache<T extends Element = Element>(query: string, ttl?: number): () => NodeListOf<T>;
128
153
 
129
154
  declare function cn(...inputs: ClassValue[]): string;
130
155
  interface PreprEventData {
131
- segment?: string;
132
- variant?: string;
133
- editMode?: boolean;
134
- [key: string]: string | boolean | number | undefined;
156
+ readonly segment?: string;
157
+ readonly variant?: string;
158
+ readonly editMode?: boolean;
159
+ readonly [key: string]: string | boolean | number | undefined;
135
160
  }
136
- declare function sendPreprEvent(event: string, data?: PreprEventData): void;
161
+ /**
162
+ * Sends a Prepr event to the parent window
163
+ * @param event - The event type to send
164
+ * @param data - Optional event data
165
+ */
166
+ declare function sendPreprEvent(event: PreprEventType, data?: PreprEventData): void;
137
167
 
138
- export { DOMService, type DebugArg, type ErrorAdditionalData, type ErrorInfo, type PreprEventData, StegaError, type StegaErrorType, cn, createElementCache, createErrorInfo, createScopedLogger, debugError, debugLog, debugWarn, getDebugLogger, handleContextError, handleDOMError, handleStegaError, initDebugLogger, sendPreprEvent, throttle };
168
+ export { DOMService, type DebugArg, type ErrorAdditionalData, type ErrorInfo, type PreprEventData, StegaError, type StegaErrorType, type ThrottledFunction, cn, createElementCache, createErrorInfo, createScopedLogger, debounce, debugError, debugLog, debugWarn, getDebugLogger, handleContextError, handleDOMError, handleStegaError, initDebugLogger, sendPreprEvent, throttle };
@@ -1,2 +1,2 @@
1
- import {a,b as b$1}from'../chunk-E7ATRJ2F.js';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';var u={DECODE_FAILED:"STEGA_DECODE_FAILED",INVALID_FORMAT:"STEGA_INVALID_FORMAT",DOM_MANIPULATION_FAILED:"DOM_MANIPULATION_FAILED",CONTEXT_NOT_FOUND:"CONTEXT_NOT_FOUND"};function p(n,e,t,r){return {type:n,context:e,message:t.message,timestamp:new Date().toISOString(),stack:t.stack,additionalData:r}}function b(n,e,t){let r=p(u.DECODE_FAILED,e,n,t);return console.error("Stega Error:",r),process.env.NODE_ENV,r}function s(n,e){let t=p(u.DOM_MANIPULATION_FAILED,e,n);return console.error("DOM Error:",t),t}function L(n){let e=new Error(`${n} must be used within its provider`),t=p(u.CONTEXT_NOT_FOUND,n,e);throw console.error("Context Error:",t),e}var D=class{static createElement(e,t){try{let r=document.createElement(e);return r.className=t,r}catch(r){throw s(r,"createElement"),r}}static appendToBody(e){try{document.body.appendChild(e);}catch(t){throw s(t,"appendToBody"),t}}static removeFromBody(e){try{e.parentNode&&e.parentNode.removeChild(e);}catch(t){throw s(t,"removeFromBody"),t}}static setElementStyles(e,t){try{Object.entries(t).forEach(([r,o])=>{e.style.setProperty(r,o);});}catch(r){throw s(r,"setElementStyles"),r}}static getElementRect(e){try{return e.getBoundingClientRect()}catch(t){throw s(t,"getElementRect"),t}}static isElementInViewport(e){try{let t=this.getElementRect(e);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}catch(t){return s(t,"isElementInViewport"),false}}static calculateDistance(e,t,r,o){return Math.sqrt(Math.pow(r-e,2)+Math.pow(o-t,2))}static findClosestElement(e,t,r){try{let o=null,i=1/0;return r.forEach(d=>{let c=this.getElementRect(d),m=this.calculateDistance(e,t,c.left+c.width/2,c.top+c.height/2);m<i&&(i=m,o=d);}),o}catch(o){return s(o,"findClosestElement"),null}}static addEventListener(e,t,r,o){try{e.addEventListener(t,r,o);}catch(i){throw s(i,"addEventListener"),i}}static removeEventListener(e,t,r,o){try{e.removeEventListener(t,r,o);}catch(i){throw s(i,"removeEventListener"),i}}};var g=class n{constructor(e){this.options=a({prefix:"[Prepr]"},e);}log(e,...t){if(!this.options.enabled)return;let r=this.options.prefix;console.log(`${r} ${e}`,...t);}warn(e,...t){if(!this.options.enabled)return;let r=this.options.prefix;console.warn(`${r} ${e}`,...t);}error(e,...t){if(!this.options.enabled)return;let r=this.options.prefix;console.error(`${r} ${e}`,...t);}scope(e){return new n(b$1(a({},this.options),{prefix:`${this.options.prefix}[${e}]`}))}},l=null;function O(n=false){l=new g({enabled:n});}function E(){return l||(l=new g({enabled:false})),l}function y(n,...e){E().log(n,...e);}function A(n,...e){E().warn(n,...e);}function M(n,...e){E().error(n,...e);}function I(n){return E().scope(n)}function C(n,e){let t=null,r=0;return (...o)=>{let i=Date.now();i-r>e?(n(...o),r=i):(t&&clearTimeout(t),t=setTimeout(()=>{n(...o),r=Date.now();},e-(i-r)));}}function S(n,e=1e3){let t=null,r=0;return ()=>{let o=Date.now();return (!t||o-r>e)&&(t=document.querySelectorAll(n),r=o),t}}function $(...n){return twMerge(clsx(n))}function k(n,e){window.parent.postMessage(a({name:"prepr_preview_bar",event:n},e));}export{D as DOMService,u as StegaError,$ as cn,S as createElementCache,p as createErrorInfo,I as createScopedLogger,M as debugError,y as debugLog,A as debugWarn,E as getDebugLogger,L as handleContextError,s as handleDOMError,b as handleStegaError,O as initDebugLogger,k as sendPreprEvent,C as throttle};//# sourceMappingURL=index.js.map
1
+ import {a,b}from'../chunk-E7ATRJ2F.js';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';var E={DECODE_FAILED:"STEGA_DECODE_FAILED",INVALID_FORMAT:"STEGA_INVALID_FORMAT",DOM_MANIPULATION_FAILED:"DOM_MANIPULATION_FAILED",CONTEXT_NOT_FOUND:"CONTEXT_NOT_FOUND"};function p(n,t,e,r){return {type:n,context:t,message:e.message,timestamp:new Date().toISOString(),stack:e.stack,additionalData:r}}function D(n,t,e){let r=p(E.DECODE_FAILED,t,n,e);return console.error("Stega Error:",r),process.env.NODE_ENV,r}function s(n,t){let e=p(E.DOM_MANIPULATION_FAILED,t,n);return console.error("DOM Error:",e),e}function x(n){let t=new Error(`${n} must be used within its provider`),e=p(E.CONTEXT_NOT_FOUND,n,t);throw console.error("Context Error:",e),t}var T=class{static createElement(t,e){try{let r=document.createElement(t);return r.className=e,r}catch(r){throw s(r,"createElement"),r}}static appendToBody(t){try{document.body.appendChild(t);}catch(e){throw s(e,"appendToBody"),e}}static removeFromBody(t){try{t.parentNode&&t.parentNode.removeChild(t);}catch(e){throw s(e,"removeFromBody"),e}}static setElementStyles(t,e){try{Object.entries(e).forEach(([r,o])=>{t.style.setProperty(r,o);});}catch(r){throw s(r,"setElementStyles"),r}}static getElementRect(t){try{return t.getBoundingClientRect()}catch(e){throw s(e,"getElementRect"),e}}static isElementInViewport(t){try{let e=this.getElementRect(t);return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}catch(e){return s(e,"isElementInViewport"),false}}static calculateDistance(t,e,r,o){return Math.sqrt(Math.pow(r-t,2)+Math.pow(o-e,2))}static findClosestElement(t,e,r){try{let o=null,i=1/0;return r.forEach(c=>{let a=this.getElementRect(c),m=this.calculateDistance(t,e,a.left+a.width/2,a.top+a.height/2);m<i&&(i=m,o=c);}),o}catch(o){return s(o,"findClosestElement"),null}}static addEventListener(t,e,r,o){try{t.addEventListener(e,r,o);}catch(i){throw s(i,"addEventListener"),i}}static removeEventListener(t,e,r,o){try{t.removeEventListener(e,r,o);}catch(i){throw s(i,"removeEventListener"),i}}};var d=class n{constructor(t){this.options=a({prefix:"[Prepr]"},t);}isEnabled(){var t,e;return this.options.enabled!==void 0?this.options.enabled:(e=(t=l==null?void 0:l.options)==null?void 0:t.enabled)!=null?e:false}log(t,...e){if(!this.isEnabled())return;let r=this.options.prefix;console.log(`${r} ${t}`,...e);}warn(t,...e){if(!this.isEnabled())return;let r=this.options.prefix;console.warn(`${r} ${t}`,...e);}error(t,...e){if(!this.isEnabled())return;let r=this.options.prefix;console.error(`${r} ${t}`,...e);}scope(t){return new n(b(a({},this.options),{prefix:`${this.options.prefix}[${t}]`}))}},l=null;function w(n=false){l=new d({enabled:n});}function g(){return l||(l=new d({enabled:false})),l}function O(n,...t){g().log(n,...t);}function A(n,...t){g().warn(n,...t);}function M(n,...t){g().error(n,...t);}function I(n){return new d({prefix:`[Prepr][${n}]`})}function F(n,t){let e=null,r=0,o=(...i)=>{let c=Date.now(),a=c-r;a>=t?(n(...i),r=c):(e&&clearTimeout(e),e=setTimeout(()=>{n(...i),r=Date.now(),e=null;},t-a));};return o.cancel=()=>{e&&(clearTimeout(e),e=null);},o}function S(n,t){let e=null,r=(...o)=>{e&&clearTimeout(e),e=setTimeout(()=>{n(...o),e=null;},t);};return r.cancel=()=>{e&&(clearTimeout(e),e=null);},r}function C(n,t=1e3){let e=null,r=0;return ()=>{let o=Date.now();return (!e||o-r>t)&&(e=document.querySelectorAll(n),r=o),e}}function V(...n){return twMerge(clsx(n))}function k(n,t){typeof window!="undefined"&&window.parent&&window.parent.postMessage(a({name:"prepr_preview_bar",event:n},t),"*");}export{T as DOMService,E as StegaError,V as cn,C as createElementCache,p as createErrorInfo,I as createScopedLogger,S as debounce,M as debugError,O as debugLog,A as debugWarn,g as getDebugLogger,x as handleContextError,s as handleDOMError,D as handleStegaError,w as initDebugLogger,k as sendPreprEvent,F as throttle};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/errors.ts","../../src/utils/dom.ts","../../src/utils/debug.ts","../../src/utils/performance.ts","../../src/utils/index.ts"],"names":["StegaError","createErrorInfo","type","context","error","additionalData","handleStegaError","errorInfo","handleDOMError","handleContextError","contextName","DOMService","tag","className","element","styles","property","value","rect","x1","y1","x2","y2","pointX","pointY","elements","closestElement","minDistance","distance","event","handler","options","DebugLogger","_DebugLogger","__spreadValues","message","args","prefix","scopeName","__spreadProps","globalDebugLogger","initDebugLogger","enabled","getDebugLogger","debugLog","debugWarn","debugError","createScopedLogger","throttle","func","delay","timeoutId","lastExecTime","currentTime","createElementCache","query","ttl","cache","lastCacheTime","now","cn","inputs","twMerge","clsx","sendPreprEvent","data"],"mappings":"2GAAO,IAAMA,CAAAA,CAAa,CACxB,aAAA,CAAe,qBAAA,CACf,eAAgB,sBAAA,CAChB,uBAAA,CAAyB,0BACzB,iBAAA,CAAmB,mBACrB,EAqBO,SAASC,CAAAA,CACdC,EACAC,CAAAA,CACAC,CAAAA,CACAC,EACW,CACX,OAAO,CACL,IAAA,CAAAH,CAAAA,CACA,QAAAC,CAAAA,CACA,OAAA,CAASC,EAAM,OAAA,CACf,SAAA,CAAW,IAAI,IAAA,EAAK,CAAE,aAAY,CAClC,KAAA,CAAOA,EAAM,KAAA,CACb,cAAA,CAAAC,CACF,CACF,CAEO,SAASC,CAAAA,CACdF,EACAD,CAAAA,CACAE,CAAAA,CACA,CACA,IAAME,CAAAA,CAAYN,EAChBD,CAAAA,CAAW,aAAA,CACXG,EACAC,CAAAA,CACAC,CACF,EAEA,OAAA,OAAA,CAAQ,KAAA,CAAM,eAAgBE,CAAS,CAAA,CAGnC,QAAQ,GAAA,CAAI,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A,CAAuB,CACnE,OAAO,MAAA,CAAO,WAAA,CAAY/B,EAAA,CACxB,IAAA,CAAM,oBACN,KAAA,CAAAL,CAAAA,CAAAA,CACGoC,EACJ,EACH","file":"index.js","sourcesContent":["export const StegaError = {\n DECODE_FAILED: 'STEGA_DECODE_FAILED',\n INVALID_FORMAT: 'STEGA_INVALID_FORMAT',\n DOM_MANIPULATION_FAILED: 'DOM_MANIPULATION_FAILED',\n CONTEXT_NOT_FOUND: 'CONTEXT_NOT_FOUND',\n} as const;\n\nexport type StegaErrorType = (typeof StegaError)[keyof typeof StegaError];\n\n// Define specific types for error additional data\nexport interface ErrorAdditionalData {\n input?: string;\n element?: HTMLElement;\n context?: string;\n [key: string]: string | HTMLElement | undefined;\n}\n\nexport interface ErrorInfo {\n type: StegaErrorType;\n context: string;\n message: string;\n timestamp: string;\n stack?: string;\n additionalData?: ErrorAdditionalData;\n}\n\nexport function createErrorInfo(\n type: StegaErrorType,\n context: string,\n error: Error,\n additionalData?: ErrorAdditionalData\n): ErrorInfo {\n return {\n type,\n context,\n message: error.message,\n timestamp: new Date().toISOString(),\n stack: error.stack,\n additionalData,\n };\n}\n\nexport function handleStegaError(\n error: Error,\n context: string,\n additionalData?: ErrorAdditionalData\n) {\n const errorInfo = createErrorInfo(\n StegaError.DECODE_FAILED,\n context,\n error,\n additionalData\n );\n\n console.error('Stega Error:', errorInfo);\n\n // In production, you might want to send this to an error tracking service\n if (process.env.NODE_ENV === 'production') {\n // sendToErrorTrackingService(errorInfo);\n }\n\n return errorInfo;\n}\n\nexport function handleDOMError(error: Error, context: string) {\n const errorInfo = createErrorInfo(\n StegaError.DOM_MANIPULATION_FAILED,\n context,\n error\n );\n\n console.error('DOM Error:', errorInfo);\n return errorInfo;\n}\n\nexport function handleContextError(contextName: string) {\n const error = new Error(`${contextName} must be used within its provider`);\n const errorInfo = createErrorInfo(\n StegaError.CONTEXT_NOT_FOUND,\n contextName,\n error\n );\n\n console.error('Context Error:', errorInfo);\n throw error;\n}\n","import { handleDOMError } from './errors';\n\nexport class DOMService {\n /**\n * Creates an HTML element with specified tag and class name\n */\n static createElement(tag: string, className: string): HTMLElement {\n try {\n const element = document.createElement(tag);\n element.className = className;\n return element;\n } catch (error) {\n handleDOMError(error as Error, 'createElement');\n throw error;\n }\n }\n\n /**\n * Appends an element to the document body\n */\n static appendToBody(element: HTMLElement): void {\n try {\n document.body.appendChild(element);\n } catch (error) {\n handleDOMError(error as Error, 'appendToBody');\n throw error;\n }\n }\n\n /**\n * Removes an element from the document body\n */\n static removeFromBody(element: HTMLElement): void {\n try {\n if (element.parentNode) {\n element.parentNode.removeChild(element);\n }\n } catch (error) {\n handleDOMError(error as Error, 'removeFromBody');\n throw error;\n }\n }\n\n /**\n * Sets multiple CSS properties on an element\n */\n static setElementStyles(\n element: HTMLElement,\n styles: Record<string, string>\n ): void {\n try {\n Object.entries(styles).forEach(([property, value]) => {\n element.style.setProperty(property, value);\n });\n } catch (error) {\n handleDOMError(error as Error, 'setElementStyles');\n throw error;\n }\n }\n\n /**\n * Gets the bounding rectangle of an element\n */\n static getElementRect(element: HTMLElement): DOMRect {\n try {\n return element.getBoundingClientRect();\n } catch (error) {\n handleDOMError(error as Error, 'getElementRect');\n throw error;\n }\n }\n\n /**\n * Checks if an element is in the viewport\n */\n static isElementInViewport(element: HTMLElement): boolean {\n try {\n const rect = this.getElementRect(element);\n return (\n rect.top >= 0 &&\n rect.left >= 0 &&\n rect.bottom <=\n (window.innerHeight || document.documentElement.clientHeight) &&\n rect.right <=\n (window.innerWidth || document.documentElement.clientWidth)\n );\n } catch (error) {\n handleDOMError(error as Error, 'isElementInViewport');\n return false;\n }\n }\n\n /**\n * Calculates distance between two points\n */\n static calculateDistance(\n x1: number,\n y1: number,\n x2: number,\n y2: number\n ): number {\n return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));\n }\n\n /**\n * Finds the closest element to a point from a list of elements\n */\n static findClosestElement(\n pointX: number,\n pointY: number,\n elements: NodeListOf<Element>\n ): HTMLElement | null {\n try {\n let closestElement: HTMLElement | null = null;\n let minDistance = Infinity;\n\n elements.forEach(element => {\n const rect = this.getElementRect(element as HTMLElement);\n const distance = this.calculateDistance(\n pointX,\n pointY,\n rect.left + rect.width / 2,\n rect.top + rect.height / 2\n );\n\n if (distance < minDistance) {\n minDistance = distance;\n closestElement = element as HTMLElement;\n }\n });\n\n return closestElement;\n } catch (error) {\n handleDOMError(error as Error, 'findClosestElement');\n return null;\n }\n }\n\n /**\n * Safely adds event listeners\n */\n static addEventListener(\n element: EventTarget,\n event: string,\n handler: EventListener,\n options?: AddEventListenerOptions\n ): void {\n try {\n element.addEventListener(event, handler, options);\n } catch (error) {\n handleDOMError(error as Error, 'addEventListener');\n throw error;\n }\n }\n\n /**\n * Safely removes event listeners\n */\n static removeEventListener(\n element: EventTarget,\n event: string,\n handler: EventListener,\n options?: EventListenerOptions\n ): void {\n try {\n element.removeEventListener(event, handler, options);\n } catch (error) {\n handleDOMError(error as Error, 'removeEventListener');\n throw error;\n }\n }\n}\n","/**\n * Debug utility for Prepr Next.js package\n * Provides centralized debug logging with performance optimizations\n */\n\n// Define specific types for debug arguments\nexport type DebugArg = string | number | boolean | null | undefined | object;\n\ninterface DebugOptions {\n enabled: boolean;\n prefix?: string;\n}\n\nclass DebugLogger {\n private options: DebugOptions;\n\n constructor(options: DebugOptions) {\n this.options = {\n prefix: '[Prepr]',\n ...options,\n };\n }\n\n /**\n * Log a debug message if debug is enabled\n */\n log(message: string, ...args: DebugArg[]): void {\n if (!this.options.enabled) return;\n\n const prefix = this.options.prefix;\n console.log(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Log a debug warning if debug is enabled\n */\n warn(message: string, ...args: DebugArg[]): void {\n if (!this.options.enabled) return;\n\n const prefix = this.options.prefix;\n console.warn(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Log a debug error if debug is enabled\n */\n error(message: string, ...args: DebugArg[]): void {\n if (!this.options.enabled) return;\n\n const prefix = this.options.prefix;\n console.error(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Create a scoped logger with additional context\n */\n scope(scopeName: string): DebugLogger {\n return new DebugLogger({\n ...this.options,\n prefix: `${this.options.prefix}[${scopeName}]`,\n });\n }\n}\n\n// Global debug instance\nlet globalDebugLogger: DebugLogger | null = null;\n\n/**\n * Initialize the debug logger\n */\nexport function initDebugLogger(enabled: boolean = false): void {\n globalDebugLogger = new DebugLogger({ enabled });\n}\n\n/**\n * Get the debug logger instance\n */\nexport function getDebugLogger(): DebugLogger {\n if (!globalDebugLogger) {\n // Fallback to disabled logger if not initialized\n globalDebugLogger = new DebugLogger({ enabled: false });\n }\n return globalDebugLogger;\n}\n\n/**\n * Convenience function for logging\n */\nexport function debugLog(message: string, ...args: DebugArg[]): void {\n getDebugLogger().log(message, ...args);\n}\n\n/**\n * Convenience function for warning\n */\nexport function debugWarn(message: string, ...args: DebugArg[]): void {\n getDebugLogger().warn(message, ...args);\n}\n\n/**\n * Convenience function for errors\n */\nexport function debugError(message: string, ...args: DebugArg[]): void {\n getDebugLogger().error(message, ...args);\n}\n\n/**\n * Create a scoped debug logger\n */\nexport function createScopedLogger(scopeName: string): DebugLogger {\n return getDebugLogger().scope(scopeName);\n}\n","// Performance utilities\n\n// TODO: Refine the type for args and return value if possible\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n delay: number\n): T {\n let timeoutId: NodeJS.Timeout | null = null;\n let lastExecTime = 0;\n\n return ((...args: unknown[]) => {\n const currentTime = Date.now();\n if (currentTime - lastExecTime > delay) {\n func(...(args as Parameters<T>));\n lastExecTime = currentTime;\n } else {\n if (timeoutId) clearTimeout(timeoutId);\n timeoutId = setTimeout(\n () => {\n func(...(args as Parameters<T>));\n lastExecTime = Date.now();\n },\n delay - (currentTime - lastExecTime)\n );\n }\n }) as T;\n}\n\n// Simple DOM element cache for querySelectorAll\nexport function createElementCache<T extends Element = Element>(\n query: string,\n ttl: number = 1000\n) {\n let cache: NodeListOf<T> | null = null;\n let lastCacheTime = 0;\n return () => {\n const now = Date.now();\n if (!cache || now - lastCacheTime > ttl) {\n cache = document.querySelectorAll<T>(query);\n lastCacheTime = now;\n }\n return cache;\n };\n}\n","import { ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// Define specific types for Prepr events\nexport interface PreprEventData {\n segment?: string;\n variant?: string;\n editMode?: boolean;\n [key: string]: string | boolean | number | undefined;\n}\n\nexport function sendPreprEvent(event: string, data?: PreprEventData) {\n window.parent.postMessage({\n name: 'prepr_preview_bar',\n event,\n ...data,\n });\n}\n\n// Export error handling utilities\nexport * from './errors';\n\n// Export DOM service\nexport * from './dom';\n\n// Export debug utilities\nexport * from './debug';\n\n// Export performance utilities\nexport * from './performance';\n"]}
1
+ {"version":3,"sources":["../../src/utils/errors.ts","../../src/utils/dom.ts","../../src/utils/debug.ts","../../src/utils/performance.ts","../../src/utils/index.ts"],"names":["StegaError","createErrorInfo","type","context","error","additionalData","handleStegaError","errorInfo","handleDOMError","handleContextError","contextName","DOMService","tag","className","element","styles","property","value","rect","x1","y1","x2","y2","pointX","pointY","elements","closestElement","minDistance","distance","event","handler","options","DebugLogger","_DebugLogger","__spreadValues","_a","_b","globalDebugLogger","message","args","prefix","scopeName","__spreadProps","initDebugLogger","enabled","getDebugLogger","debugLog","debugWarn","debugError","createScopedLogger","throttle","func","delay","timeoutId","lastExecTime","throttledFunc","currentTime","timeSinceLastExec","debounce","debouncedFunc","createElementCache","query","ttl","cache","lastCacheTime","now","cn","inputs","twMerge","clsx","sendPreprEvent","data"],"mappings":"oGAAO,IAAMA,CAAAA,CAAa,CACxB,aAAA,CAAe,sBACf,cAAA,CAAgB,sBAAA,CAChB,wBAAyB,yBAAA,CACzB,iBAAA,CAAmB,mBACrB,EAqBO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,EACW,CACX,OAAO,CACL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OM,CACT,CAGO,SAASC,CAAAA,CACdC,EACAC,CAAAA,CAAc,GAAA,CACd,CACA,IAAIC,CAAAA,CAA8B,IAAA,CAC9BC,EAAgB,CAAA,CACpB,OAAO,IAAM,CACX,IAAMC,CAAAA,CAAM,KAAK,GAAA,EAAI,CACrB,QAAI,CAACF,CAAAA,EAASE,EAAMD,CAAAA,CAAgBF,CAAAA,IAClCC,CAAAA,CAAQ,QAAA,CAAS,gBAAA,CAAoBF,CAAK,EAC1CG,CAAAA,CAAgBC,CAAAA,CAAAA,CAEXF,CACT,CACF,CC/FO,SAASG,CAAAA,CAAAA,GAAMC,CAAAA,CAAsB,CAC1C,OAAOC,OAAAA,CAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC7B,CAeO,SAASG,CAAAA,CACdzC,EACA0C,CAAAA,CACM,CACF,OAAO,MAAA,EAAW,WAAA,EAAe,MAAA,CAAO,QAC1C,MAAA,CAAO,MAAA,CAAO,WAAA,CACZrC,CAAAA,CAAA,CACE,IAAA,CAAM,oBACN,KAAA,CAAAL,CAAAA,CAAAA,CACG0C,CAAAA,CAAAA,CAEL,GACF,EAEJ","file":"index.js","sourcesContent":["export const StegaError = {\n DECODE_FAILED: 'STEGA_DECODE_FAILED',\n INVALID_FORMAT: 'STEGA_INVALID_FORMAT',\n DOM_MANIPULATION_FAILED: 'DOM_MANIPULATION_FAILED',\n CONTEXT_NOT_FOUND: 'CONTEXT_NOT_FOUND',\n} as const;\n\nexport type StegaErrorType = (typeof StegaError)[keyof typeof StegaError];\n\n// Define specific types for error additional data\nexport interface ErrorAdditionalData {\n input?: string;\n element?: HTMLElement;\n context?: string;\n [key: string]: string | HTMLElement | undefined;\n}\n\nexport interface ErrorInfo {\n type: StegaErrorType;\n context: string;\n message: string;\n timestamp: string;\n stack?: string;\n additionalData?: ErrorAdditionalData;\n}\n\nexport function createErrorInfo(\n type: StegaErrorType,\n context: string,\n error: Error,\n additionalData?: ErrorAdditionalData\n): ErrorInfo {\n return {\n type,\n context,\n message: error.message,\n timestamp: new Date().toISOString(),\n stack: error.stack,\n additionalData,\n };\n}\n\nexport function handleStegaError(\n error: Error,\n context: string,\n additionalData?: ErrorAdditionalData\n) {\n const errorInfo = createErrorInfo(\n StegaError.DECODE_FAILED,\n context,\n error,\n additionalData\n );\n\n console.error('Stega Error:', errorInfo);\n\n // In production, you might want to send this to an error tracking service\n if (process.env.NODE_ENV === 'production') {\n // sendToErrorTrackingService(errorInfo);\n }\n\n return errorInfo;\n}\n\nexport function handleDOMError(error: Error, context: string) {\n const errorInfo = createErrorInfo(\n StegaError.DOM_MANIPULATION_FAILED,\n context,\n error\n );\n\n console.error('DOM Error:', errorInfo);\n return errorInfo;\n}\n\nexport function handleContextError(contextName: string) {\n const error = new Error(`${contextName} must be used within its provider`);\n const errorInfo = createErrorInfo(\n StegaError.CONTEXT_NOT_FOUND,\n contextName,\n error\n );\n\n console.error('Context Error:', errorInfo);\n throw error;\n}\n","import { handleDOMError } from './errors';\n\nexport class DOMService {\n /**\n * Creates an HTML element with specified tag and class name\n */\n static createElement(tag: string, className: string): HTMLElement {\n try {\n const element = document.createElement(tag);\n element.className = className;\n return element;\n } catch (error) {\n handleDOMError(error as Error, 'createElement');\n throw error;\n }\n }\n\n /**\n * Appends an element to the document body\n */\n static appendToBody(element: HTMLElement): void {\n try {\n document.body.appendChild(element);\n } catch (error) {\n handleDOMError(error as Error, 'appendToBody');\n throw error;\n }\n }\n\n /**\n * Removes an element from the document body\n */\n static removeFromBody(element: HTMLElement): void {\n try {\n if (element.parentNode) {\n element.parentNode.removeChild(element);\n }\n } catch (error) {\n handleDOMError(error as Error, 'removeFromBody');\n throw error;\n }\n }\n\n /**\n * Sets multiple CSS properties on an element\n */\n static setElementStyles(\n element: HTMLElement,\n styles: Record<string, string>\n ): void {\n try {\n Object.entries(styles).forEach(([property, value]) => {\n element.style.setProperty(property, value);\n });\n } catch (error) {\n handleDOMError(error as Error, 'setElementStyles');\n throw error;\n }\n }\n\n /**\n * Gets the bounding rectangle of an element\n */\n static getElementRect(element: HTMLElement): DOMRect {\n try {\n return element.getBoundingClientRect();\n } catch (error) {\n handleDOMError(error as Error, 'getElementRect');\n throw error;\n }\n }\n\n /**\n * Checks if an element is in the viewport\n */\n static isElementInViewport(element: HTMLElement): boolean {\n try {\n const rect = this.getElementRect(element);\n return (\n rect.top >= 0 &&\n rect.left >= 0 &&\n rect.bottom <=\n (window.innerHeight || document.documentElement.clientHeight) &&\n rect.right <=\n (window.innerWidth || document.documentElement.clientWidth)\n );\n } catch (error) {\n handleDOMError(error as Error, 'isElementInViewport');\n return false;\n }\n }\n\n /**\n * Calculates distance between two points\n */\n static calculateDistance(\n x1: number,\n y1: number,\n x2: number,\n y2: number\n ): number {\n return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));\n }\n\n /**\n * Finds the closest element to a point from a list of elements\n */\n static findClosestElement(\n pointX: number,\n pointY: number,\n elements: NodeListOf<Element>\n ): HTMLElement | null {\n try {\n let closestElement: HTMLElement | null = null;\n let minDistance = Infinity;\n\n elements.forEach(element => {\n const rect = this.getElementRect(element as HTMLElement);\n const distance = this.calculateDistance(\n pointX,\n pointY,\n rect.left + rect.width / 2,\n rect.top + rect.height / 2\n );\n\n if (distance < minDistance) {\n minDistance = distance;\n closestElement = element as HTMLElement;\n }\n });\n\n return closestElement;\n } catch (error) {\n handleDOMError(error as Error, 'findClosestElement');\n return null;\n }\n }\n\n /**\n * Safely adds event listeners\n */\n static addEventListener(\n element: EventTarget,\n event: string,\n handler: EventListener,\n options?: AddEventListenerOptions\n ): void {\n try {\n element.addEventListener(event, handler, options);\n } catch (error) {\n handleDOMError(error as Error, 'addEventListener');\n throw error;\n }\n }\n\n /**\n * Safely removes event listeners\n */\n static removeEventListener(\n element: EventTarget,\n event: string,\n handler: EventListener,\n options?: EventListenerOptions\n ): void {\n try {\n element.removeEventListener(event, handler, options);\n } catch (error) {\n handleDOMError(error as Error, 'removeEventListener');\n throw error;\n }\n }\n}\n","/**\n * Debug utility for Prepr Next.js package\n * Provides centralized debug logging with performance optimizations\n */\n\n// Define specific types for debug arguments\nexport type DebugArg = string | number | boolean | null | undefined | object;\n\ninterface DebugOptions {\n enabled?: boolean;\n prefix?: string;\n}\n\nclass DebugLogger {\n private options: DebugOptions;\n\n constructor(options: DebugOptions) {\n this.options = {\n prefix: '[Prepr]',\n ...options,\n };\n }\n\n /**\n * Check if debug is enabled - checks both local and global state\n */\n private isEnabled(): boolean {\n // If this logger has a local enabled state, use it\n if (this.options.enabled !== undefined) {\n return this.options.enabled;\n }\n\n // Otherwise, check the global logger state\n return globalDebugLogger?.options?.enabled ?? false;\n }\n\n /**\n * Log a debug message if debug is enabled\n */\n log(message: string, ...args: DebugArg[]): void {\n if (!this.isEnabled()) return;\n\n const prefix = this.options.prefix;\n console.log(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Log a debug warning if debug is enabled\n */\n warn(message: string, ...args: DebugArg[]): void {\n if (!this.isEnabled()) return;\n\n const prefix = this.options.prefix;\n console.warn(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Log a debug error if debug is enabled\n */\n error(message: string, ...args: DebugArg[]): void {\n if (!this.isEnabled()) return;\n\n const prefix = this.options.prefix;\n console.error(`${prefix} ${message}`, ...args);\n }\n\n /**\n * Create a scoped logger with additional context\n */\n scope(scopeName: string): DebugLogger {\n return new DebugLogger({\n ...this.options,\n prefix: `${this.options.prefix}[${scopeName}]`,\n });\n }\n}\n\n// Global debug instance\nlet globalDebugLogger: DebugLogger | null = null;\n\n/**\n * Initialize the debug logger\n */\nexport function initDebugLogger(enabled: boolean = false): void {\n globalDebugLogger = new DebugLogger({ enabled });\n}\n\n/**\n * Get the debug logger instance\n */\nexport function getDebugLogger(): DebugLogger {\n if (!globalDebugLogger) {\n // Fallback to disabled logger if not initialized\n globalDebugLogger = new DebugLogger({ enabled: false });\n }\n return globalDebugLogger;\n}\n\n/**\n * Convenience function for logging\n */\nexport function debugLog(message: string, ...args: DebugArg[]): void {\n getDebugLogger().log(message, ...args);\n}\n\n/**\n * Convenience function for warning\n */\nexport function debugWarn(message: string, ...args: DebugArg[]): void {\n getDebugLogger().warn(message, ...args);\n}\n\n/**\n * Convenience function for errors\n */\nexport function debugError(message: string, ...args: DebugArg[]): void {\n getDebugLogger().error(message, ...args);\n}\n\n/**\n * Create a scoped debug logger that dynamically checks global debug state\n */\nexport function createScopedLogger(scopeName: string): DebugLogger {\n // Create a scoped logger without its own enabled state\n // This allows it to dynamically check the global logger state\n return new DebugLogger({\n prefix: `[Prepr][${scopeName}]`,\n });\n}\n","// Performance utilities\n\n/**\n * Throttled function with cancellation support\n */\nexport interface ThrottledFunction<T extends (...args: any[]) => any> {\n (...args: Parameters<T>): void;\n cancel(): void;\n}\n\n/**\n * Improved throttle function with better memory management and cancellation\n * @param func - The function to throttle\n * @param delay - The delay in milliseconds\n * @returns Throttled function with cancel method\n */\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n delay: number\n): ThrottledFunction<T> {\n let timeoutId: NodeJS.Timeout | null = null;\n let lastExecTime = 0;\n\n const throttledFunc = ((...args: Parameters<T>) => {\n const currentTime = Date.now();\n const timeSinceLastExec = currentTime - lastExecTime;\n\n if (timeSinceLastExec >= delay) {\n func(...args);\n lastExecTime = currentTime;\n } else {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => {\n func(...args);\n lastExecTime = Date.now();\n timeoutId = null;\n }, delay - timeSinceLastExec);\n }\n }) as ThrottledFunction<T>;\n\n throttledFunc.cancel = () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return throttledFunc;\n}\n\n/**\n * Debounce function with cancellation support\n * @param func - The function to debounce\n * @param delay - The delay in milliseconds\n * @returns Debounced function with cancel method\n */\nexport function debounce<T extends (...args: any[]) => any>(\n func: T,\n delay: number\n): ThrottledFunction<T> {\n let timeoutId: NodeJS.Timeout | null = null;\n\n const debouncedFunc = ((...args: Parameters<T>) => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => {\n func(...args);\n timeoutId = null;\n }, delay);\n }) as ThrottledFunction<T>;\n\n debouncedFunc.cancel = () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return debouncedFunc;\n}\n\n// Simple DOM element cache for querySelectorAll\nexport function createElementCache<T extends Element = Element>(\n query: string,\n ttl: number = 1000\n) {\n let cache: NodeListOf<T> | null = null;\n let lastCacheTime = 0;\n return () => {\n const now = Date.now();\n if (!cache || now - lastCacheTime > ttl) {\n cache = document.querySelectorAll<T>(query);\n lastCacheTime = now;\n }\n return cache;\n };\n}\n","import { ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport { PreprEventType } from '../types';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// Define specific types for Prepr events\nexport interface PreprEventData {\n readonly segment?: string;\n readonly variant?: string;\n readonly editMode?: boolean;\n readonly [key: string]: string | boolean | number | undefined;\n}\n\n/**\n * Sends a Prepr event to the parent window\n * @param event - The event type to send\n * @param data - Optional event data\n */\nexport function sendPreprEvent(\n event: PreprEventType,\n data?: PreprEventData\n): void {\n if (typeof window !== 'undefined' && window.parent) {\n window.parent.postMessage(\n {\n name: 'prepr_preview_bar',\n event,\n ...data,\n },\n '*'\n );\n }\n}\n\n// Export error handling utilities\nexport * from './errors';\n\n// Export DOM service\nexport * from './dom';\n\n// Export debug utilities\nexport * from './debug';\n\n// Export performance utilities\nexport * from './performance';\n"]}
package/package.json CHANGED
@@ -1,27 +1,11 @@
1
1
  {
2
2
  "name": "@preprio/prepr-nextjs",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0",
4
4
  "description": "Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities",
5
5
  "main": "dist/react/index.cjs",
6
6
  "types": "./dist/react/index.d.ts",
7
7
  "module": "./dist/react/index.js",
8
8
  "type": "module",
9
- "scripts": {
10
- "build": "tsup",
11
- "dev": "tsup --watch",
12
- "dev:css": "postcss ./src/globals.css -o ./src/output.css --watch",
13
- "build:css": "NODE_ENV=production postcss ./src/globals.css -o ./dist/index.css",
14
- "test": "echo \"Error: no test specified\" && exit 1",
15
- "clean": "rm -rf dist",
16
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
17
- "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
18
- "release": "node scripts/release.js",
19
- "check": "npm run type-check && npm run lint:check && npm run format:check",
20
- "type-check": "tsc --noEmit",
21
- "lint": "eslint src --ext .ts,.tsx --fix",
22
- "lint:check": "eslint src --ext .ts,.tsx",
23
- "prepublishOnly": "npm run check && npm run build"
24
- },
25
9
  "exports": {
26
10
  "./middleware": {
27
11
  "import": "./dist/middleware/index.js",
@@ -38,11 +22,6 @@
38
22
  "types": "./dist/react/index.d.ts",
39
23
  "require": "./dist/react/index.cjs"
40
24
  },
41
- "./contexts": {
42
- "import": "./dist/contexts/index.js",
43
- "types": "./dist/contexts/index.d.ts",
44
- "require": "./dist/contexts/index.cjs"
45
- },
46
25
  "./utils": {
47
26
  "import": "./dist/utils/index.js",
48
27
  "types": "./dist/utils/index.d.ts",
@@ -76,8 +55,8 @@
76
55
  ],
77
56
  "author": "Preprio",
78
57
  "license": "MIT",
79
- "packageManager": "pnpm@10.5.2",
80
58
  "devDependencies": {
59
+ "@changesets/cli": "^2.29.5",
81
60
  "@eslint/js": "^9.25.1",
82
61
  "@types/node": "^20.11.5",
83
62
  "@types/react": "19.1.0",
@@ -113,5 +92,15 @@
113
92
  "clsx": "^2.1.1",
114
93
  "postcss-cli": "^11.0.1",
115
94
  "tailwind-merge": "^3.0.1"
95
+ },
96
+ "scripts": {
97
+ "build": "tsup",
98
+ "dev": "tsup --watch",
99
+ "clean": "rm -rf dist",
100
+ "check": "tsc --noEmit && eslint src --ext .ts,.tsx && prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
101
+ "fix": "eslint src --ext .ts,.tsx --fix && prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
102
+ "changeset": "changeset",
103
+ "version": "changeset version",
104
+ "release": "pnpm run build && changeset publish"
116
105
  }
117
- }
106
+ }