toObjectDataInfo()

in remote/data-info-manager.js [244:295]


    toObjectDataInfo(target) {
        /** @type {Donuts.Remote.IObjectDataInfo} */
        // @ts-ignore
        let dataInfo = this.dataInfoMap.get(target);
        
        if (dataInfo) {
            return dataInfo;
        }

        dataInfo = {
            type: "object",
            id: random.generateUuidAlike(),
            memberInfos: Object.create(null)
        };

        const memberInfos = dataInfo.memberInfos;

        let currentObj = target;

        while (currentObj && currentObj !== Object.prototype) {
            const propertyDescriptors = Object.getOwnPropertyDescriptors(currentObj);
            // @ts-ignore "constructor" value is the same as other properties.
            const isClass = utils.isFunction(propertyDescriptors["constructor"].value);

            for (const propertyName in propertyDescriptors) {
                const propertyDescriptor = propertyDescriptors[propertyName];

                // ignore the member in parent class.
                if (propertyName in memberInfos) {
                    continue;
                }

                // if the member is pure-constant value.
                if ((!propertyDescriptor.writable
                    && !propertyDescriptor.configurable
                    && !propertyDescriptor.get
                    && !propertyDescriptor.set)
                    // if the member is a non-enumerable function in the class.
                    || (isClass
                        && !propertyDescriptor.enumerable
                        && utils.isFunction(propertyDescriptor.value))) {
                    memberInfos[propertyName] = this.toDataInfo(propertyDescriptor.value, false);
                }
            }

            currentObj = Object.getPrototypeOf(currentObj);
        }

        this.dataInfoMap.set(target, dataInfo);

        return dataInfo;
    }