New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@knxcloud/lowcode-hooks

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knxcloud/lowcode-hooks - npm Package Compare versions

Comparing version
1.6.0-beta.5
to
1.6.0-beta.6
+60
-1
dist/lowcode-hooks.js

@@ -1,2 +0,61 @@

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue");function d(){let e=window.__currentNode;return e||(e=Symbol("__currentNode"),window.__currentNode=e),e}function c(){const e=d();return o.inject(e,()=>({mode:"live",node:null,isDesignerEnv:!1}),!0)}function i(){let e=window.__rendererContext;return e||(e=Symbol("__rendererContext"),window.__rendererContext=e),e}function g(){const e=i();return o.inject(e,()=>{var r,u;const t=(u=(r=o.getCurrentInstance())==null?void 0:r.props)!=null?u:{};return{rerender:()=>{},thisRequiredInJSE:!0,components:n(t,"components",{}),designMode:n(t,"designMode","live"),getNode:n(t,"getNode",()=>null),wrapLeafComp:(C,_,s)=>s,triggerCompGetCtx:n(t,"triggerCompGetCtx",()=>{})}},!0)}function n(e,t,r){return e[t]||e[`__${t}`]||r}exports.getCurrentNodeKey=d;exports.getRendererContextKey=i;exports.useCurrentNode=c;exports.useRendererContext=g;
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
function getCurrentNodeKey() {
let key = window.__currentNode;
if (!key) {
key = Symbol("__currentNode");
window.__currentNode = key;
}
return key;
}
function useCurrentNode() {
const key = getCurrentNodeKey();
return vue.inject(
key,
() => {
return {
mode: "live",
node: null,
isDesignerEnv: false
};
},
true
);
}
function getRendererContextKey() {
let key = window.__rendererContext;
if (!key) {
key = Symbol("__rendererContext");
window.__rendererContext = key;
}
return key;
}
function useRendererContext() {
const key = getRendererContextKey();
return vue.inject(
key,
() => {
var _a, _b;
const props = (_b = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.props) != null ? _b : {};
return {
rerender: () => void 0,
thisRequiredInJSE: true,
components: getPropValue(props, "components", {}),
designMode: getPropValue(props, "designMode", "live"),
getNode: getPropValue(props, "getNode", () => null),
wrapLeafComp: (_, __, leaf) => leaf,
triggerCompGetCtx: getPropValue(props, "triggerCompGetCtx", () => void 0)
};
},
true
);
}
function getPropValue(props, key, defaultValue) {
return props[key] || props[`__${key}`] || defaultValue;
}
exports.getCurrentNodeKey = getCurrentNodeKey;
exports.getRendererContextKey = getRendererContextKey;
exports.useCurrentNode = useCurrentNode;
exports.useRendererContext = useRendererContext;
//# sourceMappingURL=lowcode-hooks.js.map
+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"lowcode-hooks.js","sources":["../src/current-node.ts","../src/renderer-context.ts"],"sourcesContent":["import type {\n GlobalEvent,\n IPublicModelNode,\n IPublicTypeDisposable,\n} from '@alilc/lowcode-types';\nimport type { InjectionKey } from 'vue';\nimport type { DesignMode } from './renderer-context';\nimport { inject } from 'vue';\n\nexport type IPublicTypePropChangeOptions = Omit<\n GlobalEvent.Node.Prop.ChangeOptions,\n 'node'\n>;\n\nexport interface INode extends IPublicModelNode {\n onVisibleChange(func: (flag: boolean) => any): () => void;\n onPropChange(func: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable;\n onChildrenChange(\n fn: (param?: { type: string; node: INode } | undefined) => void\n ): IPublicTypeDisposable | undefined;\n}\n\nexport interface EnvNode {\n mode: DesignMode;\n node: INode | null;\n isDesignerEnv: boolean;\n}\n\nexport interface DesignerEnvNode extends EnvNode {\n mode: 'design';\n node: INode;\n isDesignerEnv: true;\n}\n\nexport interface LiveEnvNode extends EnvNode {\n mode: 'live';\n node: null;\n isDesignerEnv: false;\n}\n\nexport type CurrentNode = DesignerEnvNode | LiveEnvNode;\n\nexport function getCurrentNodeKey(): InjectionKey<CurrentNode> {\n let key = (window as any).__currentNode;\n if (!key) {\n key = Symbol('__currentNode');\n (window as any).__currentNode = key;\n }\n return key;\n}\n\nexport function useCurrentNode(): CurrentNode {\n const key = getCurrentNodeKey();\n return inject(\n key,\n () => {\n return {\n mode: 'live',\n node: null,\n isDesignerEnv: false,\n } as LiveEnvNode;\n },\n true\n );\n}\n","import type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';\nimport type { Component, ComponentPublicInstance, InjectionKey } from 'vue';\nimport type { INode } from './current-node';\nimport { inject, getCurrentInstance } from 'vue';\n\nexport type DesignMode = 'live' | 'design';\n\nexport interface RendererContext {\n readonly components: Record<string, Component<any, any, any>>;\n readonly designMode: DesignMode;\n readonly thisRequiredInJSE: boolean;\n getNode(id: string): INode | null;\n rerender(): void;\n wrapLeafComp<C extends object, L extends object>(name: string, comp: C, leaf: L): L;\n triggerCompGetCtx(schema: IPublicTypeNodeSchema, val: ComponentPublicInstance): void;\n}\n\nexport function getRendererContextKey(): InjectionKey<RendererContext> {\n let key = (window as any).__rendererContext;\n if (!key) {\n key = Symbol('__rendererContext');\n (window as any).__rendererContext = key;\n }\n return key;\n}\n\nexport function useRendererContext(): RendererContext {\n const key = getRendererContextKey();\n return inject(\n key,\n () => {\n const props = getCurrentInstance()?.props ?? {};\n return {\n rerender: () => void 0,\n thisRequiredInJSE: true,\n components: getPropValue(props, 'components', {}),\n designMode: getPropValue<DesignMode>(props, 'designMode', 'live'),\n getNode: getPropValue(props, 'getNode', () => null),\n wrapLeafComp: <T extends object, L extends object>(_: string, __: T, leaf: L) =>\n leaf,\n triggerCompGetCtx: getPropValue(props, 'triggerCompGetCtx', () => void 0),\n };\n },\n true\n );\n}\n\nfunction getPropValue<T>(\n props: Record<string, unknown>,\n key: string,\n defaultValue: T\n): T {\n return (props[key] || props[`__${key}`] || defaultValue) as T;\n}\n"],"names":["getCurrentNodeKey","key","useCurrentNode","inject","getRendererContextKey","useRendererContext","props","getCurrentInstance","getPropValue","_","__","leaf","defaultValue"],"mappings":"uGA0CO,SAASA,GAA+C,CAC7D,IAAIC,EAAO,OAAe,cAC1B,OAAKA,IACHA,EAAM,OAAO,eAAe,EAC3B,OAAe,cAAgBA,GAE3BA,CACT,CAEO,SAASC,GAA8B,CAC5C,MAAMD,EAAMD,IACL,OAAAG,EAAA,OACLF,EACA,KACS,CACL,KAAM,OACN,KAAM,KACN,cAAe,EAAA,GAGnB,EAAA,CAEJ,CC/CO,SAASG,GAAuD,CACrE,IAAIH,EAAO,OAAe,kBAC1B,OAAKA,IACHA,EAAM,OAAO,mBAAmB,EAC/B,OAAe,kBAAoBA,GAE/BA,CACT,CAEO,SAASI,GAAsC,CACpD,MAAMJ,EAAMG,IACL,OAAAD,EAAA,OACLF,EACA,IAAM,SACJ,MAAMK,GAAQC,GAAAA,EAAAA,EAAAA,uBAAAA,YAAAA,EAAsB,QAAtBA,KAAAA,EAA+B,CAAA,EACtC,MAAA,CACL,SAAU,IAAM,GAChB,kBAAmB,GACnB,WAAYC,EAAaF,EAAO,aAAc,CAAA,CAAE,EAChD,WAAYE,EAAyBF,EAAO,aAAc,MAAM,EAChE,QAASE,EAAaF,EAAO,UAAW,IAAM,IAAI,EAClD,aAAc,CAAqCG,EAAWC,EAAOC,IACnEA,EACF,kBAAmBH,EAAaF,EAAO,oBAAqB,IAAA,EAAY,CAAA,CAE5E,EACA,EAAA,CAEJ,CAEA,SAASE,EACPF,EACAL,EACAW,EACG,CACH,OAAQN,EAAML,CAAG,GAAKK,EAAM,KAAKL,GAAK,GAAKW,CAC7C"}
{"version":3,"file":"lowcode-hooks.js","sources":["../src/current-node.ts","../src/renderer-context.ts"],"sourcesContent":["import type {\n GlobalEvent,\n IPublicModelNode,\n IPublicTypeDisposable,\n} from '@alilc/lowcode-types';\nimport type { InjectionKey } from 'vue';\nimport type { DesignMode } from './renderer-context';\nimport { inject } from 'vue';\n\nexport type IPublicTypePropChangeOptions = Omit<\n GlobalEvent.Node.Prop.ChangeOptions,\n 'node'\n>;\n\nexport interface INode extends IPublicModelNode {\n onVisibleChange(func: (flag: boolean) => any): () => void;\n onPropChange(func: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable;\n onChildrenChange(\n fn: (param?: { type: string; node: INode } | undefined) => void\n ): IPublicTypeDisposable | undefined;\n}\n\nexport interface EnvNode {\n mode: DesignMode;\n node: INode | null;\n isDesignerEnv: boolean;\n}\n\nexport interface DesignerEnvNode extends EnvNode {\n mode: 'design';\n node: INode;\n isDesignerEnv: true;\n}\n\nexport interface LiveEnvNode extends EnvNode {\n mode: 'live';\n node: null;\n isDesignerEnv: false;\n}\n\nexport type CurrentNode = DesignerEnvNode | LiveEnvNode;\n\nexport function getCurrentNodeKey(): InjectionKey<CurrentNode> {\n let key = (window as any).__currentNode;\n if (!key) {\n key = Symbol('__currentNode');\n (window as any).__currentNode = key;\n }\n return key;\n}\n\nexport function useCurrentNode(): CurrentNode {\n const key = getCurrentNodeKey();\n return inject(\n key,\n () => {\n return {\n mode: 'live',\n node: null,\n isDesignerEnv: false,\n } as LiveEnvNode;\n },\n true\n );\n}\n","import type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';\nimport type { Component, ComponentPublicInstance, InjectionKey } from 'vue';\nimport type { INode } from './current-node';\nimport { inject, getCurrentInstance } from 'vue';\n\nexport type DesignMode = 'live' | 'design';\n\nexport interface RendererContext {\n readonly components: Record<string, Component<any, any, any>>;\n readonly designMode: DesignMode;\n readonly thisRequiredInJSE: boolean;\n getNode(id: string): INode | null;\n rerender(): void;\n wrapLeafComp<C extends object, L extends object>(name: string, comp: C, leaf: L): L;\n triggerCompGetCtx(schema: IPublicTypeNodeSchema, val: ComponentPublicInstance): void;\n}\n\nexport function getRendererContextKey(): InjectionKey<RendererContext> {\n let key = (window as any).__rendererContext;\n if (!key) {\n key = Symbol('__rendererContext');\n (window as any).__rendererContext = key;\n }\n return key;\n}\n\nexport function useRendererContext(): RendererContext {\n const key = getRendererContextKey();\n return inject(\n key,\n () => {\n const props = getCurrentInstance()?.props ?? {};\n return {\n rerender: () => void 0,\n thisRequiredInJSE: true,\n components: getPropValue(props, 'components', {}),\n designMode: getPropValue<DesignMode>(props, 'designMode', 'live'),\n getNode: getPropValue(props, 'getNode', () => null),\n wrapLeafComp: <T extends object, L extends object>(_: string, __: T, leaf: L) =>\n leaf,\n triggerCompGetCtx: getPropValue(props, 'triggerCompGetCtx', () => void 0),\n };\n },\n true\n );\n}\n\nfunction getPropValue<T>(\n props: Record<string, unknown>,\n key: string,\n defaultValue: T\n): T {\n return (props[key] || props[`__${key}`] || defaultValue) as T;\n}\n"],"names":["inject","getCurrentInstance"],"mappings":";;;AA0CO,SAAS,oBAA+C;AAC7D,MAAI,MAAO,OAAe;AAC1B,MAAI,CAAC,KAAK;AACR,UAAM,OAAO,eAAe;AAC3B,WAAe,gBAAgB;AAAA,EAClC;AACO,SAAA;AACT;AAEO,SAAS,iBAA8B;AAC5C,QAAM,MAAM;AACL,SAAAA,IAAA;AAAA,IACL;AAAA,IACA,MAAM;AACG,aAAA;AAAA,QACL,MAAM;AAAA,QACN,MAAM;AAAA,QACN,eAAe;AAAA,MAAA;AAAA,IAEnB;AAAA,IACA;AAAA,EAAA;AAEJ;AC/CO,SAAS,wBAAuD;AACrE,MAAI,MAAO,OAAe;AAC1B,MAAI,CAAC,KAAK;AACR,UAAM,OAAO,mBAAmB;AAC/B,WAAe,oBAAoB;AAAA,EACtC;AACO,SAAA;AACT;AAEO,SAAS,qBAAsC;AACpD,QAAM,MAAM;AACL,SAAAA,IAAA;AAAA,IACL;AAAA,IACA,MAAM;;AACJ,YAAM,SAAQC,eAAAA,yBAAAA,mBAAsB,UAAtBA,YAA+B,CAAA;AACtC,aAAA;AAAA,QACL,UAAU,MAAM;AAAA,QAChB,mBAAmB;AAAA,QACnB,YAAY,aAAa,OAAO,cAAc,CAAA,CAAE;AAAA,QAChD,YAAY,aAAyB,OAAO,cAAc,MAAM;AAAA,QAChE,SAAS,aAAa,OAAO,WAAW,MAAM,IAAI;AAAA,QAClD,cAAc,CAAqC,GAAW,IAAO,SACnE;AAAA,QACF,mBAAmB,aAAa,OAAO,qBAAqB,MAAM,MAAM;AAAA,MAAA;AAAA,IAE5E;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,aACP,OACA,KACA,cACG;AACH,SAAQ,MAAM,GAAG,KAAK,MAAM,KAAK,KAAK,KAAK;AAC7C;;;;;"}

