@vyr/vue 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,22 +1 @@
1
- {
2
- "name": "@vyr/vue",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "./src/index.ts",
6
- "author": "",
7
- "sideEffects": true,
8
- "license": "MIT",
9
- "dependencies": {
10
- "@vyr/locale": "0.0.1",
11
- "@vyr/engine": "0.0.1",
12
- "vue": "3.5.22"
13
- },
14
- "files": [
15
- "package.json",
16
- "src/"
17
- ],
18
- "vyr": {
19
- "type": "universal",
20
- "order": 10
21
- }
22
- }
1
+ {"name":"@vyr/vue","version":"0.0.2","description":"","main":"./src/index.ts","author":"","sideEffects":true,"license":"MIT","dependencies":{"@vyr/locale":"0.0.2","@vyr/engine":"0.0.2","vue":"3.5.22"},"files":["package.json","src/"],"vyr":{"type":"universal","order":10}}
@@ -1,5 +1,5 @@
1
1
  import { App, createApp, h, markRaw, resolveDynamicComponent, VNode, ComponentPublicInstance } from 'vue'
2
- import { ArrayUtils, Asset, HTMLActor, RoutineDescriptor, RoutineInterpreter, StyleDescriptor, UpdateArgs } from "@vyr/engine"
2
+ import { ArrayUtils, Asset, HTMLActor, InteractionDescriptor, StyleDescriptor } from "@vyr/engine"
3
3
  import { TemplateDescriptor, VueDescriptor } from "../descriptor"
4
4
 
