@vyr/remote 0.0.1 → 0.0.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/package.json CHANGED
@@ -1,18 +1 @@
1
- {
2
- "name": "@vyr/remote",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "./src/index.ts",
6
- "author": "",
7
- "license": "MIT",
8
- "dependencies": {
9
- "dom-to-image": "^2.6.0",
10
- "@vyr/locale": "0.0.1",
11
- "@vyr/declare": "0.0.1",
12
- "@vyr/engine": "0.0.1"
13
- },
14
- "files": [
15
- "package.json",
16
- "src/"
17
- ]
18
- }
1
+ {"name":"@vyr/remote","version":"0.0.3","description":"","main":"./src/index.ts","author":"","license":"MIT","dependencies":{"dom-to-image":"^2.6.0","@vyr/locale":"0.0.3","@vyr/declare":"0.0.3","@vyr/engine":"0.0.3"},"files":["package.json","src/"]}
@@ -1,10 +1,10 @@
1
- import { Descriptor, Graphics, HTMLTransformControllerChangeArgs, HTMLTransformControllerDescriptor, Scriptable } from "@vyr/engine";
1
+ import { Descriptor, Graphics, HTMLTransformControllerChangeArgs, Scriptable } from "@vyr/engine";
2
2
  import { RemoteProcess } from "./RemoteProcess";
3
3
  import { Job } from "./job";
4
4
 
