UNPKG

kitten-cloud-function

Version:

用于编程猫源码云功能(云变量、云列表等)的客户端工具

1,295 lines 71.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const kitten_cloud_function_1 = require("../kitten-cloud-function"); const codemao_work_1 = require("../codemao/work/codemao-work"); const other_1 = require("../utils/other"); const kitten_cloud_variable_1 = require("../module/cloud-data/kitten-cloud-variable"); const codemao_user_1 = require("../codemao/user/codemao-user"); const kitten_cloud_private_variable_1 = require("../module/cloud-data/kitten-cloud-private-variable"); const kitten_cloud_list_1 = require("../module/cloud-data/kitten-cloud-list"); const slightning_coco_widget_1 = require("slightning-coco-widget"); const { project } = require("../../project"); const VariableValueType = [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING]; const ListItemValueType = [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING]; const types = { type: "SLIGHTNING_KITTEN_CLOUD_FUNCTION_WIDGET", title: project.name, author: project.author, category: "编程猫", icon: "icon-widget-cloud-room", version: project.version, license: project.license, docs: { url: project.docs }, isInvisibleWidget: true, isGlobalWidget: true, properties: [], methods: [ { line: "global", callMethodLabel: false }, { line: "连接", color: slightning_coco_widget_1.Color.PURPLE }, { key: "connect", label: "连接到", params: [ { key: "workID", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 0 } ] }, { key: "close", label: "关闭连接", params: [] }, { key: "isConnected", label: "已连接", params: [], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { key: "connectedWorkID", label: "已连接作品编号", params: [], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { line: "云变量", color: slightning_coco_widget_1.Color.BROWN }, { key: "getPrivateVariableList", label: "私有云变量列表", params: [], valueType: slightning_coco_widget_1.ValueType.ARRAY }, { key: "getPublicVariableList", label: "公有云变量列表", params: [], valueType: slightning_coco_widget_1.ValueType.ARRAY, blockOptions: { space: 40 } }, { key: "variableGet", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云变量" } ], valueType: VariableValueType }, { key: "variableSet", label: "设置", params: [ { key: "name", labelAfter: "的值", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云变量" }, { key: "value", label: "为", valueType: VariableValueType, defaultValue: "新的值" } ], blockOptions: { space: 40 } }, { key: "getRankingList", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "私有云变量" }, { key: "limit", label: "前", labelAfter: "名", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 31 }, { key: "order", labelAfter: "排行榜", dropdown: [ { label: "逆序", value: "-1" }, { label: "正序", value: "1" } ] } ], valueType: slightning_coco_widget_1.ValueType.ARRAY }, { line: "用户", color: slightning_coco_widget_1.Color.RED }, { key: "isUserLoggedIn", label: "用户已登录", params: [], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { key: "userLogIn", label: "用户登录", params: [], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { key: "getUserInfo", params: [ { key: "userID", label: "ID 为", labelAfter: "的用户", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 0 }, { key: "type", label: "的", dropdown: [ { label: "ID", value: "id" }, { label: "用户名", value: "username" }, { label: "昵称", value: "nickname" }, { label: "真实姓名", value: "realname" }, { label: "头像地址", value: "avatarURL" }, { label: "背景图片地址", value: "coverURL" }, { label: "描述", value: "description" }, { label: "正在做", value: "doing" }, { label: "邮箱", value: "email" }, { label: "级别", value: "level" }, { label: "等级", value: "grade" }, { label: "生日", value: "birthday" }, { label: "性别", value: "sex" }, { label: "总被被浏览次数", value: "viewTimes" }, { label: "总被被点赞次数", value: "praiseTimes" }, { label: "总被被收藏次数", value: "collectTimes" }, { label: "总被被再创作次数", value: "forkTimes" } ] } ], valueType: [slightning_coco_widget_1.ValueType.STRING, slightning_coco_widget_1.ValueType.NUMBER] }, { key: "getOnlineUsersNumber", label: "在线用户数", params: [], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { line: "云列表", color: slightning_coco_widget_1.Color.YELLOW }, { key: "getListList", label: "云列表列表", params: [], valueType: slightning_coco_widget_1.ValueType.ARRAY, blockOptions: { space: 40 } }, { key: "getListCopy", params: [ { key: "name", labelAfter: "副本", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" } ], valueType: slightning_coco_widget_1.ValueType.ARRAY }, { key: "listAppend", label: "添加", params: [ { key: "value", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "值" }, { key: "name", label: "到", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "position", dropdown: [ { label: "头部", value: "head" }, { label: "尾部", value: "tail" } ] } ] }, { key: "listAdd", label: "添加", params: [ { key: "value", valueType: ListItemValueType, defaultValue: "值" }, { key: "name", label: "到", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "indexingMode", dropdown: [ { label: "正数", value: "forward" }, { label: "倒数", value: "backward" } ] }, { key: "index", label: "第", labelAfter: "项", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1 } ] }, { key: "listRemove", label: "移除", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "indexingMode", dropdown: [ { label: "正数", value: "forward" }, { label: "倒数", value: "backward" } ] }, { key: "index", label: "第", labelAfter: "项", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1 } ] }, { key: "listEmpty", label: "清空", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" } ] }, { key: "listReplace", label: "替换", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "indexingMode", dropdown: [ { label: "正数", value: "forward" }, { label: "倒数", value: "backward" } ] }, { key: "index", label: "第", labelAfter: "项", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1 }, { key: "value", label: "为", valueType: ListItemValueType, defaultValue: "值" } ] }, { key: "listCopy", label: "复制", params: [ { key: "list1name", valueType: [slightning_coco_widget_1.ValueType.STRING, slightning_coco_widget_1.ValueType.ARRAY], defaultValue: "列表(可放入本地列表)" }, { key: "list2name", label: "到", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" } ], blockOptions: { space: 40 } }, { key: "listGet", params: [ { key: "name", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "indexingMode", dropdown: [ { label: "正数", value: "forward" }, { label: "倒数", value: "backward" } ] }, { key: "index", label: "第", labelAfter: "项", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1 } ], valueType: ListItemValueType }, { key: "listLength", params: [ { key: "name", labelAfter: "的项数", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" } ], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { key: "listFind", params: [ { key: "name", labelAfter: "中", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "countingMode", dropdown: [ { label: "正数", value: "forward" }, { label: "倒数", value: "backward" } ] }, { key: "count", label: "第", labelAfter: "个", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1 }, { key: "value", labelAfter: "的位置", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "值" } ], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { key: "listContain", params: [ { key: "name", labelAfter: "中", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "云列表" }, { key: "value", label: "包含", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "值" } ], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { line: "配置", color: slightning_coco_widget_1.Color.PINK }, { key: "getAutoReconnectIntervalTime", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" } ] }, { key: "dataName", labelAfter: "自动重连间隔时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", labelAfter: "的毫秒数", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN] }, { key: "getLocalPreupdate", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "本地预更新", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { key: "getCacheTime", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "缓存时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", labelAfter: "的毫秒数", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN] }, { key: "getUploadIntervalTime", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "上传间隔时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", labelAfter: "的毫秒数", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN] }, { key: "getUploadTimeout", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "上传超时时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", labelAfter: "的毫秒数", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { key: "getStringLengthLimit", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "字符串长度限制", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: slightning_coco_widget_1.ValueType.NUMBER }, { key: "getListLengthLimit", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "云列表组", value: "listGroup" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "列表长度限制", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "type", dropdown: [ { label: "配置值", value: "config" }, { label: "生效值", value: "value" } ] } ], valueType: slightning_coco_widget_1.ValueType.NUMBER, blockOptions: { space: 40 } }, { key: "setAutoReconnectIntervalTime", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" } ] }, { key: "dataName", labelAfter: "自动重连间隔时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", labelAfter: "毫秒", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN], defaultValue: 8000 } ] }, { key: "setLocalPreupdate", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "本地预更新", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", valueType: slightning_coco_widget_1.ValueType.BOOLEAN, defaultValue: true } ] }, { key: "setCacheTime", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "缓存时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", labelAfter: "毫秒", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN], defaultValue: 0 } ] }, { key: "setUploadIntervalTime", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "上传间隔时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", labelAfter: "毫秒", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN], defaultValue: 0 } ] }, { key: "setUploadTimeout", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "上传超时时间", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", labelAfter: "毫秒", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 4000 } ] }, { key: "setStringLengthLimit", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "私有云变量组", value: "privateVariableGroup" }, { label: "公有云变量组", value: "publicVariableGroup" }, { label: "云列表组", value: "listGroup" }, { label: "云变量", value: "variable" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "字符串长度限制", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1024 } ] }, { key: "setListLengthLimit", label: "设置", params: [ { key: "configLayerName", dropdown: [ { label: "连接", value: "connection" }, { label: "云列表组", value: "listGroup" }, { label: "云列表", value: "list" } ] }, { key: "dataName", labelAfter: "列表长度限制", valueType: slightning_coco_widget_1.ValueType.STRING, defaultValue: "" }, { key: "value", label: "为", valueType: slightning_coco_widget_1.ValueType.NUMBER, defaultValue: 1000 } ] }, { line: "已弃用", deprecated: true }, { key: "isUserLogged", label: "用户已登录", params: [], valueType: slightning_coco_widget_1.ValueType.BOOLEAN }, { key: "getConnectionConfigValue", label: "获取连接", params: [ { key: "type", dropdown: [ { label: "自动重连间隔时间", value: "autoReconnectIntervalTime" }, { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" }, { label: "列表长度限制", value: "listLengthLimit" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN] }, { key: "setConnectionConfig", label: "设置连接", params: [ { key: "type", dropdown: [ { label: "自动重连间隔时间", value: "autoReconnectIntervalTime" }, { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" }, { label: "列表长度限制", value: "listLengthLimit" } ] }, { key: "value", label: "为", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.BOOLEAN], defaultValue: 0 } ] }, { key: "getPrivateVariableConfigValue", label: "获取私有云变量", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING] }, { key: "setPrivateVariableConfig", label: "设置私有云变量", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" } ] }, { key: "value", label: "为", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING], defaultValue: 0 } ] }, { key: "getPublicVariableConfigValue", label: "获取公有云变量", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING] }, { key: "setPublicVariableConfig", label: "设置公有云变量", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" } ] }, { key: "value", label: "为", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING], defaultValue: 0 } ] }, { key: "getListConfigValue", label: "获取云列表", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" }, { label: "列表长度限制", value: "listLengthLimit" } ] } ], valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING] }, { key: "setListConfig", label: "设置云列表", params: [ { key: "type", dropdown: [ { label: "本地预更新", value: "localPreupdate" }, { label: "缓存时间", value: "cacheTime" }, { label: "上传间隔时间", value: "uploadIntervalTime" }, { label: "字符串长度限制", value: "stringLengthLimit" }, { label: "列表长度限制", value: "listLengthLimit" } ] }, { key: "value", label: "为", valueType: [slightning_coco_widget_1.ValueType.NUMBER, slightning_coco_widget_1.ValueType.STRING], defaultValue: 0 } ] } ], events: [ { key: "onOpen", label: "连接打开", params: [] }, { key: "onClose", label: "连接关闭", params: [] }, { key: "onError", label: "出现错误", params: [ { key: "message", label: "信息", valueType: slightning_coco_widget_1.ValueType.STRING } ] }, { key: "onOnlineUsersNumberChanged", label: "在线用户数改变", params: [ { key: "originalNumber", label: "原数量", valueType: slightning_coco_widget_1.ValueType.NUMBER }, { key: "newNumber", label: "新数量", valueType: slightning_coco_widget_1.ValueType.NUMBER } ] }, { key: "onPublicVariableValueChanged", label: "公有云变量值改变", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "originalValue", label: "原值", valueType: VariableValueType }, { key: "newValue", label: "新值", valueType: VariableValueType } ] }, { key: "onListPushed", label: "云列表添加到尾项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "item", label: "项", valueType: ListItemValueType } ] }, { key: "onListUnshifted", label: "云列表添加到首项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "item", label: "项", valueType: ListItemValueType } ] }, { key: "onListAdd", label: "云列表添加项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "position", label: "位置", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "item", label: "项", valueType: ListItemValueType } ] }, { key: "onListPopped", label: "云列表移除尾项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "item", label: "项", valueType: ListItemValueType } ] }, { key: "onListRemove", label: "云列表移除项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "position", label: "位置", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "item", label: "项", valueType: ListItemValueType } ] }, { key: "onListEmptied", label: "云列表清空", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "list", label: "列表", valueType: slightning_coco_widget_1.ValueType.ARRAY } ] }, { key: "onListReplacedLast", label: "云列表替换尾项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "originalItem", label: "原项", valueType: ListItemValueType }, { key: "newItem", label: "新项", valueType: ListItemValueType } ] }, { key: "onListReplaced", label: "云列表替换项", params: [ { key: "name", label: "名称", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "source", label: "来源", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "position", label: "位置", valueType: slightning_coco_widget_1.ValueType.STRING }, { key: "originalItem", label: "原项", valueType: ListItemValueType }, { key: "newItem", label: "新项", valueType: ListItemValueType } ] } ] }; let hasOutputVersionInfo = false; const userRecord = {}; userRecord[0] = kitten_cloud_function_1.KittenCloudFunction.user; class KittenCloudFunctionWidget extends (0, slightning_coco_widget_1.SLIGHTNINGWidgetSuper)(types, slightning_coco_widget_1.InvisibleWidget) { constructor() { super(...arguments); this.isOpened = false; this.handleClose = () => { this.connection = other_1.None; this.emit("onClose"); }; } getConnection() { if (this.connection == other_1.None) { throw new Error("当前未连接,请连接后再试"); } return this.connection; } connect(workID) { if (this.connection != other_1.None) { this.close(); this.warn("上一个连接未断开,已自动断开"); } if (!hasOutputVersionInfo) { if (KITTEN_CLOUD_FUNCTION_DEVELOP) { this.log(`${project.name} ${project.version}(开发调试版)`); if (!/^https?:\/\/(coco\.codemao\.cn\/editor\/editor-player\.html|cp\.cocotais\.cn\/((pptui)\/?)?)$/.test(location.origin + location.pathname)) { const message = `不要将 ${project.name} ${project.version}(开发调试版)用于生产环境中!`; this.error(new Error(message)); alert(message); } } else if (KITTEN_CLOUD_FUNCTION_ALLOW == other_1.None) { this.log(`${project.name} v${project.version}(修改受限版版)`); } else { this.log(`${project.name} v${project.version}(用户 ${KITTEN_CLOUD_FUNCTION_ALLOW.USER} 在 ${KITTEN_CLOUD_FUNCTION_ALLOW.USING_WORK} 中连接 ${KITTEN_CLOUD_FUNCTION_ALLOW.CONNECTING_WORK} 的专用版)`); } hasOutputVersionInfo = true; } this.isOpened = false; this.connection = new kitten_cloud_function_1.KittenCloudFunction(workID); this.connection.publicVariable.getAll().then((variableArray) => { for (const variable of variableArray) { variable.changed.connect(({ source, originalValue, newValue }) => { this.emit("onPublicVariableValueChanged", variable.name, source.name, originalValue, newValue); }); } }); this.connection.onlineUserNumber.then((onlineUserNumber) => { onlineUserNumber.changed.connect(({ originalNumber, newNumber }) => { this.emit("onOnlineUsersNumberChanged", originalNumber, newNumber); }); }); this.connection.list.getAll().then((listArray) => { for (const list of listArray) { list.pushed.connect(({ source, item }) => { this.emit("onListPushed", list.name, source.name, item); }); list.unshifted.connect(({ source, item }) => { this.emit("onListUnshifted", list.name, source.name, item); }); list.added.connect(({ source, index, item }) => { this.emit("onListAdd", list.name, source.name, index, item); }); list.popped.connect(({ source, item }) => { this.emit("onListPopped", list.name, source.name, item); }); list.removed.connect(({ source, index, item }) => { this.emit("onListRemove", list.name, source.name, index, item); }); list.emptied.connect(({ source, list: listValue }) => { this.emit("onListEmptied", list.name, source.name, listValue); }); list.replacedLast.connect(({ source, originalItem, newItem }) => { this.emit("onListReplacedLast", list.name, source.name, originalItem, newItem); }); list.replaced.connect(({ source, index, originalItem, newItem }) => { this.emit("onListReplaced", list.name, source.name, index, originalItem, newItem); }); } }); this.connection.opened.connect(() => { this.isOpened = true; this.emit("onOpen"); }); this.connection.errored.connect((error) => { if (!this.isOpened) { this.connection = other_1.None; } this.error(error); }); this.connection.closed.connect(this.handleClose); } async checkModifiable() { var _a, _b, _c; if (KITTEN_CLOUD_FUNCTION_DEVELOP) { return; } else if (KITTEN_CLOUD_FUNCTION_ALLOW != other_1.None) { let user, usingWork, connectingWork; let message = ""; if (location.protocol != "file:") { if (location.pathname == "/editor/editor-player.html" || location.pathname == "/player") { usingWork = parseInt((_a = new URLSearchParams(location.hash).get("#id")) !== null && _a !== void 0 ? _a : ""); user = await kitten_cloud_function_1.KittenCloudFunction.user.info.id; } else { usingWork = parseInt((_b = location.pathname.split("/").pop()) !== null && _b !== void 0 ? _b : ""); user = await (await new codemao_work_1.CodemaoWork({ id: usingWork }).info.author).info.id; } if (!KITTEN_CLOUD_FUNCTION_ALLOW.USER.split(",").includes(String(user))) { message += ",仅用户 " + KITTEN_CLOUD_FUNCTION_ALLOW.USER + " 可用"; } if (location.hostname != "cp.cocotais.cn") { if (!KITTEN_CLOUD_FUNCTION_ALLOW.USING_WORK.split(",").includes(String(usingWork))) { message += ",仅在 CoCo 作品 " + KITTEN_CLOUD_FUNCTION_ALLOW.USING_WORK + " 可用"; } } } connectingWork = await this.getConnection().work.info.id; if (!KITTEN_CLOUD_FUNCTION_ALLOW.CONNECTING_WORK.split(",").includes(String(connectingWork))) { message += ",仅可连接作品 " + KITTEN_CLOUD_FUNCTION_ALLOW.CONNECTING_WORK + ""; } if (message != "") { throw new Error(`当前版本为专用版${message}`); } } else { let expectedWorkAuthorID = other_1.None; if (location.pathname == "/editor/editor-player.html" || location.pathname == "/player") { expectedWorkAuthorID = await kitten_cloud_function_1.KittenCloudFunction.user.info.id; } else { const thisWorkID = parseInt((_c = location.pathname.split("/").pop()) !== null && _c !== void 0 ? _c : ""); if (!Number.isNaN(thisWorkID)) { expectedWorkAuthorID = await (await new codemao_work_1.CodemaoWork({ id: thisWorkID }).info.author).info.id; } } if (expectedWorkAuthorID == other_1.None) { throw new Error(`当前版本为修改受限版版,只能修改自己作品的云数据,但是源码云功能无法验证你的身份`); } if (await (await this.getConnection().work.info.author).info.id != expectedWorkAuthorID) { throw new Error(`当前版本为修改受限版版,只能修改自己作品的云数据,而 ${await this.getConnection().work.info.name} 不是你的作品`); } } } close() { const connection = this.getConnection(); connectio