cushax-client
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -14,3 +14,3 @@ import { matchPage, existPage } from "./utils"; | ||
if (existPage(schema, pageName)) { | ||
var page = new Page(pageName, schema, socket, $vue); | ||
var page_1 = new Page(pageName, schema, socket, $vue); | ||
for (var _i = 0, _a = route.matched; _i < _a.length; _i++) { | ||
@@ -20,3 +20,4 @@ var instances = _a[_i].instances; | ||
var instance = _c[_b]; | ||
instance.$page = page; | ||
instance.$page = page_1; | ||
instance.$getPage = function () { return page_1; }; | ||
} | ||
@@ -23,0 +24,0 @@ } |
/// <reference types="socket.io-client" /> | ||
import { Module } from "vuex"; | ||
export declare class Page<TSchema extends Module<any, any>> { | ||
declare type ObjectPropertyToPair<TObject, TKey extends keyof TObject, TPKey> = TPKey extends keyof TObject[TKey] ? [TPKey, TObject[TKey][TPKey]] : never; | ||
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
export declare class Page<TModule extends Module<any, any>> { | ||
private name; | ||
@@ -8,9 +10,10 @@ private cushax; | ||
private vue; | ||
get state(): TSchema["state"]; | ||
get state(): TModule["state"]; | ||
private get schema(); | ||
constructor(name: string, cushax: Module<string, string>, socket: SocketIOClient.Socket, vue: Vue); | ||
commit: (name: string, payload: any) => void; | ||
update: (params: any) => void; | ||
emit: (event: string, data: any) => void; | ||
constructor(name: string, cushax: any, socket: SocketIOClient.Socket, vue: Vue); | ||
commit: UnionToIntersection<ObjectPropertyToPair<TModule, "mutations", keyof TModule["mutations"]> extends [infer TName, infer TFunction] ? TFunction extends (state: any, payload: infer TPayload) => any ? (name: TName, payload: TPayload) => void : never : never>; | ||
update: (params: Partial<TModule["state"]["$params"]>) => void; | ||
emit: <TKey extends keyof TModule["state"]["$event"]>(params: TKey, data: TModule["state"]["$event"][TKey]) => void; | ||
reset: () => void; | ||
} | ||
export {}; |
@@ -9,6 +9,6 @@ import { buildPage } from "./utils"; | ||
this.vue = vue; | ||
this.commit = function (name, payload) { | ||
this.commit = (function (name, payload) { | ||
_this.vue.$store.commit("cushax/" + _this.name + "/" + name, payload); | ||
}; | ||
this.update = function (params) { | ||
}); | ||
this.update = (function (params) { | ||
_this.vue.$store.commit("cushax/" + _this.name + "/$update", params); | ||
@@ -18,4 +18,4 @@ _this.socket.emit("page:sync", { | ||
}); | ||
}; | ||
this.emit = function (event, data) { | ||
}); | ||
this.emit = (function (event, data) { | ||
var _a, _b; | ||
@@ -30,3 +30,3 @@ if (!((_b = (_a = _this.schema) === null || _a === void 0 ? void 0 : _a.state["$event"]) === null || _b === void 0 ? void 0 : _b[event])) { | ||
}); | ||
}; | ||
}); | ||
this.reset = function () { | ||
@@ -33,0 +33,0 @@ var _a; |
import { Page } from "./page"; | ||
import { Module } from "vuex"; | ||
declare module "vue/types/vue" { | ||
interface Vue { | ||
$page: Page<any>; | ||
$getPage: <TSchema extends Module<any, any>, TKey extends keyof TSchema["modules"]>() => Page<TSchema["modules"][TKey]>; | ||
} | ||
} |
{ | ||
"name": "cushax-client", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "boenfu <1997@boenfu.cn>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13217
281