@@ -1,53 +0,61 @@

import { inject as u, getCurrentInstance as i } from "vue";
function _() {
let e = window.__currentNode;
return e || (e = Symbol("__currentNode"), window.__currentNode = e), e;
import { inject, getCurrentInstance } from "vue";
function getCurrentNodeKey() {
let key = window.__currentNode;
if (!key) {
key = Symbol("__currentNode");
window.__currentNode = key;
}
return key;
}
function l() {
const e = _();
return u(
e,
() => ({
mode: "live",
node: null,
isDesignerEnv: !1
}),
!0
function useCurrentNode() {
const key = getCurrentNodeKey();
return inject(
key,
() => {
return {
mode: "live",
node: null,
isDesignerEnv: false
};
},
true
);
}
function c() {
let e = window.__rendererContext;
return e || (e = Symbol("__rendererContext"), window.__rendererContext = e), e;
function getRendererContextKey() {
let key = window.__rendererContext;
if (!key) {
key = Symbol("__rendererContext");
window.__rendererContext = key;
}
return key;
}
function p() {
const e = c();
return u(
e,
function useRendererContext() {
const key = getRendererContextKey();
return inject(
key,
() => {
var n, o;
const r = (o = (n = i()) == null ? void 0 : n.props) != null ? o : {};
var _a, _b;
const props = (_b = (_a = getCurrentInstance()) == null ? void 0 : _a.props) != null ? _b : {};
return {
rerender: () => {
},
thisRequiredInJSE: !0,
components: t(r, "components", {}),
designMode: t(r, "designMode", "live"),
getNode: t(r, "getNode", () => null),
wrapLeafComp: (s, g, d) => d,
triggerCompGetCtx: t(r, "triggerCompGetCtx", () => {
})
rerender: () => void 0,
thisRequiredInJSE: true,
components: getPropValue(props, "components", {}),
designMode: getPropValue(props, "designMode", "live"),
getNode: getPropValue(props, "getNode", () => null),
wrapLeafComp: (_, __, leaf) => leaf,
triggerCompGetCtx: getPropValue(props, "triggerCompGetCtx", () => void 0)
};
},
!0
true
);
}
function t(e, r, n) {
return e[r] || e[`__${r}`] || n;
function getPropValue(props, key, defaultValue) {
return props[key] || props[`__${key}`] || defaultValue;
}
export {
_ as getCurrentNodeKey,
c as getRendererContextKey,
l as useCurrentNode,
p as useRendererContext
getCurrentNodeKey,
getRendererContextKey,
useCurrentNode,
useRendererContext
};
//# sourceMappingURL=lowcode-hooks.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"file":"lowcode-hooks.mjs","sources":["../src/current-node.ts","../src/renderer-context.ts"],"sourcesContent":["import type {\n GlobalEvent,\n IPublicModelNode,\n IPublicTypeDisposable,\n} from '@alilc/lowcode-types';\nimport type { InjectionKey } from 'vue';\nimport type { DesignMode } from './renderer-context';\nimport { inject } from 'vue';\n\nexport type IPublicTypePropChangeOptions = Omit<\n GlobalEvent.Node.Prop.ChangeOptions,\n 'node'\n>;\n\nexport interface INode extends IPublicModelNode {\n onVisibleChange(func: (flag: boolean) => any): () => void;\n onPropChange(func: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable;\n onChildrenChange(\n fn: (param?: { type: string; node: INode } | undefined) => void\n ): IPublicTypeDisposable | undefined;\n}\n\nexport interface EnvNode {\n mode: DesignMode;\n node: INode | null;\n isDesignerEnv: boolean;\n}\n\nexport interface DesignerEnvNode extends EnvNode {\n mode: 'design';\n node: INode;\n isDesignerEnv: true;\n}\n\nexport interface LiveEnvNode extends EnvNode {\n mode: 'live';\n node: null;\n isDesignerEnv: false;\n}\n\nexport type CurrentNode = DesignerEnvNode | LiveEnvNode;\n\nexport function getCurrentNodeKey(): InjectionKey<CurrentNode> {\n let key = (window as any).__currentNode;\n if (!key) {\n key = Symbol('__currentNode');\n (window as any).__currentNode = key;\n }\n return key;\n}\n\nexport function useCurrentNode(): CurrentNode {\n const key = getCurrentNodeKey();\n return inject(\n key,\n () => {\n return {\n mode: 'live',\n node: null,\n isDesignerEnv: false,\n } as LiveEnvNode;\n },\n true\n );\n}\n","import type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';\nimport type { Component, ComponentPublicInstance, InjectionKey } from 'vue';\nimport type { INode } from './current-node';\nimport { inject, getCurrentInstance } from 'vue';\n\nexport type DesignMode = 'live' | 'design';\n\nexport interface RendererContext {\n readonly components: Record<string, Component<any, any, any>>;\n readonly designMode: DesignMode;\n readonly thisRequiredInJSE: boolean;\n getNode(id: string): INode | null;\n rerender(): void;\n wrapLeafComp<C extends object, L extends object>(name: string, comp: C, leaf: L): L;\n triggerCompGetCtx(schema: IPublicTypeNodeSchema, val: ComponentPublicInstance): void;\n}\n\nexport function getRendererContextKey(): InjectionKey<RendererContext> {\n let key = (window as any).__rendererContext;\n if (!key) {\n key = Symbol('__rendererContext');\n (window as any).__rendererContext = key;\n }\n return key;\n}\n\nexport function useRendererContext(): RendererContext {\n const key = getRendererContextKey();\n return inject(\n key,\n () => {\n const props = getCurrentInstance()?.props ?? {};\n return {\n rerender: () => void 0,\n thisRequiredInJSE: true,\n components: getPropValue(props, 'components', {}),\n designMode: getPropValue<DesignMode>(props, 'designMode', 'live'),\n getNode: getPropValue(props, 'getNode', () => null),\n wrapLeafComp: <T extends object, L extends object>(_: string, __: T, leaf: L) =>\n leaf,\n triggerCompGetCtx: getPropValue(props, 'triggerCompGetCtx', () => void 0),\n };\n },\n true\n );\n}\n\nfunction getPropValue<T>(\n props: Record<string, unknown>,\n key: string,\n defaultValue: T\n): T {\n return (props[key] || props[`__${key}`] || defaultValue) as T;\n}\n"],"names":["getCurrentNodeKey","key","useCurrentNode","inject","getRendererContextKey","useRendererContext","props","_b","_a","getCurrentInstance","getPropValue","_","__","leaf","defaultValue"],"mappings":";AA0CO,SAASA,IAA+C;AAC7D,MAAIC,IAAO,OAAe;AAC1B,SAAKA,MACHA,IAAM,OAAO,eAAe,GAC3B,OAAe,gBAAgBA,IAE3BA;AACT;AAEO,SAASC,IAA8B;AAC5C,QAAMD,IAAMD;AACL,SAAAG;AAAA,IACLF;AAAA,IACA,OACS;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,eAAe;AAAA,IAAA;AAAA,IAGnB;AAAA,EAAA;AAEJ;AC/CO,SAASG,IAAuD;AACrE,MAAIH,IAAO,OAAe;AAC1B,SAAKA,MACHA,IAAM,OAAO,mBAAmB,GAC/B,OAAe,oBAAoBA,IAE/BA;AACT;AAEO,SAASI,IAAsC;AACpD,QAAMJ,IAAMG;AACL,SAAAD;AAAA,IACLF;AAAA,IACA,MAAM;;AACJ,YAAMK,KAAQC,KAAAC,IAAAC,QAAA,gBAAAD,EAAsB,UAAtB,OAAAD,IAA+B,CAAA;AACtC,aAAA;AAAA,QACL,UAAU,MAAM;AAAA;AAAA,QAChB,mBAAmB;AAAA,QACnB,YAAYG,EAAaJ,GAAO,cAAc,CAAA,CAAE;AAAA,QAChD,YAAYI,EAAyBJ,GAAO,cAAc,MAAM;AAAA,QAChE,SAASI,EAAaJ,GAAO,WAAW,MAAM,IAAI;AAAA,QAClD,cAAc,CAAqCK,GAAWC,GAAOC,MACnEA;AAAA,QACF,mBAAmBH,EAAaJ,GAAO,qBAAqB,MAAA;AAAA,SAAY;AAAA,MAAA;AAAA,IAE5E;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAASI,EACPJ,GACAL,GACAa,GACG;AACH,SAAQR,EAAML,CAAG,KAAKK,EAAM,KAAKL,GAAK,KAAKa;AAC7C;"}
{"version":3,"file":"lowcode-hooks.mjs","sources":["../src/current-node.ts","../src/renderer-context.ts"],"sourcesContent":["import type {\n GlobalEvent,\n IPublicModelNode,\n IPublicTypeDisposable,\n} from '@alilc/lowcode-types';\nimport type { InjectionKey } from 'vue';\nimport type { DesignMode } from './renderer-context';\nimport { inject } from 'vue';\n\nexport type IPublicTypePropChangeOptions = Omit<\n GlobalEvent.Node.Prop.ChangeOptions,\n 'node'\n>;\n\nexport interface INode extends IPublicModelNode {\n onVisibleChange(func: (flag: boolean) => any): () => void;\n onPropChange(func: (info: IPublicTypePropChangeOptions) => void): IPublicTypeDisposable;\n onChildrenChange(\n fn: (param?: { type: string; node: INode } | undefined) => void\n ): IPublicTypeDisposable | undefined;\n}\n\nexport interface EnvNode {\n mode: DesignMode;\n node: INode | null;\n isDesignerEnv: boolean;\n}\n\nexport interface DesignerEnvNode extends EnvNode {\n mode: 'design';\n node: INode;\n isDesignerEnv: true;\n}\n\nexport interface LiveEnvNode extends EnvNode {\n mode: 'live';\n node: null;\n isDesignerEnv: false;\n}\n\nexport type CurrentNode = DesignerEnvNode | LiveEnvNode;\n\nexport function getCurrentNodeKey(): InjectionKey<CurrentNode> {\n let key = (window as any).__currentNode;\n if (!key) {\n key = Symbol('__currentNode');\n (window as any).__currentNode = key;\n }\n return key;\n}\n\nexport function useCurrentNode(): CurrentNode {\n const key = getCurrentNodeKey();\n return inject(\n key,\n () => {\n return {\n mode: 'live',\n node: null,\n isDesignerEnv: false,\n } as LiveEnvNode;\n },\n true\n );\n}\n","import type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';\nimport type { Component, ComponentPublicInstance, InjectionKey } from 'vue';\nimport type { INode } from './current-node';\nimport { inject, getCurrentInstance } from 'vue';\n\nexport type DesignMode = 'live' | 'design';\n\nexport interface RendererContext {\n readonly components: Record<string, Component<any, any, any>>;\n readonly designMode: DesignMode;\n readonly thisRequiredInJSE: boolean;\n getNode(id: string): INode | null;\n rerender(): void;\n wrapLeafComp<C extends object, L extends object>(name: string, comp: C, leaf: L): L;\n triggerCompGetCtx(schema: IPublicTypeNodeSchema, val: ComponentPublicInstance): void;\n}\n\nexport function getRendererContextKey(): InjectionKey<RendererContext> {\n let key = (window as any).__rendererContext;\n if (!key) {\n key = Symbol('__rendererContext');\n (window as any).__rendererContext = key;\n }\n return key;\n}\n\nexport function useRendererContext(): RendererContext {\n const key = getRendererContextKey();\n return inject(\n key,\n () => {\n const props = getCurrentInstance()?.props ?? {};\n return {\n rerender: () => void 0,\n thisRequiredInJSE: true,\n components: getPropValue(props, 'components', {}),\n designMode: getPropValue<DesignMode>(props, 'designMode', 'live'),\n getNode: getPropValue(props, 'getNode', () => null),\n wrapLeafComp: <T extends object, L extends object>(_: string, __: T, leaf: L) =>\n leaf,\n triggerCompGetCtx: getPropValue(props, 'triggerCompGetCtx', () => void 0),\n };\n },\n true\n );\n}\n\nfunction getPropValue<T>(\n props: Record<string, unknown>,\n key: string,\n defaultValue: T\n): T {\n return (props[key] || props[`__${key}`] || defaultValue) as T;\n}\n"],"names":[],"mappings":";AA0CO,SAAS,oBAA+C;AAC7D,MAAI,MAAO,OAAe;AAC1B,MAAI,CAAC,KAAK;AACR,UAAM,OAAO,eAAe;AAC3B,WAAe,gBAAgB;AAAA,EAClC;AACO,SAAA;AACT;AAEO,SAAS,iBAA8B;AAC5C,QAAM,MAAM;AACL,SAAA;AAAA,IACL;AAAA,IACA,MAAM;AACG,aAAA;AAAA,QACL,MAAM;AAAA,QACN,MAAM;AAAA,QACN,eAAe;AAAA,MAAA;AAAA,IAEnB;AAAA,IACA;AAAA,EAAA;AAEJ;AC/CO,SAAS,wBAAuD;AACrE,MAAI,MAAO,OAAe;AAC1B,MAAI,CAAC,KAAK;AACR,UAAM,OAAO,mBAAmB;AAC/B,WAAe,oBAAoB;AAAA,EACtC;AACO,SAAA;AACT;AAEO,SAAS,qBAAsC;AACpD,QAAM,MAAM;AACL,SAAA;AAAA,IACL;AAAA,IACA,MAAM;;AACJ,YAAM,SAAQ,oCAAA,mBAAsB,UAAtB,YAA+B,CAAA;AACtC,aAAA;AAAA,QACL,UAAU,MAAM;AAAA,QAChB,mBAAmB;AAAA,QACnB,YAAY,aAAa,OAAO,cAAc,CAAA,CAAE;AAAA,QAChD,YAAY,aAAyB,OAAO,cAAc,MAAM;AAAA,QAChE,SAAS,aAAa,OAAO,WAAW,MAAM,IAAI;AAAA,QAClD,cAAc,CAAqC,GAAW,IAAO,SACnE;AAAA,QACF,mBAAmB,aAAa,OAAO,qBAAqB,MAAM,MAAM;AAAA,MAAA;AAAA,IAE5E;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,aACP,OACA,KACA,cACG;AACH,SAAQ,MAAM,GAAG,KAAK,MAAM,KAAK,KAAK,KAAK;AAC7C;"}
{
"name": "@knxcloud/lowcode-hooks",
"version": "1.6.0-beta.5",
"version": "1.6.0-beta.6",
"main": "dist/lowcode-hooks.js",

@@ -5,0 +5,0 @@ "module": "dist/lowcode-hooks.mjs",