5
- class ChangeScriptable extends Scriptable {
5
+ class ChangeScriptable extends Scriptable<HTMLTransformControllerChangeArgs> {
6
6
 
7
- execute(descriptor: HTMLTransformControllerDescriptor, graphics: Graphics, args: HTMLTransformControllerChangeArgs) {
7
+ execute(graphics: Graphics, args: HTMLTransformControllerChangeArgs) {
8
8
  const process = RemoteProcess.get(graphics.engine)
9
9
  if (process === null) return
10
10
 
@@ -1,4 +1,4 @@
1
- import { AnimationUnitInterpreter, Asset, Compilation, Descriptor, DeserializationObject, DivDescriptor, DynamicDescriptor, Engine, Graphics, HTMLDescriptor, HTMLServiceDescriptor, HTMLTransformControllerDescriptor, observer, PrefabeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, StyleDescriptor, Unit, UpdateArgs } from '@vyr/engine'
1
+ import { AnimationUnitInterpreter, Asset, Compilation, Descriptor, DeserializationObject, DivDescriptor, DynamicDescriptor, Engine, Graphics, HTMLDescriptor, HTMLServiceDescriptor, HTMLTransformControllerDescriptor, observer, PrefabeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, StyleDescriptor, Unit } from '@vyr/engine'
2
2
  import { cleanPickupObject, getAnimationUnit, createControllerStyle, pickupObject, getAnimationUnitByAsset, screenshot } from './utils'
3
3
  import { Collection } from './Collection'
4
4
  import { RemoteProcess } from './RemoteProcess'
@@ -21,6 +21,7 @@ class RemoteExecutor {
21
21
 
22
22
  this.process.scene = task.params.url
23
23
  await Asset.loadAll(task.params.url)
24
+ await Asset.compileDataset(task.params.url, this.process.engine)
24
25
 
25
26
  //渲染新场景
26
27
  const scheduler = Asset.get<ServiceSchedulerDescriptor>(task.params.url)
@@ -82,6 +83,7 @@ class RemoteExecutor {
82
83
  }
83
84
 
84
85
  await Asset.loadAll(this.process.scene)
86
+ await Asset.compileDataset(this.process.scene, this.process.engine)
85
87
  this.sendAnimationUnitToRemote(0, getAnimationUnit(this.process.scheduler))
86
88
  }
87
89
  async removeyScene(task: InstanceType<typeof Job['scene']['remove']['Task']>) {
@@ -133,6 +135,7 @@ class RemoteExecutor {
133
135
  this.updateOtherUpdateJob(target, task.params.content)
134
136
  target.syncWith(task.params.content)
135
137
  await Asset.loadAll(this.process.scene)
138
+ await Asset.compileDataset(this.process.scene, this.process.engine)
136
139
 
137
140
  this.sendAnimationUnitToRemote(0, getAnimationUnit(this.process.scheduler))
138
141
 
@@ -147,6 +150,7 @@ class RemoteExecutor {
147
150
 
148
151
  this.process.asset = task.params.url
149
152
  await Asset.loadAll(task.params.url)
153
+ await Asset.compileDataset(task.params.url, this.process.engine)
150
154
 
151
155
  const scheduler = new ServiceSchedulerDescriptor()
152
156
  const descriptor = Asset.get<Descriptor>(task.params.url)
@@ -219,6 +223,7 @@ class RemoteExecutor {
219
223
 
220
224
  await Asset.loadAll(task.params.url)
221
225
  Asset.graph.update(this._defaultScheduleUrl)
226
+ await Asset.compileDataset(task.params.url, this.process.engine)
222
227
 
223
228
  this.sendAnimationUnitToRemote(0, getAnimationUnitByAsset(task.params.url))
224
229
  }
@@ -272,6 +277,7 @@ class RemoteExecutor {
272
277
  target.syncWith(task.params.content)
273
278
  await Asset.loadAll(task.params.url)
274
279
  Asset.graph.update(this._defaultScheduleUrl)
280
+ await Asset.compileDataset(this.process.scene, this.process.engine)
275
281
 
276
282
  this.sendAnimationUnitToRemote(0, getAnimationUnitByAsset(task.params.url))
277
283
 
@@ -347,7 +353,7 @@ class RemoteExecutor {
347
353
  }
348
354
  }
349
355
  }
350
- onUpdateScheduler(unit: Unit, args: UpdateArgs) {
356
+ onUpdateScheduler(unit: Unit) {
351
357
  const htmlTransform = Descriptor.get<Descriptor>(unit.uuid)
352
358
  const service = this.htmlTransformCollection.getByMap(htmlTransform)
353
359
  if (service !== null) {
@@ -387,29 +393,28 @@ class RemoteExecutor {
387
393
  }
388
394
  }
389
395
 
390
- enhance(process: RemoteProcess, schedulerWrapper: ((scheduler: ServiceSchedulerDescriptor) => void) | null = null) {
396
+ enhance(process: RemoteProcess, schedulerWrapper: ((graphics: Graphics) => void) | null = null) {
391
397
  const executor = process.getExecutor()
392
398
  const listen = Compilation.prototype.listen
393
399
 
394
- Compilation.prototype.listen = function (scheduler: ServiceSchedulerDescriptor, engine: Engine) {
395
- if (schedulerWrapper !== null) schedulerWrapper(scheduler)
396
- listen.call(this, scheduler, engine)
397
- const graphics = engine.getGraphics(scheduler)
398
- if (graphics === null || graphics.__VYR_REMOTE_WRAPPER === true) return graphics
400
+ Compilation.prototype.listen = function (graphics: Graphics) {
401
+ if (schedulerWrapper !== null) schedulerWrapper(graphics)
402
+ listen.call(this, graphics)
403
+ if (graphics.__VYR_REMOTE_WRAPPER === true) return graphics
399
404
  graphics.__VYR_REMOTE_WRAPPER = true
400
405
 
401
406
  return graphics
402
407
  }
403
408
 
404
409
  const doUpdate = Graphics.prototype.doUpdate
405
- Graphics.prototype.doUpdate = function (unit: Unit, args: UpdateArgs) {
410
+ Graphics.prototype.doUpdate = function (unit: Unit) {
406
411
  if (this.__VYR_REMOTE_WRAPPER === true) {
407
412
  //@ts-ignore
408
413
  window['__VYR_RUNTIME.DISABLED_INPUT'] = true
409
- executor.onUpdateScheduler(unit, args)
410
- doUpdate.call(this, unit, args)
414
+ executor.onUpdateScheduler(unit)
415
+ doUpdate.call(this, unit)
411
416
  } else {
412
- doUpdate.call(this, unit, args)
417
+ doUpdate.call(this, unit)
413
418
  }
414
419
  }
415
420
 
@@ -75,7 +75,7 @@ class RemoteProcess {
75
75
  this._executor = executor
76
76
  }
77
77
  getExecutor<T extends RemoteExecutor = RemoteExecutor>() {
78
- return this._executor as T
78
+ return (this._executor ?? null) as T
79
79
  }
80
80
  }
81
81