Skip to content

Commit 5d02fda

Browse files
author
knight.chen
committed
fix: 优化类型声明以支持 Vite
1 parent d517bb5 commit 5d02fda

File tree

24 files changed

+219
-225
lines changed

24 files changed

+219
-225
lines changed

packages/hooks/src/current-node.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Node } from '@alilc/lowcode-designer';
2-
import { NodeSchema } from '@alilc/lowcode-types';
3-
import { inject, InjectionKey } from 'vue';
4-
import { DesignMode } from './renderer-context';
1+
import type { Node } from '@alilc/lowcode-designer';
2+
import type { InjectionKey } from 'vue';
3+
import type { NodeSchema } from '@alilc/lowcode-types';
4+
import type { DesignMode } from './renderer-context';
5+
import { inject } from 'vue';
56

67
export interface EnvNode {
78
mode: DesignMode;

packages/hooks/src/renderer-context.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import {
2-
Component,
3-
ComponentPublicInstance,
4-
InjectionKey,
5-
inject,
6-
getCurrentInstance,
7-
} from 'vue';
8-
import { Node } from '@alilc/lowcode-designer';
9-
import { NodeSchema } from '@alilc/lowcode-types';
1+
import type { Component, ComponentPublicInstance, InjectionKey } from 'vue';
2+
import type { Node } from '@alilc/lowcode-designer';
3+
import type { NodeSchema } from '@alilc/lowcode-types';
4+
import { inject, getCurrentInstance } from 'vue';
105

116
export type DesignMode = 'live' | 'design';
127

packages/utils/src/asset.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
/**
22
* copy from https://github.com/alibaba/lowcode-engine/blob/main/packages/utils/src/asset.ts
33
*/
4-
5-
import {
6-
Asset,
7-
AssetBundle,
8-
AssetItem,
9-
AssetLevel,
10-
AssetLevels,
11-
AssetList,
12-
AssetType,
13-
} from '@alilc/lowcode-types';
4+
import type { Asset, AssetBundle, AssetItem, AssetList } from '@alilc/lowcode-types';
5+
import { AssetLevel, AssetLevels, AssetType } from '@alilc/lowcode-types';
146
import { isCSSUrl } from './check';
157
import { createDefer } from './create-defer';
168
import { evaluate, load } from './script';

packages/utils/src/build-components.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Component, defineComponent, h } from 'vue';
2-
import { isESModule, isFunction, isObject } from './check';
1+
import type { Component } from 'vue';
32
import type { ComponentSchema, NpmInfo } from '@alilc/lowcode-types';
3+
import { defineComponent, h } from 'vue';
4+
import { isESModule, isFunction, isObject } from './check';
45

