From 69f3cb2f12d8b2e18ac957caa5f655024cbc8577 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 2 Aug 2024 14:07:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(vue-runtime-help):=20=E5=8F=AA=E6=9C=89dsl?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=BB=84=E4=BB=B6=E6=89=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9Fhook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 68 ++++---------------------- runtime/vue-runtime-help/package.json | 12 ++--- runtime/vue-runtime-help/src/useApp.ts | 12 ++--- 3 files changed, 22 insertions(+), 70 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 993fc848f..a30ed8d20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -955,20 +955,20 @@ importers: runtime/vue-runtime-help: dependencies: '@tmagic/core': - specifier: '>=1.4.8' - version: 1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) + specifier: '>=1.4.16' + version: 1.4.16(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) '@tmagic/data-source': - specifier: '>=1.4.8' - version: 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) + specifier: '>=1.4.16' + version: 1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) '@tmagic/schema': - specifier: '>=1.4.8' - version: 1.4.15(typescript@5.5.4) + specifier: '>=1.4.16' + version: 1.4.16(typescript@5.5.4) '@tmagic/stage': - specifier: '>=1.4.8' - version: 1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4) + specifier: '>=1.4.16' + version: 1.4.16(@tmagic/core@1.4.16(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.16(typescript@5.5.4))(@tmagic/utils@1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4) '@tmagic/utils': - specifier: '>=1.4.8' - version: 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4) + specifier: '>=1.4.16' + version: 1.4.16(@tmagic/schema@1.4.16(typescript@5.5.4))(typescript@5.5.4) '@vue/composition-api': specifier: '>=1.7.2' version: 1.7.2(vue@3.4.35(typescript@5.5.4)) @@ -2356,17 +2356,6 @@ packages: typescript: optional: true - '@tmagic/data-source@1.4.15': - resolution: {integrity: sha512-Ua6jawvo0Lb41MmsWQ8Ockyq1p7gWZMZWzFPFqWOIAlp8llgiH2LMYXz8OkAEkXZOeRtGzHqcd/5zg5qF9HtXA==} - engines: {node: '>=18'} - peerDependencies: - '@tmagic/schema': 1.4.15 - '@tmagic/utils': 1.4.15 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - '@tmagic/data-source@1.4.16': resolution: {integrity: sha512-gYUARAJ5IpJzh2R9nTsvpISTJk8uiEwGwiRfpErgD2OzX9a2uEKvDaFK3GWTUtg8LLlw+UUC/vIt3Qk/89aEGg==} engines: {node: '>=18'} @@ -7507,16 +7496,6 @@ snapshots: optionalDependencies: typescript: 5.5.4 - '@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)': - dependencies: - '@tmagic/data-source': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) - '@tmagic/schema': 1.4.15(typescript@5.5.4) - '@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4) - events: 3.3.0 - lodash-es: 4.17.21 - optionalDependencies: - typescript: 5.5.4 - '@tmagic/core@1.4.15(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)': dependencies: '@tmagic/data-source': 1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) @@ -7537,17 +7516,6 @@ snapshots: optionalDependencies: typescript: 5.5.4 - '@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)': - dependencies: - '@tmagic/dep': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) - '@tmagic/schema': 1.4.15(typescript@5.5.4) - '@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4) - deep-state-observer: 5.5.13 - events: 3.3.0 - lodash-es: 4.17.21 - optionalDependencies: - typescript: 5.5.4 - '@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4)': dependencies: '@tmagic/dep': 1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) @@ -7704,22 +7672,6 @@ snapshots: optionalDependencies: typescript: 5.5.4 - '@tmagic/stage@1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)': - dependencies: - '@scena/guides': 0.29.2 - '@tmagic/core': 1.4.15(@tmagic/data-source@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4) - '@tmagic/schema': 1.4.15(typescript@5.5.4) - '@tmagic/utils': 1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4) - events: 3.3.0 - keycon: 1.4.0 - lodash-es: 4.17.21 - moveable: 0.53.0 - moveable-helper: 0.4.0(scenejs@1.10.3) - optionalDependencies: - typescript: 5.5.4 - transitivePeerDependencies: - - scenejs - '@tmagic/stage@1.4.15(@tmagic/core@1.4.15(@tmagic/data-source@1.4.16(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(typescript@5.5.4))(@tmagic/schema@1.4.15(typescript@5.5.4))(@tmagic/utils@1.4.15(@tmagic/schema@1.4.15(typescript@5.5.4))(typescript@5.5.4))(scenejs@1.10.3)(typescript@5.5.4)': dependencies: '@scena/guides': 0.29.2 diff --git a/runtime/vue-runtime-help/package.json b/runtime/vue-runtime-help/package.json index 65a55b421..a293a4679 100644 --- a/runtime/vue-runtime-help/package.json +++ b/runtime/vue-runtime-help/package.json @@ -1,5 +1,5 @@ { - "version": "0.0.7", + "version": "0.1.0", "name": "@tmagic/vue-runtime-help", "type": "module", "sideEffects": false, @@ -32,11 +32,11 @@ "vue-demi": "^0.14.7" }, "peerDependencies": { - "@tmagic/core": ">=1.4.8", - "@tmagic/data-source": ">=1.4.8", - "@tmagic/schema": ">=1.4.8", - "@tmagic/stage": ">=1.4.8", - "@tmagic/utils": ">=1.4.8", + "@tmagic/core": ">=1.4.16", + "@tmagic/data-source": ">=1.4.16", + "@tmagic/schema": ">=1.4.16", + "@tmagic/stage": ">=1.4.16", + "@tmagic/utils": ">=1.4.16", "@vue/composition-api": ">=1.7.2", "typescript": "*", "vue": ">=2.0.0 || >=3.0.0" diff --git a/runtime/vue-runtime-help/src/useApp.ts b/runtime/vue-runtime-help/src/useApp.ts index 985b45956..859ce346c 100644 --- a/runtime/vue-runtime-help/src/useApp.ts +++ b/runtime/vue-runtime-help/src/useApp.ts @@ -16,10 +16,11 @@ * limitations under the License. */ -import { computed, inject, onBeforeUnmount, onMounted } from 'vue-demi'; +import { inject, onBeforeUnmount, onMounted } from 'vue-demi'; import type Core from '@tmagic/core'; import type { MNode } from '@tmagic/schema'; +import { IS_DSL_NODE_KEY } from '@tmagic/utils'; interface UseAppOptions { config: T; @@ -28,13 +29,11 @@ interface UseAppOptions { }; } +const isDslNode = (config: MNode) => typeof config[IS_DSL_NODE_KEY] === 'undefined' || config[IS_DSL_NODE_KEY] === true; + export default ({ methods, config }: UseAppOptions) => { const app: Core | undefined = inject('app'); - const node = app?.page?.getNode(config.id || ''); - - const style = computed(() => (app ? app.transformStyle(config.style || {}) : config.style)); - const emitData = { config, ...methods, @@ -53,6 +52,8 @@ export default ({ methods, config }: UseAppOptions) => { return displayCfg !== false; }; + const node = isDslNode(config) ? app?.page?.getNode(config.id || '') : undefined; + if (node) { node.emit('created', emitData); @@ -68,7 +69,6 @@ export default ({ methods, config }: UseAppOptions) => { return { app, node, - style, display, };