5
5
  interface VyrVueProps {
@@ -52,7 +52,7 @@ class VueActor extends HTMLActor {
52
52
  const graphics = HTMLActor.getGraphics(this)
53
53
  const parent = graphics.getParent(this.uuid)
54
54
  if (parent instanceof VueDescriptor) return null
55
- const descriptor = graphics.variableProxy.get<VueDescriptor>(this.uuid, graphics, { delta: 0 })
55
+ const descriptor = graphics.variableProxy.get<VueDescriptor>(this.uuid, graphics)
56
56
  const vnode = this.createVNode(descriptor)
57
57
  this.raw.app = markRaw(createApp(vnode, { actor: this }))
58
58
  const plugins = VueDescriptor.getPlugins()
@@ -68,9 +68,9 @@ class VueActor extends HTMLActor {
68
68
  }
69
69
  }
70
70
 
71
- update(descriptor: VueDescriptor, args: UpdateArgs) {
72
- this.style = this.getWrapperStyle(descriptor, args)
73
- this.props = this.getProps(descriptor, args)
71
+ update(descriptor: VueDescriptor) {
72
+ this.style = this.getWrapperStyle(descriptor)
73
+ this.props = this.getProps(descriptor)
74
74
  }
75
75
 
76
76
  dispose() {
@@ -91,7 +91,7 @@ class VueActor extends HTMLActor {
91
91
  },
92
92
  render() {
93
93
  const _instance = this as VyrVueInstance
94
- const children = self.getChildren(_instance, { delta: 0 })
94
+ const children = self.getChildren(_instance)
95
95
  const content = _instance.actor.getContent(_instance, children, descriptor)
96
96
 
97
97
  return self.getWrapperVNode(this as any, content, descriptor)
@@ -109,7 +109,7 @@ class VueActor extends HTMLActor {
109
109
  return vnode as unknown as VNode
110
110
  }
111
111
 
112
- getChildren(instance: VyrVueInstance, args: UpdateArgs) {
112
+ getChildren(instance: VyrVueInstance) {
113
113
  const { actor } = instance
114
114
 
115
115
  const _default: VNode[] = []
@@ -123,7 +123,7 @@ class VueActor extends HTMLActor {
123
123
 
124
124
  for (let i = 0; i < actor.children.length; i++) {
125
125
  const attr = { key: i, actor: actor.children[i] }
126
- const descriptor = graphics.variableProxy.get<VueDescriptor>(attr.actor.uuid, graphics, args)
126
+ const descriptor = graphics.variableProxy.get<VueDescriptor>(attr.actor.uuid, graphics)
127
127
  const component = attr.actor.createVNode(descriptor)
128
128
 
129
129
  if (descriptor instanceof TemplateDescriptor) {
@@ -162,22 +162,21 @@ class VueActor extends HTMLActor {
162
162
  return h(component, attrs, children)
163
163
  }
164
164
 
165
- getProps(descriptor: VueDescriptor, args: UpdateArgs) {
165
+ getProps(descriptor: VueDescriptor) {
166
166
  return {}
167
167
  }
168
168
 
169
- getInteractionProps(descriptor: VueDescriptor, instance: VyrVueInstance, args: UpdateArgs) {
169
+ getInteractionProps(descriptor: VueDescriptor, instance: VyrVueInstance) {
170
170
  const interactions: { [k: string]: any } = {}
171
171
  const graphics = HTMLActor.getGraphics(this)
172
172
  //@ts-ignore
173
- const eventArgs = { ...args, trigger: descriptor, VYR_STORE: instance.VYR_STORE }
173
+ const otherArgs = { VYR_STORE: instance.VYR_STORE }
174
174
  for (const interaction of descriptor.interactions) {
175
175
  if (interaction.url) {
176
- const routine = Asset.get<RoutineDescriptor>(interaction.url)
177
- const interpreter = graphics.getInterpreter<RoutineInterpreter>(routine)
176
+ const current = Asset.get<InteractionDescriptor>(interaction.url)
178
177
  const listener = (e: Event) => {
179
178
  if (e instanceof Event) e.stopPropagation()
180
- interpreter.do(interaction.inputs, routine, eventArgs)
179
+ current.execute(interaction.inputs, graphics, descriptor, otherArgs)
181
180
  }
182
181
  const eventKey = 'on' + interaction.type.charAt(0).toUpperCase() + interaction.type.slice(1)
183
182
  interactions[eventKey] = listener
@@ -191,9 +190,9 @@ class VueActor extends HTMLActor {
191
190
  }
192
191
 
193
192
  getComponentAttrs(instance: VyrVueInstance, descriptor: VueDescriptor, ...args: any[]) {
194
- const className = [...this.getStyleClass(descriptor, { delta: 0 })]
193
+ const className = [...this.getStyleClass(descriptor)]
195
194
  if (descriptor.active) className.push(StyleDescriptor.activeName)
196
- const interactions = this.getInteractionProps(descriptor, instance, { delta: 0 })
195
+ const interactions = this.getInteractionProps(descriptor, instance)
197
196
 
198
197
  const attrs = {
199
198
  ...this.props,
@@ -1,10 +1,15 @@
1
1
  import { Plugin } from "vue";
2
- import { DeserializationObject, HTMLDescriptor } from "@vyr/engine";
2
+ import { Descriptor, DeserializationObject, HTMLDescriptor, ScriptableArgs } from "@vyr/engine";
3
3
 
4
4
  const privateState = {
5
5
  plugins: [] as { content: Plugin, args?: any }[],
6
6
  }
7
7
 
8
+ interface VueScriptableArgs<T extends Descriptor = Descriptor> extends ScriptableArgs {
9
+ trigger: T,
10
+ VYR_STORE: any
11
+ }
12
+
8
13
  class VueDescriptor extends HTMLDescriptor {
9
14
  static use(content: Plugin, args?: any) {
10
15
  privateState.plugins.push({ content, args })
@@ -22,4 +27,4 @@ class VueDescriptor extends HTMLDescriptor {
22
27
  }
23
28
  HTMLDescriptor.register(VueDescriptor)
24
29
 
25
- export { VueDescriptor }
30
+ export { VueScriptableArgs, VueDescriptor }
@@ -1,5 +1,4 @@
1
1
  import { reactive } from "vue";
2
- import { UpdateArgs } from "@vyr/engine";
3
2
  import { TemplateDescriptor } from "../descriptor";
4
3
  import { TemplateActor } from "../actor";
5
4
  import { VueInterpreter } from "./VueInterpreter";
@@ -7,7 +6,7 @@ import { VueInterpreter } from "./VueInterpreter";
7
6
  class TemplateInterpreter extends VueInterpreter {
8
7
  static type = TemplateDescriptor.type
9
8
 
10
- protected createActor(descriptor: TemplateDescriptor, args: UpdateArgs) {
9
+ protected createActor(descriptor: TemplateDescriptor) {
11
10
  return reactive(new TemplateActor(descriptor.uuid)) as TemplateActor
12
11
  }
13
12
  }
@@ -1,42 +1,42 @@
1
1
  import { reactive } from 'vue'
2
- import { Descriptor, HTMLActor, Interpreter, PickupObject, UpdateArgs } from '@vyr/engine'
2
+ import { Descriptor, HTMLActor, Interpreter, PickupObject } from '@vyr/engine'
3
3
  import { VueDescriptor } from '../descriptor'
4
4
  import { VueActor } from '../actor'
5
5
 
6
6
  class VueInterpreter extends Interpreter {
7
7
  static type = VueDescriptor.type
8
8
 
9
- protected createActor(descriptor: VueDescriptor, args: UpdateArgs) {
9
+ protected createActor(descriptor: VueDescriptor) {
10
10
  return reactive(new VueActor(descriptor.uuid)) as VueActor
11
11
  }
12
12
 
13
- update(descriptor: VueDescriptor, args: UpdateArgs) {
14
- super.update(descriptor, args)
15
- const actor = this.getActor<VueActor>(descriptor, args)
16
- actor.update(descriptor, args)
13
+ update(descriptor: VueDescriptor) {
14
+ super.update(descriptor)
15
+ const actor = this.getActor<VueActor>(descriptor)
16
+ actor.update(descriptor)
17
17
  }
18
18
 
19
- mount(descriptor: VueDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
21
- const actor = this.getActor<VueActor>(descriptor, args)
22
- const parentActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
19
+ mount(descriptor: VueDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
21
+ const actor = this.getActor<VueActor>(descriptor)
22
+ const parentActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
23
23
  parentActor.add(actor)
24
24
  }
25
25
 
26
- unmount(descriptor: VueDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
27
- const actor = this.getActor<VueActor>(descriptor, args)
28
- const parentActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
26
+ unmount(descriptor: VueDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
27
+ const actor = this.getActor<VueActor>(descriptor)
28
+ const parentActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
29
29
  parentActor.remove(actor)
30
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
30
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
31
31
  }
32
32
 
33
- free(descriptor: VueDescriptor, args: UpdateArgs) {
34
- const actor = this.getActor<VueActor>(descriptor, args)
33
+ free(descriptor: VueDescriptor) {
34
+ const actor = this.getActor<VueActor>(descriptor)
35
35
  actor.dispose()
36
- super.free(descriptor, args)
36
+ super.free(descriptor)
37
37
  }
38
38
 
39
- pickup(descriptor: VueDescriptor, args: UpdateArgs, result: PickupObject[]) {
39
+ pickup(descriptor: VueDescriptor, result: PickupObject[]) {
40
40
  result.push({ uuid: descriptor.uuid, generatedBy: descriptor.generatedBy })
41
41
  }
42
42
  }