56
export function isVueComponent(val: unknown): val is Component {
67
if (isFunction(val)) return true;

packages/utils/src/build-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { isJSFunction, JSFunction, NpmInfo } from '@alilc/lowcode-types';
1+
import type { JSFunction, NpmInfo } from '@alilc/lowcode-types';
2+
import { isJSFunction } from '@alilc/lowcode-types';
23
import { accessLibrary } from './build-components';
34

45
export interface UtilsNpmMetadata {

packages/vue-renderer/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RendererComponent } from './core';
1+
import type { RendererComponent } from './core';
22
import { RENDERER_COMPS } from './renderers';
33

44
export type RendererModules = Record<string, RendererComponent>;

packages/vue-renderer/src/core/base.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { NodeSchema, RootSchema } from '@alilc/lowcode-types';
2-
import { Node } from '@alilc/lowcode-designer';
3-
import { Component, ComponentPublicInstance, PropType, VNodeProps } from 'vue';
4-
import { BlockScope, I18nMessages, RuntimeScope } from '../utils';
1+
import type { NodeSchema, RootSchema } from '@alilc/lowcode-types';
2+
import type { Node } from '@alilc/lowcode-designer';
3+
import type { Component, ComponentPublicInstance, PropType, VNodeProps } from 'vue';
4+
import type { BlockScope, I18nMessages, RuntimeScope } from '../utils';
55

66
export const rendererProps = {
77
__scope: {

packages/vue-renderer/src/core/hoc.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1+
import type { SlotNode } from '@alilc/lowcode-designer';
2+
import type { ComponentPublicInstance } from 'vue';
3+
import type { PropSchemaMap, SlotSchemaMap } from './use';
14
import { isNil } from 'lodash-es';
25
import { isJSSlot, TransformStage } from '@alilc/lowcode-types';
3-
import { SlotNode } from '@alilc/lowcode-designer';
4-
import {
5-
ComponentPublicInstance,
6-
h,
7-
Fragment,
8-
reactive,
9-
onUnmounted,
10-
defineComponent,
11-
} from 'vue';
6+
import { h, Fragment, reactive, onUnmounted, defineComponent } from 'vue';
127
import { leafProps } from './base';
138
import { useRendererContext } from '@knxcloud/lowcode-hooks';
149
import { ensureArray } from '../utils';
15-
import { PropSchemaMap, SlotSchemaMap, useLeaf } from './use';
10+
import { useLeaf } from './use';
1611

1712
export const Hoc = defineComponent({
1813
name: 'Hoc',

packages/vue-renderer/src/core/use.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { Prop } from '@alilc/lowcode-designer';
1+
import type { Prop } from '@alilc/lowcode-designer';
2+
import type { Component, VNode, Ref, ComputedRef, Slot, Slots, InjectionKey } from 'vue';
3+
import type {
4+
NodeData,
5+
SlotSchema,
6+
NodeSchema,
7+
JSFunction,
8+
CompositeValue,
9+
} from '@alilc/lowcode-types';
10+
import type { LeafProps, RendererProps } from './base';
11+
import type { MaybeArray, BlockScope, RuntimeScope } from '../utils';
12+
213
import {
3-
Component,
4-
VNode,
5-
Ref,
6-
ComputedRef,
7-
Slot,
8-
Slots,
914
h,
1015
createTextVNode,
1116
computed,
@@ -24,14 +29,8 @@ import {
2429
toRaw,
2530
toDisplayString,
2631
inject,
27-
InjectionKey,
2832
} from 'vue';
2933
import {
30-
NodeData,
31-
SlotSchema,
32-
NodeSchema,
33-
JSFunction,
34-
CompositeValue,
3534
isJSSlot,
3635
isJSFunction,
3736
isDOMText,
@@ -45,7 +44,6 @@ import {
4544
getRendererContextKey,
4645
useRendererContext,
4746
} from '@knxcloud/lowcode-hooks';
48-
import { LeafProps, RendererProps } from './base';
4947
import { Hoc } from './hoc';
5048
import { Live } from './live';
5149
import {
@@ -58,7 +56,6 @@ import {
5856
parseExpression,
5957
} from '../utils';
6058
import { createDataSourceManager } from '../data-source';
61-
import { MaybeArray, BlockScope, RuntimeScope } from '../utils';
6259

6360
const currentNodeKey = getCurrentNodeKey();
6461

packages/vue-renderer/src/data-source/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { InterpretDataSource, InterpretDataSourceConfig } from '@alilc/lowcode-types';
1+
import type {
2+
InterpretDataSource,
3+
InterpretDataSourceConfig,
4+
} from '@alilc/lowcode-types';
5+
import type { RequestParams } from './interface';
6+
import type { RuntimeScope } from '../utils';
27
import { computed, reactive, ref, shallowRef } from 'vue';
38
import { isBoolean, isFunction, isUndefined } from 'lodash-es';
49
import { request, Response } from './request';
5-
import { DataSourceStatus, RequestParams } from './interface';
6-
import { isPlainObject, parseSchema, RuntimeScope } from '../utils';
10+
import { DataSourceStatus } from './interface';
11+
import { isPlainObject, parseSchema } from '../utils';
712

813
const same = <T>(v: T) => v;
914
const noop = () => void 0;

0 commit comments

Comments
 (0)