@ecopages/radiant 0.1.7 → 0.1.8

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.
@@ -0,0 +1,9 @@
1
+ import type { RadiantElement } from '../core/radiant-element';
2
+ /**
3
+ * A decorator to bind a method to the instance.
4
+ * @param target {@link RadiantElement}
5
+ * @param propertyKey string
6
+ * @param descriptor {@link PropertyDescriptor}
7
+ * @returns
8
+ */
9
+ export declare function bound(target: RadiantElement, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
@@ -0,0 +1,24 @@
1
+ // src/decorators/bound.ts
2
+ function bound(target, propertyKey, descriptor) {
3
+ const originalMethod = descriptor.value;
4
+ return {
5
+ configurable: true,
6
+ get() {
7
+ if (this === target.prototype || Object.hasOwn(this, propertyKey)) {
8
+ return originalMethod;
9
+ }
10
+ const boundMethod = originalMethod.bind(this);
11
+ Object.defineProperty(this, propertyKey, {
12
+ value: boundMethod,
13
+ configurable: true,
14
+ writable: true
15
+ });
16
+ return boundMethod;
17
+ }
18
+ };
19
+ }
20
+ export {
21
+ bound
22
+ };
23
+
24
+ //# debugId=90091E999EB96B5364756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/decorators/bound.ts"],
4
+ "sourcesContent": [
5
+ "import type { RadiantElement } from '@/core/radiant-element';\n\n/**\n * A decorator to bind a method to the instance.\n * @param target {@link RadiantElement}\n * @param propertyKey string\n * @param descriptor {@link PropertyDescriptor}\n * @returns\n */\nexport function bound(target: RadiantElement, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value;\n\n return {\n configurable: true,\n get() {\n /**\n * Check if the method is already bound to the instance.\n */\n if (this === (target as any).prototype || Object.hasOwn(this, propertyKey)) {\n return originalMethod;\n }\n\n /**\n * Bind the method to the instance.\n */\n const boundMethod = originalMethod.bind(this);\n Object.defineProperty(this, propertyKey, {\n value: boundMethod,\n configurable: true,\n writable: true,\n });\n return boundMethod;\n },\n };\n}\n"
6
+ ],
7
+ "mappings": ";AASO,SAAS,KAAK,CAAC,QAAwB,aAAqB,YAAoD;AACrH,QAAM,iBAAiB,WAAW;AAElC,SAAO;AAAA,IACL,cAAc;AAAA,IACd,GAAG,GAAG;AAIJ,UAAI,SAAU,OAAe,aAAa,OAAO,OAAO,MAAM,WAAW,GAAG;AAC1E,eAAO;AAAA,MACT;AAKA,YAAM,cAAc,eAAe,KAAK,IAAI;AAC5C,aAAO,eAAe,MAAM,aAAa;AAAA,QACvC,OAAO;AAAA,QACP,cAAc;AAAA,QACd,UAAU;AAAA,MACZ,CAAC;AACD,aAAO;AAAA;AAAA,EAEX;AAAA;",
8
+ "debugId": "90091E999EB96B5364756E2164756E21",
9
+ "names": []
10
+ }
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/decorators/debounce.ts"],
4
4
  "sourcesContent": [
5
- "export function debounce(\n timeout: number,\n): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor {\n let timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n return (_target: any, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor => {\n const originalMethod = descriptor.value;\n\n descriptor.value = function debounce(...args: any[]) {\n if (timeoutRef !== null) {\n clearTimeout(timeoutRef);\n }\n\n timeoutRef = setTimeout(() => {\n originalMethod.apply(this, args);\n }, timeout);\n };\n\n return descriptor;\n };\n}\n"
5
+ "import type { RadiantElement } from '@/core/radiant-element';\n\nexport function debounce(\n timeout: number,\n): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor {\n let timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\n return (_target: RadiantElement, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor => {\n const originalMethod = descriptor.value;\n\n descriptor.value = function debounce(...args: any[]) {\n if (timeoutRef !== null) {\n clearTimeout(timeoutRef);\n }\n\n timeoutRef = setTimeout(() => {\n originalMethod.apply(this, args);\n }, timeout);\n };\n\n return descriptor;\n };\n}\n"
6
6
  ],
7
- "mappings": ";AAAO,SAAS,QAAQ,CACtB,SAC0F;AAC1F,MAAI,aAAmD;AAEvD,SAAO,CAAC,SAAc,cAAsB,eAAuD;AACjG,UAAM,iBAAiB,WAAW;AAElC,eAAW,iBAAiB,QAAQ,IAAI,MAAa;AACnD,UAAI,eAAe,MAAM;AACvB,qBAAa,UAAU;AAAA,MACzB;AAEA,mBAAa,WAAW,MAAM;AAC5B,uBAAe,MAAM,MAAM,IAAI;AAAA,SAC9B,OAAO;AAAA;AAGZ,WAAO;AAAA;AAAA;",
7
+ "mappings": ";AAEO,SAAS,QAAQ,CACtB,SAC0F;AAC1F,MAAI,aAAmD;AAEvD,SAAO,CAAC,SAAyB,cAAsB,eAAuD;AAC5G,UAAM,iBAAiB,WAAW;AAElC,eAAW,iBAAiB,QAAQ,IAAI,MAAa;AACnD,UAAI,eAAe,MAAM;AACvB,qBAAa,UAAU;AAAA,MACzB;AAEA,mBAAa,WAAW,MAAM;AAC5B,uBAAe,MAAM,MAAM,IAAI;AAAA,SAC9B,OAAO;AAAA;AAGZ,WAAO;AAAA;AAAA;",
8
8
  "debugId": "30A0CC4182AD504664756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/radiant",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ecopages/radiant.git"
@@ -75,6 +75,10 @@
75
75
  "types": "./dist/core/radiant-element.d.ts",
76
76
  "import": "./dist/core/radiant-element.js"
77
77
  },
78
+ "./decorators/bound": {
79
+ "types": "./dist/decorators/bound.d.ts",
80
+ "import": "./dist/decorators/bound.js"
81
+ },
78
82
  "./decorators/custom-element": {
79
83
  "types": "./dist/decorators/custom-element.d.ts",
80
84
  "import": "./dist/decorators/custom-element.js"