Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
chore(Connector): improve comments and improved types
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbinBaauw committed Jun 24, 2020
1 parent eebd2ec commit c9a2784
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { nodeOps } from "./nodeOps";
import { patchProp } from "./patchProp";
import { VugelStage } from "../wrapper";

export type VugelRender = RootRenderFunction;

export function createRendererForStage(stage: VugelStage): VugelRender {
export function createRendererForStage(stage: VugelStage): RootRenderFunction {
const { render } = createRenderer({
patchProp,
...nodeOps(stage),
});

return render as VugelRender;
return render;
}

export * from "./nodes";
25 changes: 17 additions & 8 deletions src/wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { createRendererForStage, VugelRender } from "./runtime";
import { defineComponent, Fragment, watchEffect, h, onMounted, Ref, ref, getCurrentInstance } from "@vue/runtime-core";
import { createRendererForStage } from "./runtime";
import {
defineComponent,
Fragment,
watchEffect,
h,
onMounted,
Ref,
ref,
getCurrentInstance,
RootRenderFunction,
} from "@vue/runtime-core";
import { Stage } from "tree2d";
import { EventHelpers, setupEvents } from "./events";
import { Root } from "./runtime/nodes/Root";
Expand All @@ -21,7 +31,7 @@ export const Vugel = defineComponent({

onMounted(() => {
let rendered = false;
let vugelRenderer: VugelRender;
let vugelRenderer: RootRenderFunction;
let stage: VugelStage;
let stageRoot: Root;

Expand Down Expand Up @@ -56,11 +66,11 @@ export const Vugel = defineComponent({
});

/**
* Since vugel uses its own renderer, the ancestor vue's appContext, root and provides would
* normally be lost in the slot-specified vugel component.
* Since vugel uses its own renderer, the ancestor vue's appContext, root and provides would normally be lost in
* the vugel components.
*
* By overriding the component's parent before rendering the slot contents, we can make sure that
* these features will propagate into the user-specified vugel component.
* We can fix this by overriding the component's parent, root, appContext and provides before rendering the slot
* contents.
*/
const Connector = defineComponent({
setup(props, setupContext) {
Expand All @@ -77,7 +87,6 @@ export const Vugel = defineComponent({
},
});


// We need to use a wrapper for flexible size layouting to work with tree2d pixelRatio canvas auto-resizing.
return () =>
h(
Expand Down

0 comments on commit c9a2784

Please sign in to comment.