@textbus/adapter-viewfly 5.2.2 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,120 +1,171 @@
1
- import { makeError as R, VElement as w, VTextNode as V, merge as A, Adapter as y } from "@textbus/core";
2
- import { jsx as f, createDynamicRef as m, getCurrentInstance as C, onUnmounted as x, onUpdated as p, ReflectiveInjector as g } from "@viewfly/core";
3
- import { DomAdapter as u } from "@textbus/platform-browser";
4
- import { NodeViewAdapter as E } from "@textbus/platform-node";
5
- const h = R("ViewflyDOMRenderer");
6
- class d extends u {
1
+ import { makeError, VElement, VTextNode, merge, Adapter } from "@textbus/core";
2
+ import { jsx, createDynamicRef, getCurrentInstance, onUnmounted, onUpdated, ReflectiveInjector } from "@viewfly/core";
3
+ import { DomAdapter } from "@textbus/platform-browser";
4
+ import { NodeViewAdapter } from "@textbus/platform-node";
5
+ const adapterError = makeError("ViewflyDOMRenderer");
6
+ class ViewflyAdapter extends DomAdapter {
7
7
  components = {};
8
8
  componentRefs = /* @__PURE__ */ new WeakMap();
9
- constructor(c, a) {
9
+ constructor(components, mount) {
10
10
  super({
11
- createCompositionNode(e, r) {
12
- const t = m((n) => (r(n), () => {
13
- r(null);
14
- }));
15
- return new w("span", {
11
+ createCompositionNode(compositionState, updateNativeCompositionNode) {
12
+ const ref = createDynamicRef((node) => {
13
+ updateNativeCompositionNode(node);
14
+ return () => {
15
+ updateNativeCompositionNode(null);
16
+ };
17
+ });
18
+ return new VElement("span", {
16
19
  style: {
17
20
  textDecoration: "underline"
18
21
  },
19
- ref: t
22
+ ref
20
23
  }, [
21
- new V(e.text)
24
+ new VTextNode(compositionState.text)
22
25
  ]);
23
26
  },
24
- getParentNode(e) {
25
- return e.parentNode;
27
+ getParentNode(node) {
28
+ return node.parentNode;
26
29
  },
27
- getChildNodes(e) {
28
- return Array.from(e.childNodes);
30
+ getChildNodes(parentElement) {
31
+ return Array.from(parentElement.childNodes);
29
32
  },
30
- isNativeElementNode(e) {
31
- return e instanceof Element;
33
+ isNativeElementNode(node) {
34
+ return node instanceof Element;
32
35
  },
33
- getChildByIndex(e, r) {
34
- return e.childNodes[r];
36
+ getChildByIndex(parentElement, index) {
37
+ return parentElement.childNodes[index];
35
38
  },
36
- getAndUpdateSlotRootNativeElement(e, r) {
37
- const t = e.attrs.get("ref"), n = m((o) => (r(o), () => {
38
- r(null);
39
- }));
40
- typeof t == "function" ? e.attrs.set("ref", [t, n]) : Array.isArray(t) ? t.push(n) : e.attrs.set("ref", n);
39
+ getAndUpdateSlotRootNativeElement(vEle, update) {
40
+ const currentRef = vEle.attrs.get("ref");
41
+ const ref = createDynamicRef((nativeNode) => {
42
+ update(nativeNode);
43
+ return () => {
44
+ update(null);
45
+ };
46
+ });
47
+ if (typeof currentRef === "function") {
48
+ vEle.attrs.set("ref", [currentRef, ref]);
49
+ } else if (Array.isArray(currentRef)) {
50
+ currentRef.push(ref);
51
+ } else {
52
+ vEle.attrs.set("ref", ref);
53
+ }
41
54
  },
42
- componentRender: (e) => {
43
- const r = this.components[e.name] || this.components["*"];
44
- if (r) {
45
- let t = this.componentRefs.get(e);
46
- return t || (t = m((n) => (this.componentRootElementCaches.set(e, n), () => {
47
- this.componentRootElementCaches.get(e) === n && this.componentRootElementCaches.remove(e);
48
- })), this.componentRefs.set(e, t)), f(r, {
49
- component: e,
50
- rootRef: t
51
- }, e.id);
55
+ componentRender: (component) => {
56
+ const comp = this.components[component.name] || this.components["*"];
57
+ if (comp) {
58
+ let ref = this.componentRefs.get(component);
59
+ if (!ref) {
60
+ ref = createDynamicRef((rootNode) => {
61
+ this.componentRootElementCaches.set(component, rootNode);
62
+ return () => {
63
+ if (this.componentRootElementCaches.get(component) === rootNode) {
64
+ this.componentRootElementCaches.remove(component);
65
+ }
66
+ };
67
+ });
68
+ this.componentRefs.set(component, ref);
69
+ }
70
+ return jsx(comp, {
71
+ component,
72
+ rootRef: ref
73
+ }, component.id);
52
74
  }
53
- throw h(`cannot found view component \`${e.name}\`!`);
75
+ throw adapterError(`cannot found view component \`${component.name}\`!`);
54
76
  },
55
- vElementToViewElement(e, r) {
56
- let t;
57
- const n = Array.from(e.attrs).reduce((o, s) => {
58
- const l = s[0];
59
- return l === "key" ? (t = s[1], o) : (o[l] = s[1], o);
77
+ vElementToViewElement(vNode, children) {
78
+ let key;
79
+ const props = Array.from(vNode.attrs).reduce((a, b) => {
80
+ const propName = b[0];
81
+ if (propName === "key") {
82
+ key = b[1];
83
+ return a;
84
+ }
85
+ a[propName] = b[1];
86
+ return a;
60
87
  }, {});
61
- return e.classes.size && (n.class = Array.from(e.classes).join(" ")), e.styles && (n.style = Array.from(e.styles).reduce((o, s) => (o[s[0]] = s[1], o), {})), r.length && (n.children = r), f(e.tagName, n, t);
88
+ if (vNode.classes.size) {
89
+ props.class = Array.from(vNode.classes).join(" ");
90
+ }
91
+ if (vNode.styles) {
92
+ props.style = Array.from(vNode.styles).reduce((a, b) => {
93
+ a[b[0]] = b[1];
94
+ return a;
95
+ }, {});
96
+ }
97
+ if (children.length) {
98
+ props.children = children;
99
+ }
100
+ return jsx(vNode.tagName, props, key);
62
101
  }
63
- }, a);
64
- let i = !0;
65
- Object.entries(c).forEach(([e, r]) => {
66
- this.components[e] = (t) => {
67
- const n = C(), o = t.component, s = A(
68
- o.changeMarker.onChange,
69
- o.changeMarker.onForceChange
102
+ }, mount);
103
+ let isRoot = true;
104
+ Object.entries(components).forEach(([key, viewFlyComponent]) => {
105
+ this.components[key] = (props) => {
106
+ const comp = getCurrentInstance();
107
+ const textbusComponent = props.component;
108
+ const subscription = merge(
109
+ textbusComponent.changeMarker.onChange,
110
+ textbusComponent.changeMarker.onForceChange
70
111
  ).subscribe(() => {
71
- o.changeMarker.dirty && n.markAsDirtied();
112
+ if (textbusComponent.changeMarker.dirty) {
113
+ comp.markAsDirtied();
114
+ }
115
+ });
116
+ onUnmounted(() => {
117
+ subscription.unsubscribe();
118
+ });
119
+ if (isRoot) {
120
+ onUpdated(() => {
121
+ this.onViewUpdated.next();
122
+ });
123
+ isRoot = false;
124
+ }
125
+ onUpdated(() => {
126
+ textbusComponent.changeMarker.rendered();
127
+ if (!this.componentRootElementCaches.get(textbusComponent)) {
128
+ throw adapterError(`Component \`${textbusComponent.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
129
+ }
72
130
  });
73
- return x(() => {
74
- s.unsubscribe();
75
- }), i && (p(() => {
76
- this.onViewUpdated.next();
77
- }), i = !1), p(() => {
78
- if (o.changeMarker.rendered(), !this.componentRootElementCaches.get(o))
79
- throw h(`Component \`${o.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
80
- }), r(t);
131
+ return viewFlyComponent(props);
81
132
  };
82
133
  });
83
134
  }
84
- render(c, a) {
85
- const i = new g(a, [{
86
- provide: y,
135
+ render(rootComponent, injector) {
136
+ const childInjector = new ReflectiveInjector(injector, [{
137
+ provide: Adapter,
87
138
  useValue: this
88
139
  }, {
89
- provide: u,
140
+ provide: DomAdapter,
90
141
  useValue: this
91
142
  }, {
92
- provide: d,
143
+ provide: ViewflyAdapter,
93
144
  useValue: this
94
145
  }]);
95
- return super.render(c, i);
146
+ return super.render(rootComponent, childInjector);
96
147
  }
97
148
  copy() {
98
149
  document.execCommand("copy");
99
150
  }
100
151
  }
101
- class v extends E {
102
- render(c, a) {
103
- const i = new g(a, [{
104
- provide: y,
152
+ class ViewflyVDomAdapter extends NodeViewAdapter {
153
+ render(rootComponent, injector) {
154
+ const childInjector = new ReflectiveInjector(injector, [{
155
+ provide: Adapter,
105
156
  useValue: this
106
157
  }, {
107
- provide: u,
158
+ provide: DomAdapter,
108
159
  useValue: this
109
160
  }, {
110
- provide: d,
161
+ provide: ViewflyAdapter,
111
162
  useValue: this
112
163
  }]);
113
- return super.render(c, i);
164
+ return super.render(rootComponent, childInjector);
114
165
  }
115
166
  }
116
167
  export {
117
- d as ViewflyAdapter,
118
- v as ViewflyVDomAdapter
168
+ ViewflyAdapter,
169
+ ViewflyVDomAdapter
119
170
  };
120
171
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","VTextNode","parentElement","index","vEle","update","currentRef","nativeNode","component","comp","rootNode","jsx","vNode","children","key","props","a","b","propName","isRoot","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","onUnmounted","onUpdated","rootComponent","injector","childInjector","ReflectiveInjector","Adapter","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":";;;;AAaA,MAAMA,IAAeC,EAAU,oBAAoB;AAW5C,MAAMC,UAAuBC,EAAqC;AAAA,EAC/D,aAAuC,CAAA;AAAA,E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ewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":[],"mappings":";;;;AAaA,MAAM,eAAe,UAAU,oBAAoB;AAW5C,MAAM,uBAAuB,WAAqC;AAAA,EAC/D,aAAuC,CAAA;AAAA,EAEvC,oCAAoB,QAAA;AAAA,EAE5B,YAAY,YACA,OACV;AACA,UAAM;AAAA,MACJ,sBAAsB,kBACA,6BAA+E;AACnG,cAAM,MAAM,iBAA0B,CAAA,SAAQ;AAC5C,sCAA4B,IAAI;AAChC,iBAAO,MAAM;AACX,wCAA4B,IAAI;AAAA,UAClC;AAAA,QACF,CAAC;AACD,eAAO,IAAI,SAAS,QAAQ;AAAA,UAC1B,OAAO;AAAA,YACL,gBAAgB;AAAA,UAAA;AAAA,UAElB;AAAA,QAAA,GACC;AAAA,UACD,IAAI,UAAU,iBAAiB,IAAI;AAAA,QAAA,CACpC;AAAA,MACH;AAAA,MACA,cAAc,MAAsC;AA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AACd,iBAAK,cAAc,KAAA;AAAA,UACrB,CAAC;AACD,mBAAS;AAAA,QACX;AACA,kBAAU,MAAM;AACd,2BAAiB,aAAa,SAAA;AAC9B,cAAI,CAAC,KAAK,2BAA2B,IAAI,gBAAgB,GAAG;AAE1D,kBAAM,aAAa,eAAe,iBAAiB,IAAI,mGAAmG;AAAA,UAC5J;AAAA,QACF,CAAC;AACD,eAAO,iBAAiB,KAAK;AAAA,MAC/B;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAES,OAAO,eAA0B,UAAyC;AACjF,UAAM,gBAAgB,IAAI,mBAAmB,UAAU,CAAC;AAAA,MACtD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAO,eAAe,aAAa;AAAA,EAClD;AAAA,EAES,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;AC3KO,MAAM,2BAA2B,gBAAgB;AAAA,EAC7C,OAAO,eAA0B,UAAyC;AACjF,UAAM,gBAAgB,IAAI,mBAAmB,UAAU,CAAC;AAAA,MACtD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAO,eAAe,aAAa;AAAA,EAClD;AACF;"}
package/dist/index.js CHANGED
@@ -1,2 +1,171 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@textbus/core"),s=require("@viewfly/core"),m=require("@textbus/platform-browser"),h=require("@textbus/platform-node"),p=a.makeError("ViewflyDOMRenderer");class l extends m.DomAdapter{components={};componentRefs=new WeakMap;constructor(u,d){super({createCompositionNode(e,r){const t=s.createDynamicRef(n=>(r(n),()=>{r(null)}));return new a.VElement("span",{style:{textDecoration:"underline"},ref:t},[new a.VTextNode(e.text)])},getParentNode(e){return e.parentNode},getChildNodes(e){return Array.from(e.childNodes)},isNativeElementNode(e){return e instanceof Element},getChildByIndex(e,r){return e.childNodes[r]},getAndUpdateSlotRootNativeElement(e,r){const t=e.attrs.get("ref"),n=s.createDynamicRef(o=>(r(o),()=>{r(null)}));typeof t=="function"?e.attrs.set("ref",[t,n]):Array.isArray(t)?t.push(n):e.attrs.set("ref",n)},componentRender:e=>{const r=this.components[e.name]||this.components["*"];if(r){let t=this.componentRefs.get(e);return t||(t=s.createDynamicRef(n=>(this.componentRootElementCaches.set(e,n),()=>{this.componentRootElementCaches.get(e)===n&&this.componentRootElementCaches.remove(e)})),this.componentRefs.set(e,t)),s.jsx(r,{component:e,rootRef:t},e.id)}throw p(`cannot found view component \`${e.name}\`!`)},vElementToViewElement(e,r){let t;const n=Array.from(e.attrs).reduce((o,i)=>{const f=i[0];return f==="key"?(t=i[1],o):(o[f]=i[1],o)},{});return e.classes.size&&(n.class=Array.from(e.classes).join(" ")),e.styles&&(n.style=Array.from(e.styles).reduce((o,i)=>(o[i[0]]=i[1],o),{})),r.length&&(n.children=r),s.jsx(e.tagName,n,t)}},d);let c=!0;Object.entries(u).forEach(([e,r])=>{this.components[e]=t=>{const n=s.getCurrentInstance(),o=t.component,i=a.merge(o.changeMarker.onChange,o.changeMarker.onForceChange).subscribe(()=>{o.changeMarker.dirty&&n.markAsDirtied()});return s.onUnmounted(()=>{i.unsubscribe()}),c&&(s.onUpdated(()=>{this.onViewUpdated.next()}),c=!1),s.onUpdated(()=>{if(o.changeMarker.rendered(),!this.componentRootElementCaches.get(o))throw p(`Component \`${o.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)}),r(t)}})}render(u,d){const c=new s.ReflectiveInjector(d,[{provide:a.Adapter,useValue:this},{provide:m.DomAdapter,useValue:this},{provide:l,useValue:this}]);return super.render(u,c)}copy(){document.execCommand("copy")}}class y extends h.NodeViewAdapter{render(u,d){const c=new s.ReflectiveInjector(d,[{provide:a.Adapter,useValue:this},{provide:m.DomAdapter,useValue:this},{provide:l,useValue:this}]);return super.render(u,c)}}exports.ViewflyAdapter=l;exports.ViewflyVDomAdapter=y;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const core = require("@textbus/core");
4
+ const core$1 = require("@viewfly/core");
5
+ const platformBrowser = require("@textbus/platform-browser");
6
+ const platformNode = require("@textbus/platform-node");
7
+ const adapterError = core.makeError("ViewflyDOMRenderer");
8
+ class ViewflyAdapter extends platformBrowser.DomAdapter {
9
+ components = {};
10
+ componentRefs = /* @__PURE__ */ new WeakMap();
11
+ constructor(components, mount) {
12
+ super({
13
+ createCompositionNode(compositionState, updateNativeCompositionNode) {
14
+ const ref = core$1.createDynamicRef((node) => {
15
+ updateNativeCompositionNode(node);
16
+ return () => {
17
+ updateNativeCompositionNode(null);
18
+ };
19
+ });
20
+ return new core.VElement("span", {
21
+ style: {
22
+ textDecoration: "underline"
23
+ },
24
+ ref
25
+ }, [
26
+ new core.VTextNode(compositionState.text)
27
+ ]);
28
+ },
29
+ getParentNode(node) {
30
+ return node.parentNode;
31
+ },
32
+ getChildNodes(parentElement) {
33
+ return Array.from(parentElement.childNodes);
34
+ },
35
+ isNativeElementNode(node) {
36
+ return node instanceof Element;
37
+ },
38
+ getChildByIndex(parentElement, index) {
39
+ return parentElement.childNodes[index];
40
+ },
41
+ getAndUpdateSlotRootNativeElement(vEle, update) {
42
+ const currentRef = vEle.attrs.get("ref");
43
+ const ref = core$1.createDynamicRef((nativeNode) => {
44
+ update(nativeNode);
45
+ return () => {
46
+ update(null);
47
+ };
48
+ });
49
+ if (typeof currentRef === "function") {
50
+ vEle.attrs.set("ref", [currentRef, ref]);
51
+ } else if (Array.isArray(currentRef)) {
52
+ currentRef.push(ref);
53
+ } else {
54
+ vEle.attrs.set("ref", ref);
55
+ }
56
+ },
57
+ componentRender: (component) => {
58
+ const comp = this.components[component.name] || this.components["*"];
59
+ if (comp) {
60
+ let ref = this.componentRefs.get(component);
61
+ if (!ref) {
62
+ ref = core$1.createDynamicRef((rootNode) => {
63
+ this.componentRootElementCaches.set(component, rootNode);
64
+ return () => {
65
+ if (this.componentRootElementCaches.get(component) === rootNode) {
66
+ this.componentRootElementCaches.remove(component);
67
+ }
68
+ };
69
+ });
70
+ this.componentRefs.set(component, ref);
71
+ }
72
+ return core$1.jsx(comp, {
73
+ component,
74
+ rootRef: ref
75
+ }, component.id);
76
+ }
77
+ throw adapterError(`cannot found view component \`${component.name}\`!`);
78
+ },
79
+ vElementToViewElement(vNode, children) {
80
+ let key;
81
+ const props = Array.from(vNode.attrs).reduce((a, b) => {
82
+ const propName = b[0];
83
+ if (propName === "key") {
84
+ key = b[1];
85
+ return a;
86
+ }
87
+ a[propName] = b[1];
88
+ return a;
89
+ }, {});
90
+ if (vNode.classes.size) {
91
+ props.class = Array.from(vNode.classes).join(" ");
92
+ }
93
+ if (vNode.styles) {
94
+ props.style = Array.from(vNode.styles).reduce((a, b) => {
95
+ a[b[0]] = b[1];
96
+ return a;
97
+ }, {});
98
+ }
99
+ if (children.length) {
100
+ props.children = children;
101
+ }
102
+ return core$1.jsx(vNode.tagName, props, key);
103
+ }
104
+ }, mount);
105
+ let isRoot = true;
106
+ Object.entries(components).forEach(([key, viewFlyComponent]) => {
107
+ this.components[key] = (props) => {
108
+ const comp = core$1.getCurrentInstance();
109
+ const textbusComponent = props.component;
110
+ const subscription = core.merge(
111
+ textbusComponent.changeMarker.onChange,
112
+ textbusComponent.changeMarker.onForceChange
113
+ ).subscribe(() => {
114
+ if (textbusComponent.changeMarker.dirty) {
115
+ comp.markAsDirtied();
116
+ }
117
+ });
118
+ core$1.onUnmounted(() => {
119
+ subscription.unsubscribe();
120
+ });
121
+ if (isRoot) {
122
+ core$1.onUpdated(() => {
123
+ this.onViewUpdated.next();
124
+ });
125
+ isRoot = false;
126
+ }
127
+ core$1.onUpdated(() => {
128
+ textbusComponent.changeMarker.rendered();
129
+ if (!this.componentRootElementCaches.get(textbusComponent)) {
130
+ throw adapterError(`Component \`${textbusComponent.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
131
+ }
132
+ });
133
+ return viewFlyComponent(props);
134
+ };
135
+ });
136
+ }
137
+ render(rootComponent, injector) {
138
+ const childInjector = new core$1.ReflectiveInjector(injector, [{
139
+ provide: core.Adapter,
140
+ useValue: this
141
+ }, {
142
+ provide: platformBrowser.DomAdapter,
143
+ useValue: this
144
+ }, {
145
+ provide: ViewflyAdapter,
146
+ useValue: this
147
+ }]);
148
+ return super.render(rootComponent, childInjector);
149
+ }
150
+ copy() {
151
+ document.execCommand("copy");
152
+ }
153
+ }
154
+ class ViewflyVDomAdapter extends platformNode.NodeViewAdapter {
155
+ render(rootComponent, injector) {
156
+ const childInjector = new core$1.ReflectiveInjector(injector, [{
157
+ provide: core.Adapter,
158
+ useValue: this
159
+ }, {
160
+ provide: platformBrowser.DomAdapter,
161
+ useValue: this
162
+ }, {
163
+ provide: ViewflyAdapter,
164
+ useValue: this
165
+ }]);
166
+ return super.render(rootComponent, childInjector);
167
+ }
168
+ }
169
+ exports.ViewflyAdapter = ViewflyAdapter;
170
+ exports.ViewflyVDomAdapter = ViewflyVDomAdapter;
2
171
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","VTextNode","parentElement","index","vEle","update","currentRef","nativeNode","component","comp","rootNode","jsx","vNode","children","key","props","a","b","propName","isRoot","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","onUnmounted","onUpdated","rootComponent","injector","childInjector","ReflectiveInjector","Adapter","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":"uNAaMA,EAAeC,EAAAA,UAAU,oBAAoB,EAW5C,MAAMC,UAAuBC,EAAAA,UAAqC,CAC/D,WAAuC,CAAA,EAEvC,kBAAoB,QAE5B,YAAYC,EACAC,EACV,CACA,MAAM,CACJ,sBAAsBC,EACAC,EAA+E,CACnG,MAAMC,EAAMC,mBAA0BC,IACpCH,EAA4BG,CAAI,EACzB,IAAM,CACXH,EAA4B,IAAI,CAClC,EACD,EACD,OAAO,IAAII,EAAAA,SAAS,OAAQ,CAC1B,MAAO,CACL,eAAgB,WAAA,EAElB,IAAAH,CAAA,EACC,CACD,IAAII,EAAAA,UAAUN,EAAiB,IAAI,CAAA,CACpC,CACH,EACA,cAAcI,EAAsC,CAClD,OAAQA,EAAc,UACxB,EACA,cAAcG,EAA+C,CAC3D,OAAO,MAAM,KAAKA,EAAc,UAAU,CAC5C,EACA,oBAAoBH,EAAuC,CACzD,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oC,EAAeE,CAAa,CAClD,CAES,MAAO,CACd,SAAS,YAAY,MAAM,CAC7B,CACF,CC3KO,MAAMG,UAA2BC,EAAAA,eAAgB,CAC7C,OAAON,EAA0BC,EAAyC,CACjF,MAAMC,EAAgB,IAAIC,qBAAmBF,EAAU,CAAC,CACtD,QAASG,EAAAA,QACT,SAAU,IAAA,EACT,CACD,QAASvC,EAAAA,WACT,SAAU,IAAA,EACT,CACD,QAASD,EACT,SAAU,IAAA,CACX,CAAC,EACF,OAAO,MAAM,OAAOoC,EAAeE,CAAa,CAClD,CACF"}
1
+ {"version":3,"file":"index.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["makeError","DomAdapter","createDynamicRef","VElement","VTextNode","jsx","getCurrentInstance","merge","onUnmounted","onUpdated","ReflectiveInjector","Adapter","NodeViewAdapter"],"mappings":";;;;;;AAaA,MAAM,e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,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;AC3KO,MAAM,2BAA2BW,aAAAA,gBAAgB;AAAA,EAC7C,OAAO,eAA0B,UAAyC;AACjF,UAAM,gBAAgB,IAAIF,0BAAmB,UAAU,CAAC;AAAA,MACtD,SAASC,KAAAA;AAAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASV,gBAAAA;AAAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAO,eAAe,aAAa;AAAA,EAClD;AACF;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/adapter-viewfly",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -33,11 +33,11 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@tanbo/stream": "^1.2.7",
36
- "@viewfly/core": "^2.2.0 || >=3.0.0-alpha.0 <4",
37
- "@viewfly/platform-browser": "^2.2.0 || >=3.0.0-alpha.0 <4",
38
- "@textbus/platform-browser": "^5.2.2",
39
- "@textbus/core": "^5.2.2",
40
- "@textbus/platform-node": "^5.2.2"
36
+ "@viewfly/core": "^2.2.0 || >=3.0.0-alpha.3 <4",
37
+ "@viewfly/platform-browser": "^2.2.0 || >=3.0.0-alpha.3 <4",
38
+ "@textbus/core": "^5.2.3",
39
+ "@textbus/platform-node": "^5.2.3",
40
+ "@textbus/platform-browser": "^5.2.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "rimraf": "^3.0.2",