ohctechv3/.svn/pristine/f2/f23fb6e8bb48a3af3b795652acdc1268ce45cf34.svn-base

1 line
26 KiB
Plaintext
Raw Permalink Normal View History

2024-10-28 15:03:36 +05:30
{"version":3,"names":["_checkInRHS","require","_setFunctionName","_toPropertyKey","applyDecs2311","targetClass","classDecs","memberDecs","classDecsHaveThis","instanceBrand","parentClass","symbolMetadata","Symbol","metadata","for","defineProperty","Object","create","existingNonFields","hasClassDecs","length","_","createRunInitializers","initializers","useStaticThis","hasValue","thisArg","value","i","apply","assertCallable","fn","hint1","hint2","throwUndefined","TypeError","applyDec","Class","decInfo","decoratorsHaveThis","name","kind","ret","isStatic","isPrivate","isField","hasPrivateBrand","assertInstanceIfPrivate","target","decs","concat","decVal","isClass","isAccessor","isGetter","isSetter","isMethod","_bindPropCall","before","_this","desc","call","init","key","get","setFunctionName","set","getOwnPropertyDescriptor","Error","newValue","dec","decThis","decoratorFinishedRef","ctx","addInitializer","initializer","v","push","bind","static","private","access","has","unshift","splice","applyMemberDecs","protoInitializers","staticInitializers","pushInitializers","applyMemberDecsOfKind","kindOnly","prototype","toPropertyKey","checkInRHS","defineMetadata","configurable","enumerable","undefined","e","c"],"sources":["../../src/helpers/applyDecs2311.ts"],"sourcesContent":["/* @minVersion 7.24.0 */\n/* @mangleFns */\n\nimport checkInRHS from \"./checkInRHS.ts\";\nimport setFunctionName from \"./setFunctionName.ts\";\nimport toPropertyKey from \"./toPropertyKey.ts\";\n\nconst enum PROP_KIND {\n FIELD = 0,\n ACCESSOR = 1,\n METHOD = 2,\n GETTER = 3,\n SETTER = 4,\n CLASS = 5,\n KIND_MASK = 7, // 0b111\n\n STATIC = 8,\n\n DECORATORS_HAVE_THIS = 16,\n}\n\ntype DecoratorFinishedRef = { v?: number };\ntype DecoratorContextAccess = {\n get?: (target: object) => any;\n set?: (target: object, value: any) => void;\n has: (target: object) => boolean;\n};\ntype DecoratorContext = {\n kind: \"accessor\" | \"method\" | \"getter\" | \"setter\" | \"field\" | \"class\";\n name: string | symbol;\n static?: boolean;\n private?: boolean;\n access?: DecoratorContextAccess;\n metadata?: any;\n addInitializer?: (initializer: Function) => void;\n};\ntype DecoratorInfo =\n | [\n decs: Function | Function[],\n kind: PROP_KIND,\n name: string,\n privateGetter?: Function,\n privateSetter?: Function,\n ]\n | [classDecs: Function[]];\ntype DecoratorNonFieldCheckStorage = Record<\n string | symbol,\n PROP_KIND.ACCESSOR | PROP_KIND.GETTER | PROP_KIND.SETTER\n>;\n/**\n Basic usage:\n\n applyDecs(\n Class,\n [\n // member decorators\n [\n decs, // dec, or array of decs, or array of this values and decs\n 0, // kind of value being decorated\n 'prop', // name of public prop on class containing the value being decorated,\n '#p', // the name of the private property (if is private, void 0 otherwise),\n ]\n ],\n [\n // class decorators\n dec1, dec2\n ]\n )\n ```\n\n Fully transpiled example:\n\n ```js\n @dec\n class Class {\n @dec\n a = 123;\n\n @dec\n #a = 123;\n\n @dec\n @dec2\n accessor b = 123;\n\n @dec\n accessor #b = 123;\n\n @dec\n c() { console.log('c'); }\n\n @dec\n #c() { console.log('privC'); }\n\n @dec\n get d() { console.log('d'); }\n\n @dec\n get #d() { console.log('privD'); }\n\n @dec\n set e(v) { console.log('e'); }\n\n @dec\n set #e(v) { console.log('privE'); }\n }\n\n\n // becomes\n let initializeInstance;\n let initializeClass;\n\n let initA;\n let initPrivA;\n\n let initB;\n let initPrivB, getPrivB, setPrivB;\n\n let privC;\n let privD;\n let privE;\n\n let Class;\n class _Class {\n static {\n let ret = applyDecs(\n this,\n [\n [dec, 0, 'a'],\n [dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],\n [[dec, dec2], 1, 'b'],\n [dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],\n [dec, 2, 'c'],\n [dec, 2, 'c', () => c