astro-ghostcms/.pnpm-store/v3/files/d5/413cbc735eb2f46d06c5074219b...

1 line
25 KiB
Plaintext
Raw Permalink Normal View History

2024-02-14 14:10:47 +00:00
{"version":3,"names":["_checkInRHS","require","_setFunctionName","_toPropertyKey","applyDecs2305","targetClass","memberDecs","classDecs","classDecsHaveThis","instanceBrand","parentClass","_bindPropCall","obj","name","before","_this","value","call","runInitializers","initializers","i","length","assertCallable","fn","hint1","hint2","throwUndefined","TypeError","applyDec","Class","decInfo","decoratorsHaveThis","kind","metadata","ret","isStatic","isPrivate","isField","isAccessor","hasPrivateBrand","assertInstanceIfPrivate","target","decs","decVal","_","isClass","Array","isArray","desc","init","key","get","setFunctionName","set","Object","getOwnPropertyDescriptor","newValue","dec","decThis","decoratorFinishedRef","ctx","addInitializer","initializer","v","Error","push","bind","static","private","access","has","instance","defineProperty","applyMemberDecs","decInfos","protoInitializers","staticInitializers","staticBrand","checkInRHS","existingNonFields","Map","pushInitializers","existingKind","prototype","toPropertyKey","defineMetadata","Symbol","for","configurable","enumerable","arguments","parentMetadata","create","e","c"],"sources":["../../src/helpers/applyDecs2305.ts"],"sourcesContent":["/* @minVersion 7.21.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\n STATIC = 8,\n\n DECORATORS_HAVE_THIS = 16,\n}\n\ntype DecoratorFinishedRef = { v?: boolean };\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;\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 any?,\n Function?,\n ]\n | [classDecs: Function[]];\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', () => console.log('privC')],\n [dec, 3, 'd'],\n [dec, 3, 'd', () => console.log('privD')],\n [dec, 4, 'e'],\n [dec, 4, 'e', () => console.log('privE')],\n ],\n [\n dec\n ]\n );\n\n initA = ret[0];\n\n init