buzzcasting-utils 1.12.3 → 1.13.5

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.
@@ -142,6 +142,22 @@ export declare interface Data {
142
142
 
143
143
  export declare const debounce: (func: Function, timeout?: number) => (...args: any[]) => void;
144
144
 
145
+ /**
146
+ * Interface of a Snowflake after `Generator.deconstruct()`.
147
+ * @property {bigint} snowflake - Snowflake deconstructed from
148
+ * @property {bigint} timestamp - The timestamp the snowflake was generated
149
+ * @property {bigint} shard_id - The shard_id used when generating
150
+ * @property {bigint} increment - The increment of this snowflake
151
+ * @property {string} binary - The 64Bit snowflake binary string
152
+ * @interface DeconstructedSnowflake
153
+ */
154
+ declare interface DeconstructedSnowflake {
155
+ timestamp: number;
156
+ shard_id: number;
157
+ sequence: number;
158
+ binary: string;
159
+ }
160
+
145
161
  export declare function deepMerge(objs: any): void;
146
162
 
147
163
  export declare const dir: (message: IMessage) => "rtl" | "ltr";
@@ -476,9 +492,9 @@ export declare interface ICloudOptions {
476
492
  debug?: boolean;
477
493
  dimensions?: IDimensions;
478
494
  globe?: IGlobe;
479
- grid: ICardsGrid;
495
+ grid?: ICardsGrid;
480
496
  highlight?: IHighlight;
481
- image: ICardImage;
497
+ image?: ICardImage;
482
498
  kpi?: Kpi;
483
499
  legend?: ILegend;
484
500
  pie?: IPie;
@@ -1238,8 +1254,8 @@ export declare interface ISeriesOptions {
1238
1254
  time?: ITime;
1239
1255
  date?: IDate;
1240
1256
  dimensions?: IDimensions;
1241
- graph: IGraph;
1242
- legend: ILegend;
1257
+ graph?: IGraph;
1258
+ legend?: ILegend;
1243
1259
  pie?: IPie;
1244
1260
  show?: IShowSeries;
1245
1261
  }
@@ -1589,6 +1605,73 @@ export declare function showModal(e: MouseEvent, widget: any, message: IMessage,
1589
1605
 
1590
1606
  export declare function shuffleMessages(messages: IMessage[]): IMessage[];
1591
1607
 
1608
+ export declare class Snowflake {
1609
+ /**
1610
+ * The generators epoch timestamp in milliseconds.
1611
+ *
1612
+ * Defaults to "1st of January, 2000, 00:00".
1613
+ *
1614
+ * @type {number}
1615
+ */
1616
+ static EPOCH: number;
1617
+ /**
1618
+ * The id of the shard running this generator.
1619
+ *
1620
+ * Defaults to "1".
1621
+ *
1622
+ * @type {number}
1623
+ */
1624
+ static SHARD_ID: number;
1625
+ /**
1626
+ * The sequence of the current running generator.
1627
+ *
1628
+ * Defaults to "1".
1629
+ *
1630
+ * @type {number}
1631
+ */
1632
+ static SEQUENCE: number;
1633
+ /**
1634
+ * Generates a single snowflake.
1635
+ * @param {Date|number} [timestamp = Date.now] - Timestamp to generate from
1636
+ * @returns {bigint}
1637
+ */
1638
+ static generate({ timestamp, shard_id, }?: {
1639
+ timestamp?: Date | number;
1640
+ shard_id?: number;
1641
+ }): string;
1642
+ /**
1643
+ * Deconstruct a snowflake to its values using the `Generator.epoch`.
1644
+ * @param {SnowflakeResolvable|SnowflakeResolvable[]} snowflake - Snowflake(s) to deconstruct
1645
+ * @returns {DeconstructedSnowflake|DeconstructedSnowflake[]}
1646
+ */
1647
+ static parse(snowflake: SnowflakeResolvable): DeconstructedSnowflake;
1648
+ static isValid(snowflake: string): boolean;
1649
+ /**
1650
+ * Extract bits and their values from a snowflake.
1651
+ * @param {SnowflakeResolvable} snowflake - Snowflake to extract from
1652
+ * @param {number|bigint} shift - Number of bits to shift before extracting
1653
+ * @param {number|bigint} length - Number of bits to extract before stopping
1654
+ * @returns {bigint}
1655
+ */
1656
+ static extractBits(snowflake: SnowflakeResolvable, start: number, length?: number): number;
1657
+ /**
1658
+ * Transform a snowflake into its 64Bit binary string.
1659
+ * @param {SnowflakeResolvable} snowflake - Snowflake to transform
1660
+ * @returns {string}
1661
+ * @private
1662
+ */
1663
+ static binary(snowflake: SnowflakeResolvable): string;
1664
+ }
1665
+
1666
+ /**
1667
+ * Resolvable value types for a valid Snowflake.
1668
+ * * string
1669
+ * * number
1670
+ * * bigint
1671
+ * @type {SnowflakeResolvable}
1672
+ */
1673
+ declare type SnowflakeResolvable = string;
1674
+
1592
1675
  export declare const stall: (func: Function, timeout?: number) => (...args: any[]) => void;
1593
1676
 
1594
1677
  export declare enum STORAGE {
@@ -3,4 +3,4 @@ var e=function(e){return e.CARDS=`cards`,e.CLOUD=`cloud`,e.DASHBOARD=`dashboard`
3
3
  <`),ue=e=>e.replace(/\/\*.*\*\/|\/\*[\s\S]*?\*\/|\n|\t|\v|\s{2,}/g,``).replace(/\s*\{\s*/g,`{`).replace(/\s*\}\s*/g,`}`).replace(/\s*\:\s*/g,`:`).replace(/\s*\;\s*/g,`;`).replace(/\s*\,\s*/g,`,`).replace(/\s*\~\s*/g,`~`).replace(/\s*\>\s*/g,`>`).replace(/\s*\+\s*/g,`+`).replace(/\s*\!\s*/g,`!`),de=e=>e.replace(/\,/g,`, `).replace(/\{/g,` {
4
4
  `).replace(/\}/g,`}
5
5
  `).replace(/\;/g,`;
6
- `);function fe(e,t){let n=[{value:1,symbol:``},{value:1e3,symbol:`k`},{value:1e6,symbol:`M`},{value:1e9,symbol:`G`},{value:0xe8d4a51000,symbol:`T`},{value:0x38d7ea4c68000,symbol:`P`},{value:0xde0b6b3a7640000,symbol:`E`},{value:1e21,symbol:`Z`},{value:1e24,symbol:`Y`}],r=/\.0+$|(\.\d*[1-9])0+$/,i;for(i=n.length-1;i>0&&!(e>=n[i].value);i--);return(e/n[i].value).toFixed(t).replace(r,`$1`)+n[i].symbol}function pe(e){let t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g,` `))||null}var me=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t)})[e];function he(e){return e[Math.floor(Math.random()*e.length)]}function ge(e){switch(e.language){case`ar`:return{direction:`rtl`,textAlign:`right`};default:return{direction:`ltr`,textAlign:`left`}}}var _e=e=>{switch(e.language){case`ar`:case`ml`:return`rtl`;default:return`ltr`}};function ve(e){let t=e.filter(e=>e!==void 0);return t.forEach(e=>{if(window.__bc.opts.suspended===!0?e.content=`License suspended, please contact your Sales Representative to restore service`:e.content=e.content?.replace(/(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)((\?.*)?)/g,``)||``,e.sender!==null)switch(!0){case e.sender.title===`Unknown author`:e.sender.title=``,e.sender.name=``;break;case e.sender.title===e.sender.name:e.sender.name=``;break;case e.channel===`tw`:e.sender.name=`@${e.sender.name}`;break}else e.sender={title:``,name:``,id:``,avatar:`default`,bio:``,location:``,following:0,verified:0,listed:0,followers:0,favourites:0,messages:0,influence:0};if(e.sender.title===``&&e.link!==``){let t=new URL(e.link);e.sender.title=t.hostname.replace(`www.`,``)}}),t}function ye(e,t,n,r){e.stopPropagation(),t.showModal({showComponent:`card-modal`,props:{data:n,options:r}})}function be(e){let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function $(){let e=``;for(let t=0;t<7;t++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}var xe=n=>{switch(n?.type){case e.MESSAGES:return t.MESSAGES;case e.SERIES:return t.SERIES;case e.CLOUD:return t.CLOUD;default:return t.NO_UPDATES}},Se=(e=6)=>Math.random().toString(36).substring(2,e+2),Ce=(e,t=[])=>!t.find(function(t){return t===e}),we=(e,t=[])=>{let n=0,r=``;for(;r==``&&n<100;)r=Se(e),Ce(r,t)||(r=``,n++);return r},Te=e=>{switch(!0){case e<0:return`text-down text-xs`;case e>0:return`text-up text-xs`;default:return`text-white text-xs`}},Ee=(e,t,n)=>Promise.race([e,De(t,n)]),De=(e,t)=>new Promise((n,r)=>setTimeout(()=>t===void 0?n(`ok`):r(t),e));function Oe(e){let t=`${e.type}.${e.topics}`;return e.order&&(t+=`.${e.order}`),e.period&&(t+=`.${e.period}`),t}function ke(e){if(e.widget===void 0){let t=e.topics?.split(`-`);t&&t.length>1?(e.dashboard=t?t[0]:``,e.widget=t?t[1]:``):(e.widget=e.topics,e.dashboard=e.slide)}return e}function Ae(e,t){let n,i,a,o,s;switch(e.moderation){case r.BEFORE:n=new Date,i=e.beforeTime?.split(`:`),a=Number.parseInt(i?i[0]:`00`),o=Number.parseInt(i?i[1]:`00`),s=Number.parseInt(i?i[2]:`00`),t.before=n.setHours(a,o,s,0)/1e3,t.period||=n.getDay()===1?72:24;break;case r.DELAYED:e.delay&&e.delay>0&&(t.delay=`${e.delay}`);break;case r.APPROVED:t.approved=`1`;break;default:e.period!==0&&(t.period=e.period)}return t}var je=function(e){return e.MultiPolygon=`MultiPolygon`,e.Polygon=`Polygon`,e}({}),Me=function(e){return e.MultiPolygon=`MultiPolygon`,e.Polygon=`Polygon`,e}({});export{e as API,t as CSS,n as EVENTS,je as GeoType,K as HTMLParser,F as HTMLtoDOM,P as HTMLtoXML,r as MODERATION,te as RGBAchangeA,i as STORAGE,Me as ShapeType,ie as abbr,a as anonymize,o as attachedMedia,s as attrs,u as awaitElement,d as brandLogo,p as camelCase,l as camelCasedProps,m as camelToHyphen,f as camelize,h as capitalizeFirstLetter,g as clearContents,ne as debounce,x as deepMerge,_e as dir,C as escape,c as filterAttributes,T as flatten,w as formatContent,E as getGuid,Oe as getKey,pe as getParameterByName,me as getQueryParam,Z as hasHWA,N as hashSum,Y as html2json,re as intToString,ae as isEmpty,X as json2html,oe as log,se as logging,de as maxifyCss,le as maxifyHtml,ue as minifyCss,ce as minifyHtml,Ae as moderation,fe as numberFormatter,_ as randomColor,ee as randomRGB,y as randomRGBA,v as randomRGBAfull,he as randomValue,ge as rtl,ve as sanitize,ye as showModal,be as shuffleMessages,b as stall,$ as stringGen,xe as typeCss,we as uniq,S as unique,Te as upDownColor,ke as widgetParams,Ee as wrapPromise};
6
+ `);function fe(e,t){let n=[{value:1,symbol:``},{value:1e3,symbol:`k`},{value:1e6,symbol:`M`},{value:1e9,symbol:`G`},{value:0xe8d4a51000,symbol:`T`},{value:0x38d7ea4c68000,symbol:`P`},{value:0xde0b6b3a7640000,symbol:`E`},{value:1e21,symbol:`Z`},{value:1e24,symbol:`Y`}],r=/\.0+$|(\.\d*[1-9])0+$/,i;for(i=n.length-1;i>0&&!(e>=n[i].value);i--);return(e/n[i].value).toFixed(t).replace(r,`$1`)+n[i].symbol}function pe(e){let t=RegExp(`[?&]${e}=([^&]*)`).exec(window.location.search);return t&&decodeURIComponent(t[1].replace(/\+/g,` `))||null}var me=e=>new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get(t)})[e];function he(e){return e[Math.floor(Math.random()*e.length)]}function ge(e){switch(e.language){case`ar`:return{direction:`rtl`,textAlign:`right`};default:return{direction:`ltr`,textAlign:`left`}}}var _e=e=>{switch(e.language){case`ar`:case`ml`:return`rtl`;default:return`ltr`}};function ve(e){let t=e.filter(e=>e!==void 0);return t.forEach(e=>{if(window.__bc.opts.suspended===!0?e.content=`License suspended, please contact your Sales Representative to restore service`:e.content=e.content?.replace(/(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)((\?.*)?)/g,``)||``,e.sender!==null)switch(!0){case e.sender.title===`Unknown author`:e.sender.title=``,e.sender.name=``;break;case e.sender.title===e.sender.name:e.sender.name=``;break;case e.channel===`tw`:e.sender.name=`@${e.sender.name}`;break}else e.sender={title:``,name:``,id:``,avatar:`default`,bio:``,location:``,following:0,verified:0,listed:0,followers:0,favourites:0,messages:0,influence:0};if(e.sender.title===``&&e.link!==``){let t=new URL(e.link);e.sender.title=t.hostname.replace(`www.`,``)}}),t}function ye(e,t,n,r){e.stopPropagation(),t.showModal({showComponent:`card-modal`,props:{data:n,options:r}})}function be(e){let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}var xe=class e{static EPOCH=Date.UTC(1970,0,1).valueOf();static SHARD_ID=1;static SEQUENCE=1;static generate({timestamp:t=Date.now(),shard_id:n=e.SHARD_ID}={}){t=t instanceof Date?t.valueOf():new Date(t).valueOf();let r=BigInt(t)-BigInt(e.EPOCH)<<BigInt(22);return r|=BigInt(n%1024)<<BigInt(12),r|=BigInt(e.SEQUENCE++%4096),r.toString()}static parse(t){let n=e.binary(t);return{timestamp:e.extractBits(t,1,41),shard_id:e.extractBits(t,42,10),sequence:e.extractBits(t,52),binary:n}}static isValid(t){if(!/^[\d]{19}$/.test(t))return!1;try{return e.parse(t),!0}catch{return!1}}static extractBits(t,n,r){return parseInt(r?e.binary(t).substring(n,n+r):e.binary(t).substring(n),2)}static binary(e){let t=BigInt(e).toString(2);return t.length<64?`0000000000000000000000000000000000000000000000000000000000000000`.substring(0,64-t.length)+t:t}};function Se(){let e=``;for(let t=0;t<7;t++)e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return e}var Ce=n=>{switch(n?.type){case e.MESSAGES:return t.MESSAGES;case e.SERIES:return t.SERIES;case e.CLOUD:return t.CLOUD;default:return t.NO_UPDATES}},we=(e=6)=>Math.random().toString(36).substring(2,e+2),Te=(e,t=[])=>!t.find(function(t){return t===e}),Ee=(e,t=[])=>{let n=0,r=``;for(;r==``&&n<100;)r=we(e),Te(r,t)||(r=``,n++);return r},De=e=>{switch(!0){case e<0:return`text-down text-xs`;case e>0:return`text-up text-xs`;default:return`text-white text-xs`}},$=(e,t,n)=>Promise.race([e,Oe(t,n)]),Oe=(e,t)=>new Promise((n,r)=>setTimeout(()=>t===void 0?n(`ok`):r(t),e));function ke(e){let t=`${e.type}.${e.topics}`;return e.order&&(t+=`.${e.order}`),e.period&&(t+=`.${e.period}`),t}function Ae(e){if(e.widget===void 0){let t=e.topics?.split(`-`);t&&t.length>1?(e.dashboard=t?t[0]:``,e.widget=t?t[1]:``):(e.widget=e.topics,e.dashboard=e.slide)}return e}function je(e,t){let n,i,a,o,s;switch(e.moderation){case r.BEFORE:n=new Date,i=e.beforeTime?.split(`:`),a=Number.parseInt(i?i[0]:`00`),o=Number.parseInt(i?i[1]:`00`),s=Number.parseInt(i?i[2]:`00`),t.before=n.setHours(a,o,s,0)/1e3,t.period||=n.getDay()===1?72:24;break;case r.DELAYED:e.delay&&e.delay>0&&(t.delay=`${e.delay}`);break;case r.APPROVED:t.approved=`1`;break;default:e.period!==0&&(t.period=e.period)}return t}var Me=function(e){return e.MultiPolygon=`MultiPolygon`,e.Polygon=`Polygon`,e}({}),Ne=function(e){return e.MultiPolygon=`MultiPolygon`,e.Polygon=`Polygon`,e}({});export{e as API,t as CSS,n as EVENTS,Me as GeoType,K as HTMLParser,F as HTMLtoDOM,P as HTMLtoXML,r as MODERATION,te as RGBAchangeA,i as STORAGE,Ne as ShapeType,xe as Snowflake,ie as abbr,a as anonymize,o as attachedMedia,s as attrs,u as awaitElement,d as brandLogo,p as camelCase,l as camelCasedProps,m as camelToHyphen,f as camelize,h as capitalizeFirstLetter,g as clearContents,ne as debounce,x as deepMerge,_e as dir,C as escape,c as filterAttributes,T as flatten,w as formatContent,E as getGuid,ke as getKey,pe as getParameterByName,me as getQueryParam,Z as hasHWA,N as hashSum,Y as html2json,re as intToString,ae as isEmpty,X as json2html,oe as log,se as logging,de as maxifyCss,le as maxifyHtml,ue as minifyCss,ce as minifyHtml,je as moderation,fe as numberFormatter,_ as randomColor,ee as randomRGB,y as randomRGBA,v as randomRGBAfull,he as randomValue,ge as rtl,ve as sanitize,ye as showModal,be as shuffleMessages,b as stall,Se as stringGen,Ce as typeCss,Ee as uniq,S as unique,De as upDownColor,Ae as widgetParams,$ as wrapPromise};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzcasting-utils",
3
3
  "type": "module",
4
- "version": "1.12.3",
4
+ "version": "1.13.5",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "Mark Tamis, TouchFlows SAS",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "dev": "vite",
24
- "docs": "npx typedoc src ",
24
+ "docs": "typedoc",
25
25
  "build": "tsc && vite build",
26
26
  "changelog": "changelogen --release",
27
27
  "release": "npm test && npm run build && changelogen --release && npm publish && git push --follow-tags",
@@ -31,24 +31,21 @@
31
31
  "test:coverage": "vitest --coverage"
32
32
  },
33
33
  "devDependencies": {
34
- "@antfu/eslint-config": "^7.7.3",
35
- "@commitlint/cli": "^20.5.0",
36
- "@commitlint/config-conventional": "^20.5.0",
37
- "@types/node": "^24.12.0",
38
- "@typescript-eslint/eslint-plugin": "^8.57.1",
39
- "@typescript-eslint/parser": "^8.57.1",
40
- "@vitest/coverage-v8": "^4.1.0",
34
+ "@commitlint/cli": "^20.5.3",
35
+ "@commitlint/config-conventional": "^20.5.3",
36
+ "@types/node": "^24.13.2",
37
+ "@vitest/coverage-v8": "^4.1.9",
41
38
  "camelcase": "^9.0.0",
42
39
  "changelogen": "^0.6.2",
43
- "eslint": "^9.39.2",
44
- "lint-staged": "^16.2.7",
45
- "typedoc": "^0.28.17",
40
+ "lint-staged": "^16.4.0",
41
+ "typedoc": "^0.28.19",
42
+ "typedoc-plugin-markdown": "^4.12.0",
46
43
  "typescript": "^5.9.3",
47
- "vite": "^8.0.1",
44
+ "vite": "^8.1.2",
48
45
  "vite-plugin-dts": "^4.5.4",
49
- "vitest": "^4.1.0"
46
+ "vitest": "^4.1.9"
50
47
  },
51
48
  "lint-staged": {
52
49
  "*.ts": "npm run lint"
53
50
  }
54
- }
51
+ }