@ibyar/decorators 1.1.0 → 1.2.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 +1 @@
1
- {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/decorators/decorator/metadata.ts"],"names":[],"mappings":"AAgBA,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;IACrB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;QACzC,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM,CAAC,iBAAiB,CAAC;KAChC,CAAC,CAAC;CACH;AAGD,MAAM,cAAc;IACC;IAApB,YAAoB,UAAuD;QAAvD,eAAU,GAAV,UAAU,CAA6C;IAAI,CAAC;IAEhF,GAAG,CAAC,GAAqB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,GAAqB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,WAAW,CAAC,GAAqB;QAChC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAChC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC9C,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,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AAC;IACH,CAAC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,EAAQ,CAAC;AAEnD,MAAM,UAAU,wBAAwB,CACvC,SAA2F;IAE3F,OAAO,CAAC,KAAY,EAAE,OAAgB,EAAE,EAAE;QACzC,MAAM,QAAQ,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7D,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC;AACH,CAAC","sourcesContent":["export type MetadataClass<T = any> = { new(...args: any): T;[Symbol.metadata]: Record<PropertyKey, any> };\n\nexport interface MetadataContext extends Record<PropertyKey, any> {\n\n}\n\ndeclare global {\n\n\tinterface SymbolConstructor {\n\t\t/**\n\t\t * metadata symbol\n\t\t */\n\t\treadonly metadata: unique symbol;\n\t}\n}\n\nif (!Symbol.metadata) {\n\tObject.defineProperty(Symbol, 'metadata', {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\twritable: false,\n\t\tvalue: Symbol('Symbol.metadata'),\n\t});\n}\n\n\nclass ContextService {\n\tconstructor(private contextMap: WeakMap<Record<any, any>, Record<any, any>>) { }\n\n\thas(key: Record<any, any>) {\n\t\treturn this.contextMap.has(key);\n\t}\n\n\tget(key: Record<any, any>) {\n\t\treturn this.contextMap.get(key);\n\t}\n\n\tgetOrCreate(key: Record<any, any>) {\n\t\tif (this.contextMap.has(key)) {\n\t\t\treturn this.contextMap.get(key);\n\t\t}\n\t\tconst value = Object.create(null);\n\t\tconst prototype = Object.getPrototypeOf(key);\n\t\tif (this.contextMap.has(prototype)) {\n\t\t\tconst parent = this.contextMap.get(prototype);\n\t\t\tparent && this.clone(value, parent);\n\t\t}\n\t\tthis.contextMap.set(key, value);\n\t\treturn value;\n\t}\n\n\tprivate clone(child: MetadataContext, parent: MetadataContext): void {\n\t\tfor (const property in parent) {\n\t\t\tconst parentValue = parent[property];\n\t\t\tif (Array.isArray(parentValue)) {\n\t\t\t\tchild[property] = [...parentValue];\n\t\t\t} else if (typeof parentValue === 'undefined' || parentValue === null) {\n\t\t\t\tchild[property] = parentValue;\n\t\t\t} else if (typeof parentValue === 'object') {\n\t\t\t\tchild[property] = Object.assign(Object.create(null), parentValue);\n\t\t\t} else {\n\t\t\t\tchild[property] = parentValue;\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst contextMap = new WeakMap<Record<any, any>, Record<any, any>>();\nexport const metadataHoler = new ContextService(contextMap);\n\n\nexport function makeClassDecorator<V, Type = any>(\n\tdecorator?: (param: V, constructor: Type, context: ClassDecoratorContext<new (...args: any) => any>, metadata: MetadataContext) => void\n) {\n\treturn (param: V) => {\n\t\treturn (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => {\n\t\t\tconst metadata = metadataHoler.getOrCreate(context.metadata);\n\t\t\tdecorator?.(param, constructor, context, metadata);\n\t\t\treturn constructor;\n\t\t};\n\t};\n}\n\nexport const Metadata = makeClassDecorator<void>();\n\nexport function makeClassMemberDecorator<Value, Context extends ClassMemberDecoratorContext = ClassMemberDecoratorContext>(\n\tdecorator?: (value: Value | undefined, context: Context, metadata: MetadataContext) => void\n) {\n\treturn (value: Value, context: Context) => {\n\t\tconst metadata = metadataHoler.getOrCreate(context.metadata);\n\t\tdecorator?.(value, context, metadata);\n\t};\n}\n"]}
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/decorators/decorator/metadata.ts"],"names":[],"mappings":"AAgBA,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACtB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;QACzC,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM,CAAC,iBAAiB,CAAC;KAChC,CAAC,CAAC;AACJ,CAAC;AAGD,MAAM,cAAc;IACC;IAApB,YAAoB,UAAuD;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bol.metadata]: Record<PropertyKey, any> };\n\nexport interface MetadataContext extends Record<PropertyKey, any> {\n\n}\n\ndeclare global {\n\n\tinterface SymbolConstructor {\n\t\t/**\n\t\t * metadata symbol\n\t\t */\n\t\treadonly metadata: unique symbol;\n\t}\n}\n\nif (!Symbol.metadata) {\n\tObject.defineProperty(Symbol, 'metadata', {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\twritable: false,\n\t\tvalue: Symbol('Symbol.metadata'),\n\t});\n}\n\n\nclass ContextService {\n\tconstructor(private contextMap: WeakMap<Record<any, any>, Record<any, any>>) { }\n\n\thas(key: Record<any, any>) {\n\t\treturn this.contextMap.has(key);\n\t}\n\n\tget(key: Record<any, any>) {\n\t\treturn this.contextMap.get(key);\n\t}\n\n\tgetOrCreate(key: Record<any, any>) {\n\t\tif (this.contextMap.has(key)) {\n\t\t\treturn this.contextMap.get(key);\n\t\t}\n\t\tconst value = Object.create(null);\n\t\tconst prototype = Object.getPrototypeOf(key);\n\t\tif (this.contextMap.has(prototype)) {\n\t\t\tconst parent = this.contextMap.get(prototype);\n\t\t\tparent && this.clone(value, parent);\n\t\t}\n\t\tthis.contextMap.set(key, value);\n\t\treturn value;\n\t}\n\n\tprivate clone(child: MetadataContext, parent: MetadataContext): void {\n\t\tfor (const property in parent) {\n\t\t\tconst parentValue = parent[property];\n\t\t\tif (Array.isArray(parentValue)) {\n\t\t\t\tchild[property] = [...parentValue];\n\t\t\t} else if (typeof parentValue === 'undefined' || parentValue === null) {\n\t\t\t\tchild[property] = parentValue;\n\t\t\t} else if (typeof parentValue === 'object') {\n\t\t\t\tchild[property] = Object.assign(Object.create(null), parentValue);\n\t\t\t} else {\n\t\t\t\tchild[property] = parentValue;\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst contextMap = new WeakMap<Record<any, any>, Record<any, any>>();\nexport const metadataHoler = new ContextService(contextMap);\n\n\nexport function makeClassDecorator<V, Type = any>(\n\tdecorator?: (param: V, constructor: Type, context: ClassDecoratorContext<new (...args: any) => any>, metadata: MetadataContext) => void\n) {\n\treturn (param: V) => {\n\t\treturn (constructor: any, context: ClassDecoratorContext<new (...args: any) => any>) => {\n\t\t\tconst metadata = metadataHoler.getOrCreate(context.metadata);\n\t\t\tdecorator?.(param, constructor, context, metadata);\n\t\t\treturn constructor;\n\t\t};\n\t};\n}\n\nexport const Metadata = makeClassDecorator<void>();\n\nexport function makeClassMemberDecorator<Value, Context extends ClassMemberDecoratorContext = ClassMemberDecoratorContext>(\n\tdecorator?: (value: Value | undefined, context: Context, metadata: MetadataContext) => void\n) {\n\treturn (value: Value, context: Context) => {\n\t\tconst metadata = metadataHoler.getOrCreate(context.metadata);\n\t\tdecorator?.(value, context, metadata);\n\t};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/decorators",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Ibyar Decorators is implementations for proposal-decorator-metadata",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ibyar/aurora/tree/dev/packages/decorators",
@@ -36,7 +36,7 @@
36
36
  "tslib": "^2.6.2"
37
37
  },
38
38
  "devDependencies": {
39
- "typescript": "^5.2.2"
39
+ "typescript": "^5.3.3"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc --build --verbose"
@@ -48,5 +48,5 @@
48
48
  "typescript",
49
49
  "front-end"
50
50
  ],
51
- "gitHead": "9427f428b9783263536b896d363bd10a59b380de"
51
+ "gitHead": "85a94555492c9cf4c4a985f5972ebd5009708775"
52
52
  }