{"version":3,"sources":["get_prototype_properties.ts"],"sourcesContent":["import type { Class } from \"datex-core-legacy/utils/global_types.ts\";\n\n/**\n * returns list of all property names and there corresponding value,\n * taking prototype overriding into account\n * @param clss class with prototypes\n * @returns \n */\nexport function* getPrototypeProperties(clss: Class) {\n\tconst usedKeys = new Set<string>();\n\tdo {\n\t\tconst proto=clss.prototype;\n\t\tif (!proto) return;\n\t\tfor (const x of Object.getOwnPropertyNames(proto)) {\n\t\t\tif (!usedKeys.has(x)) {\n\t\t\t\tusedKeys.add(x);\n\t\t\t\tyield [x, proto[x]];\n\t\t\t}\n\t\t}\n\t} while ((clss=Object.getPrototypeOf(clss)) && clss != HTMLElement && clss != Object); // prototype chain\n\treturn;\n}\n\n\nexport const DISPOSE_BOUND_PROTOTYPE = Symbol(\"DISPOSE_BOUND_PROTOTYPE\");\n\n/**\n * Bind class prototoype to a value to act if the value was extending the class\n * @param value object\n * @param clss class with prototype\n */\nexport function bindPrototype(value:Record<string|symbol,unknown>, clss:Class) {\n\tconst keys = new Set<string>()\n\tvalue[DISPOSE_BOUND_PROTOTYPE] = () => {\n\t\tconst hasOnDisplay = !!keys.has(\"onDisplay\");\n\t\tfor (const k of keys) delete value[k];\n\t\tdelete value[DISPOSE_BOUND_PROTOTYPE];\n\t\treturn hasOnDisplay;\n\t}\n\n\tfor (const [n,v] of getPrototypeProperties(clss)) {\n\t\tif (n == \"constructor\") continue;\n\t\tvalue[n] = v.bind(value);\n\t\tkeys.add(n)\n\t}\n\n}"],"names":["getPrototypeProperties","clss","usedKeys","Set","proto","prototype","x","Object","getOwnPropertyNames","has","add","getPrototypeOf","HTMLElement","DISPOSE_BOUND_PROTOTYPE","Symbol","bindPrototype","value","keys","n","v","hasOnDisplay","k","bind"],"mappings":"AAQA,OAAO,UAAUA,uBAAuBC,IAAW;IAClD,IAAMC,WAAW,IAAIC;IACrB,GAAG;QACF,IAAMC,QAAMH,KAAKI,SAAS;QAC1B,IAAI,CAACD,OAAO;QACZ,KAAK,IAAME,KAAKC,OAAOC,mBAAmB,CAACJ,OACrCF,SAASO,GAAG,CAACH,OACjBJ,SAASQ,GAAG,CAACJ,IACb,MAAM;YAACA;YAAGF,KAAK,CAACE,EAAE;SAAC;IAGtB,QAAS,AAACL,CAAAA,OAAKM,OAAOI,cAAc,CAACV,KAAI,KAAMA,QAAQW,eAAeX,QAAQM,OAAQ;AAEvF;AAGA,OAAO,MAAMM,0BAA0BC,OAAO,2BAA2B;AAOzE,OAAO,SAASC,cAAcC,KAAmC,EAAEf,IAAU;IAC5E,IAAMgB,OAAO,IAAId;IAQjB,KAAK,IAAM,CAACe,GAAEC,EAAE,KAPhBH,KAAK,CAACH,wBAAwB,GAAG;QAChC,IAAMO,eAAe,CAAC,CAACH,KAAKR,GAAG,CAAC;QAChC,KAAK,IAAMY,KAAKJ,KAAM,OAAOD,KAAK,CAACK,EAAE;QAErC,OADA,OAAOL,KAAK,CAACH,wBAAwB,EAC9BO;IACR,GAEoBpB,uBAAuBC,OACjC,iBAALiB,MACJF,KAAK,CAACE,EAAE,GAAGC,EAAEG,IAAI,CAACN,QAClBC,KAAKP,GAAG,CAACQ;AAGX","sourceRoot":"/lib/uix-0.4.39/src/standalone/","file":"get_prototype_properties.ts"}