@tsed/hooks 8.5.0-beta.2 → 8.5.1

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 +1 @@
1
- {"version":3,"file":"hooks.umd.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,eAAiBD,IAEzBD,EAAK,eAAiBC,GACvB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,KCL9D,SAASC,EAAMC,EAAKC,GAChB,OAAQD,IAAQC,EAAKD,KAAQA,GAAOC,EAAKD,MAAQA,CACrD,C,qIACO,MAAME,EACT,GAAa,IAAIC,IAKjB,GAAAC,CAAIC,GACA,QAASC,MAAK,EAAWhB,IAAIe,IAAQE,MACzC,CACA,EAAAC,CAAGH,EAAOI,EAAQC,GACd,IAAIV,EAAMS,EACLC,IACDA,EAAKV,EACLA,OAAMW,GAEV,MAAMC,EAAQN,MAAK,EAAWhB,IAAIe,IAAU,GAM5C,OALAO,EAAMC,KAAK,CACPH,KACAV,QAEJM,MAAK,EAAWQ,IAAIT,EAAOO,GACpBN,IACX,CACA,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MAAMpB,EAAQN,MAAK,EAAWhB,IAAIe,GAClC,GAAIO,GAAOL,OACP,IAAK,MAAM,GAAEG,KAAQE,EACjBd,EAAQY,EAAGf,KAAKqC,EAAUlC,KAAUmB,GAG5C,OAAOnB,CACX,CAQA,gBAAMmC,CAAW5B,EAAOP,EAAOmB,EAAO,GAAIe,EAAW,MACjD,MAAMpB,EAAQN,MAAK,EAAWhB,IAAIe,GAClC,GAAIO,GAAOL,OACP,IAAK,MAAMN,KAAQW,EACfd,QAAcG,EAAKS,GAAGf,KAAKqC,EAAUlC,KAAUmB,GAGvD,OAAOnB,CACX,CACA,OAAAoC,GACI5B,MAAK,EAAW6B,OACpB,EAEG,MAAMC,EAAQ,IAAIlC,EACZmC,EAAMD,EAAM5B,GAAG8B,KAAKF,GACpBG,EAAQH,EAAMrB,KAAKuB,KAAKF,GACxBI,EAAOJ,EAAMlB,IAAIoB,KAAKF,GACtBK,EAAQL,EAAMd,KAAKgB,KAAKF,GACxBM,EAAaN,EAAMV,UAAUY,KAAKF,GAClCO,EAASP,EAAML,MAAMO,KAAKF,GAC1BQ,EAAcR,EAAMH,WAAWK,KAAKF,G","sources":["webpack://@tsed/hooks/webpack/universalModuleDefinition","webpack://@tsed/hooks/webpack/bootstrap","webpack://@tsed/hooks/webpack/runtime/define property getters","webpack://@tsed/hooks/webpack/runtime/hasOwnProperty shorthand","webpack://@tsed/hooks/webpack/runtime/make namespace object","webpack://@tsed/hooks/./src/Hooks.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@tsed/hooks\"] = factory();\n\telse\n\t\troot[\"@tsed/hooks\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","function match(ref, item) {\n return !ref || !item.ref || (ref && item.ref === ref);\n}\nexport class Hooks {\n #listeners = new Map();\n /**\n * Check if an event has listeners\n * @param event\n */\n has(event) {\n return !!this.#listeners.get(event)?.length;\n }\n on(event, cbORef, cb) {\n let ref = cbORef;\n if (!cb) {\n cb = ref;\n ref = undefined;\n }\n const items = this.#listeners.get(event) || [];\n items.push({\n cb,\n ref\n });\n this.#listeners.set(event, items);\n return this;\n }\n once(event, ref, cb) {\n if (!cb) {\n cb = ref;\n }\n const onceCb = (...args) => {\n cb(...args);\n this.off(event, onceCb);\n };\n this.on(event, ref, onceCb);\n return this;\n }\n off(event, cb) {\n const set = (event, items) => {\n if (items.length) {\n this.#listeners.set(event, items);\n }\n else {\n this.#listeners.delete(event);\n }\n };\n if (typeof event === \"string\" && cb) {\n let items = this.#listeners.get(event);\n if (items) {\n set(event, items.filter((item) => item.cb !== cb));\n }\n }\n else {\n const ref = event;\n this.#listeners.forEach((items, event) => {\n set(event, items.filter((item) => item.ref !== ref));\n });\n }\n return this;\n }\n emit(event, ref, args) {\n if (Array.isArray(ref)) {\n args = ref;\n ref = undefined;\n }\n args ||= [];\n const items = this.#listeners.get(event);\n if (items?.length) {\n for (const item of items) {\n if (match(ref, item)) {\n item.cb.apply(null, args);\n }\n }\n }\n }\n async asyncEmit(event, ref, args) {\n if (Array.isArray(ref)) {\n args = ref;\n ref = undefined;\n }\n const items = this.#listeners.get(event);\n if (items?.length) {\n const promises = items.filter((item) => match(ref, item)).map((item) => item.cb.apply(null, args));\n await Promise.all(promises);\n }\n }\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter(event, value, args = [], callThis = null) {\n const items = this.#listeners.get(event);\n if (items?.length) {\n for (const { cb } of items) {\n value = cb.call(callThis, value, ...args);\n }\n }\n return value;\n }\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter(event, value, args = [], callThis = null) {\n const items = this.#listeners.get(event);\n if (items?.length) {\n for (const item of items) {\n value = await item.cb.call(callThis, value, ...args);\n }\n }\n return value;\n }\n destroy() {\n this.#listeners.clear();\n }\n}\nexport const hooks = new Hooks();\nexport const $on = hooks.on.bind(hooks);\nexport const $once = hooks.once.bind(hooks);\nexport const $off = hooks.off.bind(hooks);\nexport const $emit = hooks.emit.bind(hooks);\nexport const $asyncEmit = hooks.asyncEmit.bind(hooks);\nexport const $alter = hooks.alter.bind(hooks);\nexport const $asyncAlter = hooks.asyncAlter.bind(hooks);\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","match","ref","item","Hooks","Map","has","event","this","length","on","cbORef","cb","undefined","items","push","set","once","onceCb","args","off","delete","filter","forEach","emit","Array","isArray","apply","asyncEmit","promises","map","Promise","all","alter","callThis","asyncAlter","destroy","clear","hooks","$on","bind","$once","$off","$emit","$asyncEmit","$alter","$asyncAlter"],"sourceRoot":""}
1
+ {"version":3,"file":"hooks.umd.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,eAAiBD,IAEzBD,EAAK,eAAiBC,GACvB,CATD,CASGK,MAAM,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KqC,EAAUlC,KAAUmB,GAInD,OAAOnB,CACT,CAEA,OAAAoC,GACE5B,MAAK,EAAW6B,OAClB,EAGK,MAAMC,EAAQ,IAAIlC,EACZmC,EAAuBD,EAAM5B,GAAG8B,KAAKF,GACrCG,EAA2BH,EAAMrB,KAAKuB,KAAKF,GAC3CI,EAAyBJ,EAAMlB,IAAIoB,KAAKF,GACxCK,EAA2BL,EAAMd,KAAKgB,KAAKF,GAC3CM,EAAqCN,EAAMV,UAAUY,KAAKF,GAC1DO,EAA6BP,EAAML,MAAMO,KAAKF,GAC9CQ,EAAuCR,EAAMH,WAAWK,KAAKF,G","sources":["webpack://@tsed/hooks/webpack/universalModuleDefinition","webpack://@tsed/hooks/webpack/bootstrap","webpack://@tsed/hooks/webpack/runtime/define property getters","webpack://@tsed/hooks/webpack/runtime/hasOwnProperty shorthand","webpack://@tsed/hooks/webpack/runtime/make namespace object","webpack://@tsed/hooks/./src/Hooks.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@tsed/hooks\"] = factory();\n\telse\n\t\troot[\"@tsed/hooks\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export type HookRef = string | symbol | any | Function;\nexport type HookListener = Function;\n\ntype HookItem = {cb: HookListener; ref?: HookRef};\n\nfunction match(ref: HookRef | unknown[] | undefined, item: HookItem) {\n return !ref || !item.ref || (ref && item.ref === ref);\n}\n\nexport class Hooks {\n #listeners: Map<string, HookItem[]> = new Map();\n\n /**\n * Check if an event has listeners\n * @param event\n */\n has(event: string) {\n return !!this.#listeners.get(event)?.length;\n }\n\n /**\n * Listen a hook event\n * @param event The event name\n * @param ref The reference of the listener\n * @param cb The callback\n */\n on(event: string, ref: HookRef, cb: HookListener): this;\n /**\n * Listen a hook event\n * @param event The event name\n * @param cb The callback\n */\n on(event: string, cb: HookListener): this;\n on(event: string, cbORef: HookRef | HookListener, cb?: HookListener) {\n let ref: HookRef | HookListener | undefined = cbORef;\n\n if (!cb) {\n cb = ref as HookListener;\n ref = undefined;\n }\n\n const items = this.#listeners.get(event) || [];\n\n items.push({\n cb,\n ref\n });\n\n this.#listeners.set(event, items);\n\n return this;\n }\n\n /**\n * Listen a hook event once\n *\n * @param event The event name\n * @param ref The reference of the listener\n * @param cb The callback\n */\n once(event: string, ref: HookRef, cb: HookListener): this;\n /**\n * Listen a hook event once\n * @param event\n * @param cb\n */\n once(event: string, cb: HookListener): this;\n once(event: string, ref: HookRef | HookListener, cb?: HookListener) {\n if (!cb) {\n cb = ref as HookListener;\n }\n\n const onceCb = (...args: unknown[]) => {\n cb(...args);\n this.off(event, onceCb);\n };\n\n this.on(event, ref, onceCb);\n\n return this;\n }\n\n /**\n * Remove a listener attached to an event\n * @param ref\n */\n off(ref: HookRef): this;\n /**\n * Remove a listener attached to an event\n * @param event\n * @param cb\n */\n off(event: string, cb: HookListener): this;\n off(event: string | HookRef, cb?: HookListener) {\n const set = (event: string, items: HookItem[]) => {\n if (items.length) {\n this.#listeners.set(event, items);\n } else {\n this.#listeners.delete(event);\n }\n };\n\n if (typeof event === \"string\" && cb) {\n let items = this.#listeners.get(event);\n\n if (items) {\n set(\n event,\n items.filter((item) => item.cb !== cb)\n );\n }\n } else {\n const ref = event as HookRef;\n\n this.#listeners.forEach((items, event) => {\n set(\n event,\n items.filter((item) => item.ref !== ref)\n );\n });\n }\n\n return this;\n }\n\n /**\n * Trigger an event without arguments.\n * @param event The event name\n */\n emit(event: string): void;\n /**\n * Trigger an event and call listener.\n * @param event\n * @param args\n * @param callThis\n */\n emit(event: string, args: unknown[]): void;\n /**\n * Trigger an event with arguments and call only listener attached to the given ref.\n * @param event The event name\n * @param ref The reference of the listener\n * @param args The arguments\n */\n emit(event: string, ref: HookRef, args?: unknown[]): void;\n emit(event: string, ref?: HookRef | unknown[], args?: unknown[]): void {\n if (Array.isArray(ref)) {\n args = ref;\n ref = undefined;\n }\n\n args ||= [];\n\n const items = this.#listeners.get(event);\n\n if (items?.length) {\n for (const item of items) {\n if (match(ref, item)) {\n item.cb.apply(null, args);\n }\n }\n }\n }\n\n /**\n * Trigger an event and call async listener.\n * @param event The event name\n */\n async asyncEmit(event: string): Promise<void>;\n async asyncEmit(event: string, args: unknown[]): Promise<void>;\n async asyncEmit(event: string, ref: HookRef, args?: unknown[]): Promise<void>;\n async asyncEmit(event: string, ref?: HookRef | unknown[], args?: unknown[]): Promise<void> {\n if (Array.isArray(ref)) {\n args = ref;\n ref = undefined;\n }\n\n const items = this.#listeners.get(event);\n\n if (items?.length) {\n const promises = items.filter((item) => match(ref, item)).map((item) => item.cb.apply(null, args));\n\n await Promise.all(promises);\n }\n }\n\n /**\n * Trigger an event, listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n alter<Arg = unknown, AlteredArg = Arg>(event: string, value: Arg, args: unknown[] = [], callThis: unknown = null): AlteredArg {\n const items = this.#listeners.get(event);\n\n if (items?.length) {\n for (const {cb} of items) {\n value = cb.call(callThis, value, ...args);\n }\n }\n\n return value as unknown as AlteredArg;\n }\n\n /**\n * Trigger an event, async listener alter given value and return it.\n * @param event\n * @param value\n * @param args\n * @param callThis\n */\n async asyncAlter<Arg = unknown, AlteredArg = Arg>(\n event: string,\n value: Arg,\n args: unknown[] = [],\n callThis: unknown = null\n ): Promise<AlteredArg> {\n const items = this.#listeners.get(event);\n\n if (items?.length) {\n for (const item of items) {\n value = await item.cb.call(callThis, value, ...args);\n }\n }\n\n return value as unknown as AlteredArg;\n }\n\n destroy() {\n this.#listeners.clear();\n }\n}\n\nexport const hooks = new Hooks();\nexport const $on: typeof hooks.on = hooks.on.bind(hooks);\nexport const $once: typeof hooks.once = hooks.once.bind(hooks);\nexport const $off: typeof hooks.off = hooks.off.bind(hooks);\nexport const $emit: typeof hooks.emit = hooks.emit.bind(hooks);\nexport const $asyncEmit: typeof hooks.asyncEmit = hooks.asyncEmit.bind(hooks);\nexport const $alter: typeof hooks.alter = hooks.alter.bind(hooks);\nexport const $asyncAlter: typeof hooks.asyncAlter = hooks.asyncAlter.bind(hooks);\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","match","ref","item","Hooks","Map","has","event","this","length","on","cbORef","cb","undefined","items","push","set","once","onceCb","args","off","delete","filter","forEach","emit","Array","isArray","apply","asyncEmit","promises","map","Promise","all","alter","callThis","asyncAlter","destroy","clear","hooks","$on","bind","$once","$off","$emit","$asyncEmit","$alter","$asyncAlter"],"sourceRoot":""}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/hooks",
3
3
  "description": "Hooks module for Ts.ED Framework",
4
4
  "type": "module",
5
- "version": "8.5.0-beta.2",
5
+ "version": "8.5.1",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -35,8 +35,8 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsed/monorepo-utils": "2.3.11",
38
- "@tsed/typescript": "8.5.0-beta.2",
39
- "@tsed/vitest": "8.5.0-beta.2",
38
+ "@tsed/typescript": "8.5.1",
39
+ "@tsed/vitest": "8.5.1",
40
40
  "eslint": "9.12.0",
41
41
  "typescript": "5.4.5",
42
42
  "vite": "6.0.9",
@@ -50,8 +50,5 @@
50
50
  },
51
51
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/hooks",
52
52
  "author": "Romain Lenzotti",
53
- "license": "MIT",
54
- "publishConfig": {
55
- "tag": "beta"
56
- }
53
+ "license": "MIT"
57
54
  }