lanxin преди 2 месеца
ревизия
bbc8f22110
променени са 100 файла, в които са добавени 2035 реда и са изтрити 0 реда
  1. 1 0
      @dage/events/.eslintignore
  2. 83 0
      @dage/events/index.d.ts
  3. 474 0
      @dage/events/index.js
  4. 7 0
      @dage/events/package.json
  5. 73 0
      @dage/krpano/build/KrpanoActionProxy.d.ts
  6. 1 0
      @dage/krpano/build/KrpanoActionProxy.d.ts.map
  7. 190 0
      @dage/krpano/build/KrpanoActionProxy.js
  8. 21 0
      @dage/krpano/build/PromiseQueue.d.ts
  9. 1 0
      @dage/krpano/build/PromiseQueue.d.ts.map
  10. 32 0
      @dage/krpano/build/PromiseQueue.js
  11. 1 0
      @dage/krpano/build/actions/littleplanetintro.d.ts
  12. 1 0
      @dage/krpano/build/actions/littleplanetintro.d.ts.map
  13. 1 0
      @dage/krpano/build/actions/littleplanetintro.js
  14. 8 0
      @dage/krpano/build/components/Action.d.ts
  15. 1 0
      @dage/krpano/build/components/Action.d.ts.map
  16. 14 0
      @dage/krpano/build/components/Action.js
  17. 41 0
      @dage/krpano/build/components/Autorotate.d.ts
  18. 1 0
      @dage/krpano/build/components/Autorotate.d.ts.map
  19. 11 0
      @dage/krpano/build/components/Autorotate.js
  20. 25 0
      @dage/krpano/build/components/Control.d.ts
  21. 1 0
      @dage/krpano/build/components/Control.d.ts.map
  22. 17 0
      @dage/krpano/build/components/Control.js
  23. 3 0
      @dage/krpano/build/components/Dev.d.ts
  24. 1 0
      @dage/krpano/build/components/Dev.d.ts.map
  25. 16 0
      @dage/krpano/build/components/Dev.js
  26. 56 0
      @dage/krpano/build/components/Events.d.ts
  27. 1 0
      @dage/krpano/build/components/Events.d.ts.map
  28. 25 0
      @dage/krpano/build/components/Events.js
  29. 7 0
      @dage/krpano/build/components/Gyro/index.d.ts
  30. 1 0
      @dage/krpano/build/components/Gyro/index.d.ts.map
  31. 14 0
      @dage/krpano/build/components/Gyro/index.js
  32. 57 0
      @dage/krpano/build/components/HotSpot.d.ts
  33. 1 0
      @dage/krpano/build/components/HotSpot.d.ts.map
  34. 36 0
      @dage/krpano/build/components/HotSpot.js
  35. 9 0
      @dage/krpano/build/components/Image.d.ts
  36. 1 0
      @dage/krpano/build/components/Image.d.ts.map
  37. 20 0
      @dage/krpano/build/components/Image.js
  38. 6 0
      @dage/krpano/build/components/Include.d.ts
  39. 1 0
      @dage/krpano/build/components/Include.d.ts.map
  40. 18 0
      @dage/krpano/build/components/Include.js
  41. 4 0
      @dage/krpano/build/components/Krpano.1.d.ts
  42. 1 0
      @dage/krpano/build/components/Krpano.1.d.ts.map
  43. 91 0
      @dage/krpano/build/components/Krpano.1.js
  44. 22 0
      @dage/krpano/build/components/Krpano.d.ts
  45. 1 0
      @dage/krpano/build/components/Krpano.d.ts.map
  46. 107 0
      @dage/krpano/build/components/Krpano.js
  47. 20 0
      @dage/krpano/build/components/Layer.d.ts
  48. 1 0
      @dage/krpano/build/components/Layer.d.ts.map
  49. 18 0
      @dage/krpano/build/components/Layer.js
  50. 3 0
      @dage/krpano/build/components/Loading/index.d.ts
  51. 1 0
      @dage/krpano/build/components/Loading/index.d.ts.map
  52. 5 0
      @dage/krpano/build/components/Loading/index.js
  53. 7 0
      @dage/krpano/build/components/Plugin.d.ts
  54. 1 0
      @dage/krpano/build/components/Plugin.d.ts.map
  55. 27 0
      @dage/krpano/build/components/Plugin.js
  56. 27 0
      @dage/krpano/build/components/Scene.d.ts
  57. 1 0
      @dage/krpano/build/components/Scene.d.ts.map
  58. 52 0
      @dage/krpano/build/components/Scene.js
  59. 48 0
      @dage/krpano/build/components/VideoScene.d.ts
  60. 1 0
      @dage/krpano/build/components/VideoScene.d.ts.map
  61. 70 0
      @dage/krpano/build/components/VideoScene.js
  62. 83 0
      @dage/krpano/build/components/View.d.ts
  63. 1 0
      @dage/krpano/build/components/View.d.ts.map
  64. 24 0
      @dage/krpano/build/components/View.js
  65. 7 0
      @dage/krpano/build/components/WebVR/index.d.ts
  66. 1 0
      @dage/krpano/build/components/WebVR/index.d.ts.map
  67. 24 0
      @dage/krpano/build/components/WebVR/index.js
  68. 13 0
      @dage/krpano/build/components/index.d.ts
  69. 1 0
      @dage/krpano/build/components/index.d.ts.map
  70. 12 0
      @dage/krpano/build/components/index.js
  71. 3 0
      @dage/krpano/build/contexts/CurrentSceneContext.d.ts
  72. 1 0
      @dage/krpano/build/contexts/CurrentSceneContext.d.ts.map
  73. 2 0
      @dage/krpano/build/contexts/CurrentSceneContext.js
  74. 4 0
      @dage/krpano/build/contexts/KrpanoRendererContext.d.ts
  75. 1 0
      @dage/krpano/build/contexts/KrpanoRendererContext.d.ts.map
  76. 2 0
      @dage/krpano/build/contexts/KrpanoRendererContext.js
  77. 10 0
      @dage/krpano/build/contexts/VideoSceneContext.d.ts
  78. 1 0
      @dage/krpano/build/contexts/VideoSceneContext.d.ts.map
  79. 4 0
      @dage/krpano/build/contexts/VideoSceneContext.js
  80. 3 0
      @dage/krpano/build/contexts/index.d.ts
  81. 1 0
      @dage/krpano/build/contexts/index.d.ts.map
  82. 2 0
      @dage/krpano/build/contexts/index.js
  83. 3 0
      @dage/krpano/build/hooks/index.d.ts
  84. 1 0
      @dage/krpano/build/hooks/index.d.ts.map
  85. 2 0
      @dage/krpano/build/hooks/index.js
  86. 2 0
      @dage/krpano/build/hooks/useCreate.d.ts
  87. 1 0
      @dage/krpano/build/hooks/useCreate.d.ts.map
  88. 10 0
      @dage/krpano/build/hooks/useCreate.js
  89. 1 0
      @dage/krpano/build/hooks/useCurrentScene.d.ts
  90. 1 0
      @dage/krpano/build/hooks/useCurrentScene.d.ts.map
  91. 1 0
      @dage/krpano/build/hooks/useCurrentScene.js
  92. 3 0
      @dage/krpano/build/hooks/useEventCallback.d.ts
  93. 1 0
      @dage/krpano/build/hooks/useEventCallback.d.ts.map
  94. 8 0
      @dage/krpano/build/hooks/useEventCallback.js
  95. 2 0
      @dage/krpano/build/hooks/useMounted.d.ts
  96. 1 0
      @dage/krpano/build/hooks/useMounted.d.ts.map
  97. 10 0
      @dage/krpano/build/hooks/useMounted.js
  98. 1 0
      @dage/krpano/build/hooks/useSceneState.d.ts
  99. 1 0
      @dage/krpano/build/hooks/useSceneState.d.ts.map
  100. 0 0
      @dage/krpano/build/hooks/useSceneState.js

+ 1 - 0
@dage/events/.eslintignore

@@ -0,0 +1 @@
+index.js

+ 83 - 0
@dage/events/index.d.ts

@@ -0,0 +1,83 @@
+/* eslint-disable @typescript-eslint/no-extraneous-class */
+
+declare global {
+  namespace WKUtils {
+    interface EventEmitter {
+      addListener(event: string | symbol, listener: (...args: any[]) => void): this;
+      on(event: string | symbol, listener: (...args: any[]) => void): this;
+      once(event: string | symbol, listener: (...args: any[]) => void): this;
+      removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
+      off(event: string | symbol, listener: (...args: any[]) => void): this;
+      removeAllListeners(event?: string | symbol): this;
+      setMaxListeners(n: number): this;
+      getMaxListeners(): number;
+      listeners(event: string | symbol): Function[];
+      rawListeners(event: string | symbol): Function[];
+      emit(event: string | symbol, ...args: any[]): boolean;
+      listenerCount(event: string | symbol): number;
+      // Added in Node 6...
+      prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
+      prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
+      eventNames(): (string | symbol)[];
+    }
+  }
+}
+
+export interface EventEmitterOptions {
+  /**
+   * Enables automatic capturing of promise rejection.
+   */
+  captureRejections?: boolean;
+}
+
+export interface NodeEventTarget {
+  once(event: string | symbol, listener: (...args: any[]) => void): this;
+}
+
+export interface DOMEventTarget {
+  addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
+}
+
+export interface StaticEventEmitterOptions {
+  signal?: AbortSignal;
+}
+
+interface EventEmitter extends WKUtils.EventEmitter {}
+
+export class EventEmitter {
+  constructor(options?: EventEmitterOptions);
+
+  static once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
+  static once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>;
+  static on(
+    emitter: WKUtils.EventEmitter,
+    event: string,
+    options?: StaticEventEmitterOptions
+  ): AsyncIterableIterator<any>;
+
+  /** @deprecated since v4.0.0 */
+  static listenerCount(emitter: WKUtils.EventEmitter, event: string | symbol): number;
+  /**
+   * Returns a list listener for a specific emitter event name.
+   */
+  static getEventListener(emitter: DOMEventTarget | WKUtils.EventEmitter, name: string | symbol): Function[];
+
+  /**
+   * This symbol shall be used to install a listener for only monitoring `'error'`
+   * events. Listeners installed using this symbol are called before the regular
+   * `'error'` listeners are called.
+   *
+   * Installing a listener using this symbol does not change the behavior once an
+   * `'error'` event is emitted, therefore the process will still crash if no
+   * regular `'error'` listener is installed.
+   */
+  static readonly errorMonitor: unique symbol;
+  static readonly captureRejectionSymbol: unique symbol;
+
+  /**
+   * Sets or gets the default captureRejection value for all emitters.
+   */
+  // TODO: These should be described using static getter/setter pairs:
+  static captureRejections: boolean;
+  static defaultMaxListeners: number;
+}

+ 474 - 0
@dage/events/index.js

@@ -0,0 +1,474 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+var R = typeof Reflect === 'object' ? Reflect : null;
+var ReflectApply =
+  R && typeof R.apply === 'function'
+    ? R.apply
+    : function ReflectApply(target, receiver, args) {
+        return Function.prototype.apply.call(target, receiver, args);
+      };
+
+var ReflectOwnKeys;
+if (R && typeof R.ownKeys === 'function') {
+  ReflectOwnKeys = R.ownKeys;
+} else if (Object.getOwnPropertySymbols) {
+  ReflectOwnKeys = function ReflectOwnKeys(target) {
+    return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
+  };
+} else {
+  ReflectOwnKeys = function ReflectOwnKeys(target) {
+    return Object.getOwnPropertyNames(target);
+  };
+}
+
+function ProcessEmitWarning(warning) {
+  if (console && console.warn) console.warn(warning);
+}
+
+var NumberIsNaN =
+  Number.isNaN ||
+  function NumberIsNaN(value) {
+    return value !== value;
+  };
+
+function EventEmitter() {
+  EventEmitter.init.call(this);
+}
+module.exports = EventEmitter;
+module.exports.once = once;
+
+// Backwards-compat with node 0.10.x
+EventEmitter.EventEmitter = EventEmitter;
+
+EventEmitter.prototype._events = undefined;
+EventEmitter.prototype._eventsCount = 0;
+EventEmitter.prototype._maxListeners = undefined;
+
+// By default EventEmitters will print a warning if more than 10 listeners are
+// added to it. This is a useful default which helps finding memory leaks.
+var defaultMaxListeners = 10;
+
+function checkListener(listener) {
+  if (typeof listener !== 'function') {
+    throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
+  }
+}
+
+Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
+  enumerable: true,
+  get: function () {
+    return defaultMaxListeners;
+  },
+  set: function (arg) {
+    if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
+      throw new RangeError(
+        'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'
+      );
+    }
+    defaultMaxListeners = arg;
+  },
+});
+
+EventEmitter.init = function () {
+  if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
+    this._events = Object.create(null);
+    this._eventsCount = 0;
+  }
+
+  this._maxListeners = this._maxListeners || undefined;
+};
+
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
+  if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
+    throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
+  }
+  this._maxListeners = n;
+  return this;
+};
+
+function _getMaxListeners(that) {
+  if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
+  return that._maxListeners;
+}
+
+EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
+  return _getMaxListeners(this);
+};
+
+EventEmitter.prototype.emit = function emit(type) {
+  var args = [];
+  for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
+  var doError = type === 'error';
+
+  var events = this._events;
+  if (events !== undefined) doError = doError && events.error === undefined;
+  else if (!doError) return false;
+
+  // If there is no 'error' event listener then throw.
+  if (doError) {
+    var er;
+    if (args.length > 0) er = args[0];
+    if (er instanceof Error) {
+      // Note: The comments on the `throw` lines are intentional, they show
+      // up in Node's output if this results in an unhandled exception.
+      throw er; // Unhandled 'error' event
+    }
+    // At least give some kind of context to the user
+    var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
+    err.context = er;
+    throw err; // Unhandled 'error' event
+  }
+
+  var handler = events[type];
+
+  if (handler === undefined) return false;
+
+  if (typeof handler === 'function') {
+    ReflectApply(handler, this, args);
+  } else {
+    var len = handler.length;
+    var listeners = arrayClone(handler, len);
+    for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
+  }
+
+  return true;
+};
+
+function _addListener(target, type, listener, prepend) {
+  var m;
+  var events;
+  var existing;
+
+  checkListener(listener);
+
+  events = target._events;
+  if (events === undefined) {
+    events = target._events = Object.create(null);
+    target._eventsCount = 0;
+  } else {
+    // To avoid recursion in the case that type === "newListener"! Before
+    // adding it to the listeners, first emit "newListener".
+    if (events.newListener !== undefined) {
+      target.emit('newListener', type, listener.listener ? listener.listener : listener);
+
+      // Re-assign `events` because a newListener handler could have caused the
+      // this._events to be assigned to a new object
+      events = target._events;
+    }
+    existing = events[type];
+  }
+
+  if (existing === undefined) {
+    // Optimize the case of one listener. Don't need the extra array object.
+    existing = events[type] = listener;
+    ++target._eventsCount;
+  } else {
+    if (typeof existing === 'function') {
+      // Adding the second element, need to change to array.
+      existing = events[type] = prepend ? [listener, existing] : [existing, listener];
+      // If we've already got an array, just append.
+    } else if (prepend) {
+      existing.unshift(listener);
+    } else {
+      existing.push(listener);
+    }
+
+    // Check for listener leak
+    m = _getMaxListeners(target);
+    if (m > 0 && existing.length > m && !existing.warned) {
+      existing.warned = true;
+      // No error code for this since it is a Warning
+      // eslint-disable-next-line no-restricted-syntax
+      var w = new Error(
+        'Possible EventEmitter memory leak detected. ' +
+          existing.length +
+          ' ' +
+          String(type) +
+          ' listeners ' +
+          'added. Use emitter.setMaxListeners() to ' +
+          'increase limit'
+      );
+      w.name = 'MaxListenersExceededWarning';
+      w.emitter = target;
+      w.type = type;
+      w.count = existing.length;
+      ProcessEmitWarning(w);
+    }
+  }
+
+  return target;
+}
+
+EventEmitter.prototype.addListener = function addListener(type, listener) {
+  return _addListener(this, type, listener, false);
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.prependListener = function prependListener(type, listener) {
+  return _addListener(this, type, listener, true);
+};
+
+function onceWrapper() {
+  if (!this.fired) {
+    this.target.removeListener(this.type, this.wrapFn);
+    this.fired = true;
+    if (arguments.length === 0) return this.listener.call(this.target);
+    return this.listener.apply(this.target, arguments);
+  }
+}
+
+function _onceWrap(target, type, listener) {
+  var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
+  var wrapped = onceWrapper.bind(state);
+  wrapped.listener = listener;
+  state.wrapFn = wrapped;
+  return wrapped;
+}
+
+EventEmitter.prototype.once = function once(type, listener) {
+  checkListener(listener);
+  this.on(type, _onceWrap(this, type, listener));
+  return this;
+};
+
+EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
+  checkListener(listener);
+  this.prependListener(type, _onceWrap(this, type, listener));
+  return this;
+};
+
+// Emits a 'removeListener' event if and only if the listener was removed.
+EventEmitter.prototype.removeListener = function removeListener(type, listener) {
+  var list, events, position, i, originalListener;
+
+  checkListener(listener);
+
+  events = this._events;
+  if (events === undefined) return this;
+
+  list = events[type];
+  if (list === undefined) return this;
+
+  if (list === listener || list.listener === listener) {
+    if (--this._eventsCount === 0) this._events = Object.create(null);
+    else {
+      delete events[type];
+      if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
+    }
+  } else if (typeof list !== 'function') {
+    position = -1;
+
+    for (i = list.length - 1; i >= 0; i--) {
+      if (list[i] === listener || list[i].listener === listener) {
+        originalListener = list[i].listener;
+        position = i;
+        break;
+      }
+    }
+
+    if (position < 0) return this;
+
+    if (position === 0) list.shift();
+    else {
+      spliceOne(list, position);
+    }
+
+    if (list.length === 1) events[type] = list[0];
+
+    if (events.removeListener !== undefined) this.emit('removeListener', type, originalListener || listener);
+  }
+
+  return this;
+};
+
+EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
+
+EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
+  var listeners, events, i;
+
+  events = this._events;
+  if (events === undefined) return this;
+
+  // not listening for removeListener, no need to emit
+  if (events.removeListener === undefined) {
+    if (arguments.length === 0) {
+      this._events = Object.create(null);
+      this._eventsCount = 0;
+    } else if (events[type] !== undefined) {
+      if (--this._eventsCount === 0) this._events = Object.create(null);
+      else delete events[type];
+    }
+    return this;
+  }
+
+  // emit removeListener for all listeners on all events
+  if (arguments.length === 0) {
+    var keys = Object.keys(events);
+    var key;
+    for (i = 0; i < keys.length; ++i) {
+      key = keys[i];
+      if (key === 'removeListener') continue;
+      this.removeAllListeners(key);
+    }
+    this.removeAllListeners('removeListener');
+    this._events = Object.create(null);
+    this._eventsCount = 0;
+    return this;
+  }
+
+  listeners = events[type];
+
+  if (typeof listeners === 'function') {
+    this.removeListener(type, listeners);
+  } else if (listeners !== undefined) {
+    // LIFO order
+    for (i = listeners.length - 1; i >= 0; i--) {
+      this.removeListener(type, listeners[i]);
+    }
+  }
+
+  return this;
+};
+
+function _listeners(target, type, unwrap) {
+  var events = target._events;
+
+  if (events === undefined) return [];
+
+  var evlistener = events[type];
+  if (evlistener === undefined) return [];
+
+  if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
+
+  return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
+}
+
+EventEmitter.prototype.listeners = function listeners(type) {
+  return _listeners(this, type, true);
+};
+
+EventEmitter.prototype.rawListeners = function rawListeners(type) {
+  return _listeners(this, type, false);
+};
+
+EventEmitter.listenerCount = function (emitter, type) {
+  if (typeof emitter.listenerCount === 'function') {
+    return emitter.listenerCount(type);
+  } else {
+    return listenerCount.call(emitter, type);
+  }
+};
+
+EventEmitter.prototype.listenerCount = listenerCount;
+function listenerCount(type) {
+  var events = this._events;
+
+  if (events !== undefined) {
+    var evlistener = events[type];
+
+    if (typeof evlistener === 'function') {
+      return 1;
+    } else if (evlistener !== undefined) {
+      return evlistener.length;
+    }
+  }
+
+  return 0;
+}
+
+EventEmitter.prototype.eventNames = function eventNames() {
+  return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
+};
+
+function arrayClone(arr, n) {
+  var copy = new Array(n);
+  for (var i = 0; i < n; ++i) copy[i] = arr[i];
+  return copy;
+}
+
+function spliceOne(list, index) {
+  for (; index + 1 < list.length; index++) list[index] = list[index + 1];
+  list.pop();
+}
+
+function unwrapListeners(arr) {
+  var ret = new Array(arr.length);
+  for (var i = 0; i < ret.length; ++i) {
+    ret[i] = arr[i].listener || arr[i];
+  }
+  return ret;
+}
+
+function once(emitter, name) {
+  return new Promise(function (resolve, reject) {
+    function errorListener(err) {
+      emitter.removeListener(name, resolver);
+      reject(err);
+    }
+
+    function resolver() {
+      if (typeof emitter.removeListener === 'function') {
+        emitter.removeListener('error', errorListener);
+      }
+      resolve([].slice.call(arguments));
+    }
+
+    eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
+    if (name !== 'error') {
+      addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
+    }
+  });
+}
+
+function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
+  if (typeof emitter.on === 'function') {
+    eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
+  }
+}
+
+function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
+  if (typeof emitter.on === 'function') {
+    if (flags.once) {
+      emitter.once(name, listener);
+    } else {
+      emitter.on(name, listener);
+    }
+  } else if (typeof emitter.addEventListener === 'function') {
+    // EventTarget does not have `error` event semantics like Node
+    // EventEmitters, we do not listen for `error` events here.
+    emitter.addEventListener(name, function wrapListener(arg) {
+      // IE does not have builtin `{ once: true }` support so we
+      // have to do it manually.
+      if (flags.once) {
+        emitter.removeEventListener(name, wrapListener);
+      }
+      listener(arg);
+    });
+  } else {
+    throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
+  }
+}

+ 7 - 0
@dage/events/package.json

@@ -0,0 +1,7 @@
+{
+  "name": "@dage/events",
+  "version": "1.0.1",
+  "main": "./index.js",
+  "types": "./index.d.ts",
+  "license": "MIT"
+}

+ 73 - 0
@dage/krpano/build/KrpanoActionProxy.d.ts

@@ -0,0 +1,73 @@
+import { PromiseQueue } from "./PromiseQueue";
+import { NativeKrpanoRendererObject, ROTATE_DIRECTION, ZOOM_ACTION } from "./types";
+export type HandlerFunc = (renderer: KrpanoActionProxy) => void;
+interface EventHandler {
+    eventName: string;
+    selector: string;
+    handler: HandlerFunc;
+}
+export declare class KrpanoActionProxy {
+    name: string;
+    krpanoRenderer?: NativeKrpanoRendererObject;
+    eventHandlers: EventHandler[];
+    dynamicTagWaitQueue: PromiseQueue<any>;
+    constructor(krpanoRenderer?: NativeKrpanoRendererObject, name?: string);
+    /**
+     * 等待 include 标签加载完成
+     */
+    waitIncludeLoaded(push?: boolean): Promise<any>;
+    /**
+     * 执行 Javascript 函数
+     * @param action 动作
+     * @param nexttick 是否在下一个渲染帧后执行
+     */
+    call(action: string, nexttick?: boolean): void;
+    set(name: string, ...params: Array<string | number | boolean>): void;
+    /**
+     * 动态添加标签
+     * @param tag 标签
+     * @param name 名称
+     * @param attrs 属性
+     */
+    setTag(tag: "scene" | "hotspot" | "layer" | "view" | "events" | "autorotate", name: string | null, attrs: Record<string, any>): Promise<void>;
+    get<T = any>(name: string): T;
+    /**
+     * 删除场景
+     * @param name 场景名称
+     */
+    removeScene(name: string): void;
+    /**
+     * 加载场景
+     * @param name 场景 name
+     */
+    loadScene(name: string): void;
+    /**
+     * 旋转视图
+     * @param direction 方位
+     * @param degrees 旋转度数,默认为 10
+     */
+    rotateView(direction: ROTATE_DIRECTION, degrees?: number): void;
+    /**
+     * 缩放视图
+     * @param action 动作
+     * @param num 缩放大小
+     */
+    zoomView(action: ZOOM_ACTION, num?: number): void;
+    on(eventName: string, selector: string, handler: HandlerFunc): this;
+    off(eventName: string, selector: string, handler: HandlerFunc): void;
+    fire(eventName: string, selector: string): void;
+    bindEvents(selector: string, mapEventsToHandler: Record<string, HandlerFunc | undefined>): void;
+    unbindEvents(selector: string, mapEventsToHandler: Record<string, HandlerFunc | undefined>): void;
+    addHotspot(name: string, attrs: Record<string, string | boolean | number | undefined>): Promise<void>;
+    removeHotspot(name: string): void;
+    syncTagsLoaded: boolean;
+    syncTagStack: {
+        tagName: string;
+        attribute: Record<string, unknown>;
+    }[];
+    pushSyncTag(tagName: string, attribute: Record<string, unknown>): void;
+    createSyncTags(): Promise<Document>;
+    private getXMLContent;
+}
+export {};
+//# sourceMappingURL=KrpanoActionProxy.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/KrpanoActionProxy.d.ts.map


+ 190 - 0
@dage/krpano/build/KrpanoActionProxy.js

@@ -0,0 +1,190 @@
+import { __awaiter } from "tslib";
+import { PromiseQueue } from "./PromiseQueue";
+import { ROTATE_DIRECTION, ZOOM_ACTION, } from "./types";
+import { buildKrpanoAction, buildKrpanoTagSetterActions } from "./utils";
+export class KrpanoActionProxy {
+    constructor(krpanoRenderer, name = "ReactKrpanoActionProxy") {
+        this.eventHandlers = [];
+        this.syncTagsLoaded = false;
+        this.syncTagStack = [];
+        this.krpanoRenderer = krpanoRenderer;
+        this.name = name;
+        // krpano 1.19 版本不支持动态插入 include,只能在文本中插入后重新加载
+        this.dynamicTagWaitQueue = new PromiseQueue();
+    }
+    /**
+     * 等待 include 标签加载完成
+     */
+    waitIncludeLoaded(push) {
+        return this.syncTagsLoaded
+            ? Promise.resolve()
+            : // 先进后出
+                this.dynamicTagWaitQueue[push ? "push" : "unshift"]();
+    }
+    /**
+     * 执行 Javascript 函数
+     * @param action 动作
+     * @param nexttick 是否在下一个渲染帧后执行
+     */
+    call(action, nexttick = false) {
+        var _a;
+        const actionStr = nexttick ? `nexttick(${action})` : action;
+        (_a = this.krpanoRenderer) === null || _a === void 0 ? void 0 : _a.call(actionStr);
+    }
+    set(name, ...params) {
+        this.call(buildKrpanoAction("set", name, ...params));
+    }
+    /**
+     * 动态添加标签
+     * @param tag 标签
+     * @param name 名称
+     * @param attrs 属性
+     */
+    setTag(tag, name, attrs) {
+        return __awaiter(this, void 0, void 0, function* () {
+            let nexttick = false;
+            if (tag === "hotspot" || tag === "events") {
+                nexttick = true;
+            }
+            yield this.waitIncludeLoaded();
+            this.call(buildKrpanoTagSetterActions(name ? `${tag}[${name}]` : tag, attrs), nexttick);
+        });
+    }
+    get(name) {
+        var _a;
+        return (_a = this.krpanoRenderer) === null || _a === void 0 ? void 0 : _a.get(name);
+    }
+    /**
+     * 删除场景
+     * @param name 场景名称
+     */
+    removeScene(name) {
+        if (this.get("scene") &&
+            typeof this.get("scene").removeItem === "function") {
+            this.get("scene").removeItem(name);
+        }
+        else {
+            // TODO: report Error
+        }
+    }
+    /**
+     * 加载场景
+     * @param name 场景 name
+     */
+    loadScene(name) {
+        this.call(buildKrpanoAction("loadscene", name, "null", "MERGE", "BLEND(0.5)"));
+    }
+    /**
+     * 旋转视图
+     * @param direction 方位
+     * @param degrees 旋转度数,默认为 10
+     */
+    rotateView(direction, degrees = 10) {
+        let str = "";
+        const view = this.get("view");
+        switch (direction) {
+            case ROTATE_DIRECTION.LEFT:
+                str = `view.hlookat, ${(view.hlookat || 0) - degrees}`;
+                break;
+            case ROTATE_DIRECTION.RIGHT:
+                str = `view.hlookat, ${(view.hlookat || 0) + degrees}`;
+                break;
+            case ROTATE_DIRECTION.UP:
+                str = `view.vlookat, ${(view.vlookat || 0) - degrees}`;
+                break;
+            case ROTATE_DIRECTION.DOWN:
+                str = `view.vlookat, ${(view.vlookat || 0) + degrees}`;
+                break;
+        }
+        this.call(buildKrpanoAction("tween", str, 0.5));
+    }
+    /**
+     * 缩放视图
+     * @param action 动作
+     * @param num 缩放大小
+     */
+    zoomView(action, num = 10) {
+        const view = this.get("view");
+        const targetFov = action === ZOOM_ACTION.IN ? -num : num;
+        this.call(buildKrpanoAction("tween", "view.fov", (view.fov || 0) + targetFov, 1));
+    }
+    on(eventName, selector, handler) {
+        this.eventHandlers.push({
+            eventName: eventName.toLowerCase(),
+            selector,
+            handler,
+        });
+        return this;
+    }
+    off(eventName, selector, handler) {
+        this.eventHandlers = this.eventHandlers.filter((e) => !(e.eventName === eventName.toLowerCase() &&
+            e.selector === selector &&
+            e.handler === handler));
+    }
+    fire(eventName, selector) {
+        this.eventHandlers
+            .filter((e) => e.eventName === eventName.toLowerCase() && e.selector === selector)
+            .map(({ handler }) => handler(this));
+    }
+    bindEvents(selector, mapEventsToHandler) {
+        Object.keys(mapEventsToHandler).map((eventName) => {
+            const func = mapEventsToHandler[eventName];
+            if (func) {
+                this.on(eventName, selector, func);
+            }
+        });
+    }
+    unbindEvents(selector, mapEventsToHandler) {
+        Object.keys(mapEventsToHandler).map((eventName) => {
+            const func = mapEventsToHandler[eventName];
+            if (func) {
+                this.off(eventName, selector, func);
+            }
+        });
+    }
+    addHotspot(name, attrs) {
+        return __awaiter(this, void 0, void 0, function* () {
+            yield this.waitIncludeLoaded();
+            this.call(buildKrpanoAction("addhotspot", name), true);
+            this.setTag("hotspot", name, attrs);
+        });
+    }
+    removeHotspot(name) {
+        this.call(buildKrpanoAction("removehotspot", name), true);
+    }
+    pushSyncTag(tagName, attribute) {
+        this.syncTagStack.unshift({
+            tagName,
+            attribute,
+        });
+    }
+    createSyncTags() {
+        return __awaiter(this, void 0, void 0, function* () {
+            const xmlDoc = yield this.getXMLContent();
+            const krpanoElement = xmlDoc.querySelector("krpano");
+            while (this.syncTagStack.length) {
+                const tag = this.syncTagStack.pop();
+                const element = xmlDoc.createElement(tag.tagName);
+                for (const key in tag.attribute) {
+                    element.setAttribute(key, tag.attribute[key]);
+                }
+                krpanoElement === null || krpanoElement === void 0 ? void 0 : krpanoElement.insertBefore(element, null);
+            }
+            return xmlDoc;
+        });
+    }
+    getXMLContent() {
+        return __awaiter(this, void 0, void 0, function* () {
+            let contentText = "";
+            const xml = this === null || this === void 0 ? void 0 : this.get("xml");
+            const parser = new DOMParser();
+            if (xml.content) {
+                contentText = xml.content;
+            }
+            else if (xml.url) {
+                contentText = yield fetch(xml.url).then((res) => res.text());
+            }
+            return parser.parseFromString(contentText, "text/xml");
+        });
+    }
+}

+ 21 - 0
@dage/krpano/build/PromiseQueue.d.ts

@@ -0,0 +1,21 @@
+export interface PromiseQueueItem<T> {
+    resolve(value: T): void;
+    reject(error: Error): void;
+}
+export declare class PromiseQueue<T> {
+    private queue;
+    /**
+     * 返回一个 promise 用于等待
+     */
+    push: () => Promise<T>;
+    unshift: () => Promise<T>;
+    /**
+     * 清空队列, 正常结束
+     */
+    flushResolve: (value: T) => void;
+    /**
+     * 清空队列, 移除结束
+     */
+    flushReject: (error: Error) => void;
+}
+//# sourceMappingURL=PromiseQueue.d.ts.map

+ 1 - 0
@dage/krpano/build/PromiseQueue.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"PromiseQueue.d.ts","sourceRoot":"","sources":["../src/PromiseQueue.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED,qBAAa,YAAY,CAAC,CAAC;IACzB,OAAO,CAAC,KAAK,CAAkC;IAE/C;;OAEG;IACH,IAAI,mBAIF;IACF,OAAO,mBAIL;IAEF;;OAEG;IACH,YAAY,UAAW,CAAC,UAGtB;IAEF;;OAEG;IACH,WAAW,UAAW,KAAK,UAGzB;CACH"}

+ 32 - 0
@dage/krpano/build/PromiseQueue.js

@@ -0,0 +1,32 @@
+export class PromiseQueue {
+    constructor() {
+        this.queue = [];
+        /**
+         * 返回一个 promise 用于等待
+         */
+        this.push = () => {
+            return new Promise((resolve, reject) => {
+                this.queue.push({ resolve, reject });
+            });
+        };
+        this.unshift = () => {
+            return new Promise((resolve, reject) => {
+                this.queue.unshift({ resolve, reject });
+            });
+        };
+        /**
+         * 清空队列, 正常结束
+         */
+        this.flushResolve = (value) => {
+            this.queue.forEach((item) => item.resolve(value));
+            this.queue = [];
+        };
+        /**
+         * 清空队列, 移除结束
+         */
+        this.flushReject = (error) => {
+            this.queue.forEach((item) => item.reject(error));
+            this.queue = [];
+        };
+    }
+}

+ 1 - 0
@dage/krpano/build/actions/littleplanetintro.d.ts

@@ -0,0 +1 @@
+//# sourceMappingURL=littleplanetintro.d.ts.map

+ 1 - 0
@dage/krpano/build/actions/littleplanetintro.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"littleplanetintro.d.ts","sourceRoot":"","sources":["../../src/actions/littleplanetintro.ts"],"names":[],"mappings":""}

+ 1 - 0
@dage/krpano/build/actions/littleplanetintro.js

@@ -0,0 +1 @@
+"use strict";

+ 8 - 0
@dage/krpano/build/components/Action.d.ts

@@ -0,0 +1,8 @@
+import { FC } from "react";
+export interface ActionProps {
+    name: string;
+    content: string;
+    [key: string]: unknown;
+}
+export declare const Action: FC<ActionProps>;
+//# sourceMappingURL=Action.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Action.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../src/components/Action.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAGlD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CAiBlC,CAAC"}

+ 14 - 0
@dage/krpano/build/components/Action.js

@@ -0,0 +1,14 @@
+import { __rest } from "tslib";
+import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const Action = (_a) => {
+    var { name, content } = _a, attrs = __rest(_a, ["name", "content"]);
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        renderer.tagAction.pushSyncTag("action", Object.assign({ name }, attrs), content);
+    }, [renderer]);
+    return _jsx(_Fragment, {});
+};

+ 41 - 0
@dage/krpano/build/components/Autorotate.d.ts

@@ -0,0 +1,41 @@
+import React from "react";
+/**
+ * @see https://krpano.com/docu/xml/#autorotate
+ */
+export interface AutorotateProps {
+    enabled: boolean;
+    /**
+     * 用户交互后等待的时间(秒)
+     * @default 2
+     */
+    waittime?: number;
+    /**
+     * 自动旋转的速度
+     * @default 10
+     */
+    speed?: number;
+    /**
+     * 自动旋转时视角的水平位置
+     * @default 0
+     */
+    horizon?: number;
+    /**
+     * 旋转的加速度
+     * @default 1
+     */
+    accel?: number;
+    tofov?: "off" | number;
+    oneroundrange?: number;
+    /**
+     * 当用户放大或缩小(通过滚动鼠标滚轮或手势)时,启用这个属性会减缓缩放的速度
+     * @default true
+     */
+    zoomslowdown?: boolean;
+    /**
+     * 定义哪些事件可以中断全景图像的交互操作
+     * @default userviewchange|layers|keyboard
+     */
+    interruptionevents?: string;
+}
+export declare const Autorotate: React.FC<AutorotateProps>;
+//# sourceMappingURL=Autorotate.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Autorotate.d.ts.map


+ 11 - 0
@dage/krpano/build/components/Autorotate.js

@@ -0,0 +1,11 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+import { memo, useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const Autorotate = memo((props) => {
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        const options = Object.assign({ waittime: 2, speed: 10 }, props);
+        renderer === null || renderer === void 0 ? void 0 : renderer.setTag("autorotate", null, options);
+    }, [renderer, props]);
+    return _jsx("div", { className: "autorotate" });
+});

+ 25 - 0
@dage/krpano/build/components/Control.d.ts

@@ -0,0 +1,25 @@
+import { FC } from "react";
+/**
+ * @see https://krpano.com/docu/xml/#control
+ */
+export interface ControlProps {
+    /**
+     * 控制方式
+     * @default 'moveto'
+     */
+    mode?: "drag" | "follow" | "moveto";
+    /**
+     * 控制用户是否可以交互
+     * @default 'all'
+     */
+    usercontrol?: "all" | "mouse" | "keyb" | "off";
+    /**
+     * 是否反转控制方向
+     * @default false
+     */
+    invert?: boolean;
+    [key: string]: unknown;
+}
+export declare const DEFAULT_CONTROL_PROPS: ControlProps;
+export declare const Control: FC<ControlProps>;
+//# sourceMappingURL=Control.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Control.d.ts.map


+ 17 - 0
@dage/krpano/build/components/Control.js

@@ -0,0 +1,17 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const DEFAULT_CONTROL_PROPS = {
+    mode: "drag",
+    usercontrol: "all",
+    invert: false,
+};
+export const Control = (props) => {
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        renderer.tagAction.pushSyncTag("control", Object.assign({}, DEFAULT_CONTROL_PROPS, props));
+    }, [renderer]);
+    return _jsx("div", { className: "control" });
+};

+ 3 - 0
@dage/krpano/build/components/Dev.d.ts

@@ -0,0 +1,3 @@
+import { FC } from "react";
+export declare const Dev: FC;
+//# sourceMappingURL=Dev.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Dev.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Dev.d.ts","sourceRoot":"","sources":["../../src/components/Dev.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAGtC,eAAO,MAAM,GAAG,EAAE,EAyBjB,CAAC"}

+ 16 - 0
@dage/krpano/build/components/Dev.js

@@ -0,0 +1,16 @@
+import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
+import { useEffect } from "react";
+import { Action } from ".";
+export const Dev = () => {
+    useEffect(() => {
+        window._devUpdateHotspotAthAtv = function (ath, atv) {
+            console.log("Updated ath: " + ath + ", atv: " + atv);
+        };
+    }, []);
+    return (_jsxs("div", { children: [_jsx(Action, { name: "dev_draggable_hotspot", content: `
+            asyncloop(pressed, dev_update_hotspot());
+          ` }), _jsx(Action, { name: "dev_update_hotspot", content: `
+          screentosphere(mouse.stagex, mouse.stagey, ath, atv);
+          js(_devUpdateHotspotAthAtv(get(ath), get(atv)));
+          ` })] }));
+};

+ 56 - 0
@dage/krpano/build/components/Events.d.ts

@@ -0,0 +1,56 @@
+import { FC } from "react";
+import { EventCallback } from "../types";
+/**
+ * @see https://krpano.com/docu/xml/#events
+ */
+export interface EventsConfig {
+    /** 事件名,若存在该参数则为局部事件 */
+    name?: string;
+    keep?: boolean;
+    onEnterFullscreen?: EventCallback;
+    onExitFullscreen?: EventCallback;
+    onXmlComplete?: EventCallback;
+    onPreviewComplete?: EventCallback;
+    onLoadComplete?: EventCallback;
+    onBlendComplete?: EventCallback;
+    onNewPano?: EventCallback;
+    onRemovePano?: EventCallback;
+    onNewScene?: EventCallback;
+    onXmlError?: EventCallback;
+    onLoadError?: EventCallback;
+    onKeydown?: EventCallback;
+    onKeyup?: EventCallback;
+    onClick?: EventCallback;
+    onSingleClick?: EventCallback;
+    onDoubleClick?: EventCallback;
+    onMousedown?: EventCallback;
+    onMouseup?: EventCallback;
+    onMousewheel?: EventCallback;
+    onContextmenu?: EventCallback;
+    onIdle?: EventCallback;
+    onViewChange?: EventCallback;
+    onViewChanged?: EventCallback;
+    onResize?: EventCallback;
+    onFrameBufferResize?: EventCallback;
+    /**
+     * 启动自动旋转时回调
+     */
+    onAutoRotateStart?: EventCallback;
+    /**
+     * 停止自动旋转时回调
+     */
+    onAutoRotateStop?: EventCallback;
+    /**
+     * 全景图完成一轮自动旋转时回调
+     */
+    onAutoRotateOneRound?: EventCallback;
+    /**
+     * 自动旋转状态发生改变时回调
+     */
+    onAutoRotateChange?: EventCallback;
+    onIPhoneFullscreen?: EventCallback;
+}
+export interface EventsProps extends EventsConfig {
+}
+export declare const Events: FC<EventsProps>;
+//# sourceMappingURL=Events.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Events.d.ts.map


+ 25 - 0
@dage/krpano/build/components/Events.js

@@ -0,0 +1,25 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts/KrpanoRendererContext";
+import { mapEventPropsToJSCall } from "../utils";
+const GlobalEvents = "__GlobalEvents";
+export const Events = (_a) => {
+    var { name, keep } = _a, EventsAttrs = __rest(_a, ["name", "keep"]);
+    const renderer = useContext(KrpanoRendererContext);
+    const EventSelector = `events[${name || GlobalEvents}]`;
+    // 在renderer上绑定回调
+    useEffect(() => {
+        renderer === null || renderer === void 0 ? void 0 : renderer.bindEvents(EventSelector, Object.assign({}, EventsAttrs));
+        return () => {
+            renderer === null || renderer === void 0 ? void 0 : renderer.unbindEvents(EventSelector, Object.assign({}, EventsAttrs));
+        };
+    }, [renderer, EventsAttrs]);
+    // Krpano标签上添加js call,触发事件
+    useEffect(() => {
+        renderer === null || renderer === void 0 ? void 0 : renderer.setTag("events", 
+        // 全局事件直接设置
+        name || null, Object.assign(Object.assign({}, mapEventPropsToJSCall(Object.assign({}, EventsAttrs), (eventName) => `js(${renderer.name}.fire(${eventName},${EventSelector}))`)), { keep }), true);
+    }, [name, renderer]);
+    return _jsx("div", { className: "events" });
+};

+ 7 - 0
@dage/krpano/build/components/Gyro/index.d.ts

@@ -0,0 +1,7 @@
+import { FC } from "react";
+export interface GyroProps {
+    url: string;
+    [key: string]: unknown;
+}
+export declare const Gyro: FC<GyroProps>;
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Gyro/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Gyro/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAQ,MAAM,OAAO,CAAC;AAGjC,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AASD,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAS7B,CAAC"}

+ 14 - 0
@dage/krpano/build/components/Gyro/index.js

@@ -0,0 +1,14 @@
+import { __rest } from "tslib";
+import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
+import { memo } from "react";
+import { Plugin } from "../Plugin";
+const DEFAULT_GYRO_CONFIG = {
+    softstart: 1,
+    devices: "html5",
+    keep: true,
+    enabled: true,
+};
+export const Gyro = memo((_a) => {
+    var attrs = __rest(_a, []);
+    return (_jsx(_Fragment, { children: _jsx(Plugin, Object.assign({ name: "skin_gyro" }, Object.assign(Object.assign({}, DEFAULT_GYRO_CONFIG), attrs))) }));
+});

+ 57 - 0
@dage/krpano/build/components/HotSpot.d.ts

@@ -0,0 +1,57 @@
+import { FC, ReactNode } from "react";
+import { EventCallback } from "../types";
+export interface HotspotProps {
+    name: string;
+    children?: ReactNode;
+    url?: string;
+    /**
+     * @see https://krpano.com/docu/xml/?version=121#layer.type
+     */
+    type?: "image" | "text";
+    keep?: boolean;
+    visible?: boolean;
+    enabled?: boolean;
+    handCursor?: boolean;
+    cursor?: string;
+    maskChildren?: boolean;
+    zOrder?: string;
+    style?: string;
+    /**
+     * 水平方向
+     */
+    ath?: number;
+    /**
+     * 垂直方向
+     */
+    atv?: number;
+    edge?: string;
+    zoom?: boolean;
+    distorted?: boolean;
+    rx?: number;
+    ry?: number;
+    rz?: number;
+    width?: string;
+    height?: string;
+    /**
+     * 比例
+     * @default 0.5
+     */
+    scale?: number;
+    rotate?: number;
+    alpha?: number;
+    bg?: boolean;
+    bgcolor?: string;
+    bgalpha?: number;
+    bgborder?: number;
+    bgbordermode?: "outside" | "inside";
+    bgborderblend?: boolean;
+    onOver?: EventCallback;
+    onHover?: EventCallback;
+    onOut?: EventCallback;
+    onDown?: EventCallback | string;
+    onUp?: EventCallback;
+    onClick?: EventCallback;
+    onLoaded?: EventCallback;
+}
+export declare const HotSpot: FC<HotspotProps>;
+//# sourceMappingURL=HotSpot.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/HotSpot.d.ts.map


+ 36 - 0
@dage/krpano/build/components/HotSpot.js

@@ -0,0 +1,36 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { memo, useContext, useEffect, useMemo } from "react";
+import { KrpanoRendererContext } from "../contexts";
+import { buildKrpanoAction, childrenToOuterHTML, mapEventPropsToJSCall, mapObject, } from "../utils";
+export const HotSpot = memo((_a) => {
+    var { name } = _a, rest = __rest(_a, ["name"]);
+    const EventSelector = `hotspot[${name}]`;
+    const renderer = useContext(KrpanoRendererContext);
+    const options = useMemo(() => {
+        const { scale = 0.5, children } = rest, r = __rest(rest, ["scale", "children"]);
+        return Object.assign({ scale, html: r.type === "text" ? childrenToOuterHTML(children) : null, onOver: buildKrpanoAction("tween", "scale", scale + 0.05), onOut: buildKrpanoAction("tween", "scale", scale) }, r);
+    }, [rest]);
+    useEffect(() => {
+        const eventsObj = mapObject(Object.assign({}, options), (key, value) => {
+            if (key.startsWith("on") && typeof value === "function") {
+                return {
+                    [key]: value,
+                };
+            }
+            return {};
+        });
+        renderer === null || renderer === void 0 ? void 0 : renderer.bindEvents(EventSelector, eventsObj);
+        renderer === null || renderer === void 0 ? void 0 : renderer.addHotspot(name, {});
+        return () => {
+            renderer === null || renderer === void 0 ? void 0 : renderer.unbindEvents(EventSelector, eventsObj);
+            renderer === null || renderer === void 0 ? void 0 : renderer.removeHotspot(name);
+        };
+    }, []);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        renderer.setTag("hotspot", name, Object.assign(Object.assign({}, options), mapEventPropsToJSCall(Object.assign({}, options), (key) => `js(${renderer.name}.fire(${key},${EventSelector}))`)), true);
+    }, [renderer, name, options]);
+    return _jsx("div", { className: "hotspot" });
+});

+ 9 - 0
@dage/krpano/build/components/Image.d.ts

@@ -0,0 +1,9 @@
+import { FC } from "react";
+/**
+ * @see https://krpano.com/docu/xml/#layer.html
+ */
+export interface KrpanoImgProps {
+    children?: React.ReactNode;
+}
+export declare const KrpanoImg: FC<KrpanoImgProps>;
+//# sourceMappingURL=Image.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Image.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../src/components/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAGlD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAgBxC,CAAC"}

+ 20 - 0
@dage/krpano/build/components/Image.js

@@ -0,0 +1,20 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const KrpanoImg = (_a) => {
+    var { children } = _a, attrs = __rest(_a, ["children"]);
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        renderer.call(`
+      addimage(image_sphere);
+      set(image_sphere.type, sphere);
+      set(image_sphere.url, 'plugin:video');
+      set(image_sphere.preload, true);
+      set(image_sphere.onload, 'trace("Video Loaded!");');
+    `);
+    }, [renderer, attrs]);
+    return _jsx("div", { className: "krpano-img", children: children });
+};

+ 6 - 0
@dage/krpano/build/components/Include.d.ts

@@ -0,0 +1,6 @@
+import { FC } from "react";
+export interface IncludeProps {
+    url: string;
+}
+export declare const Include: FC<IncludeProps>;
+//# sourceMappingURL=Include.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Include.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Include.d.ts","sourceRoot":"","sources":["../../src/components/Include.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAIlD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAcpC,CAAC"}

+ 18 - 0
@dage/krpano/build/components/Include.js

@@ -0,0 +1,18 @@
+import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+import { buildKrpanoAction, is121Version } from "../utils";
+export const Include = ({ url }) => {
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        if (is121Version) {
+            renderer.call(buildKrpanoAction("includexml", url));
+        }
+        else {
+            renderer.tagAction.pushSyncTag("include", { url });
+        }
+    }, [renderer]);
+    return _jsx(_Fragment, {});
+};

+ 4 - 0
@dage/krpano/build/components/Krpano.1.d.ts

@@ -0,0 +1,4 @@
+import React from "react";
+import { KrpanoProps } from "./Krpano";
+export declare const Krpano: React.FC<KrpanoProps>;
+//# sourceMappingURL=Krpano.1.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Krpano.1.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Krpano.1.d.ts","sourceRoot":"","sources":["../../src/components/Krpano.1.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAShE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+HxC,CAAC"}

+ 91 - 0
@dage/krpano/build/components/Krpano.1.js

@@ -0,0 +1,91 @@
+import { __awaiter, __rest } from "tslib";
+import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
+import { useCallback, useEffect, useState } from "react";
+import { KrpanoActionProxy } from "../models";
+import { useMounted, useEventCallback } from "../hooks";
+import { CurrentSceneContext, KrpanoRendererContext } from "../contexts";
+import { buildKrpanoAction } from "../utils";
+import { WebVR } from "./WebVR";
+import { Action } from "./Action";
+import { Events } from "./Events";
+export const Krpano = (_a) => {
+    var { className, style, children, currentScene, target = "krpano", webvrUrl, webvrConfig, gyroUrl, onReady } = _a, rest = __rest(_a, ["className", "style", "children", "currentScene", "target", "webvrUrl", "webvrConfig", "gyroUrl", "onReady"]);
+    const [renderer, setRenderer] = useState(null);
+    const onReadyRef = useEventCallback(onReady);
+    const onReadyCallback = useCallback((obj) => {
+        const renderer = new KrpanoActionProxy(obj);
+        window[renderer.name] = renderer;
+        setRenderer(renderer);
+        if (onReadyRef.current) {
+            onReadyRef.current(renderer);
+        }
+    }, [onReadyRef]);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        const reloadXML = () => __awaiter(void 0, void 0, void 0, function* () {
+            if (renderer.tagAction.syncTagStack.length) {
+                // krpano 1.21 版本以下不支持动态插入 include,只能在文本中插入后重新加载
+                const updateXmlString = new XMLSerializer().serializeToString(yield renderer.tagAction.createSyncTags());
+                console.log(updateXmlString);
+                renderer.call(buildKrpanoAction("loadxml", updateXmlString));
+            }
+            renderer.tagAction.syncTagsLoaded = true;
+            renderer.tagAction.queue.flushResolve(true);
+        });
+        reloadXML();
+    }, [renderer]);
+    useEffect(() => {
+        if (!renderer || !currentScene)
+            return;
+        renderer.tagAction.waitIncludeLoaded(true).then(() => {
+            renderer.loadScene(currentScene);
+        });
+    }, [renderer, currentScene]);
+    const initKrpano = () => {
+        const defaultConfig = {
+            html5: "auto",
+            xml: null,
+            mobilescale: 1,
+        };
+        if (typeof window.embedpano === "function") {
+            window.embedpano(Object.assign(Object.assign(Object.assign({}, defaultConfig), { target, onready: onReadyCallback }), rest));
+        }
+        else {
+            throw new Error("Krpano required");
+        }
+    };
+    useMounted(() => {
+        initKrpano();
+    });
+    return (_jsx(KrpanoRendererContext.Provider, { value: renderer, children: _jsxs(CurrentSceneContext.Provider, { value: currentScene || null, children: [webvrUrl && _jsx(WebVR, Object.assign({ url: webvrUrl }, webvrConfig)), _jsx("div", { id: target, className: className, style: style, children: renderer ? children : null }), _jsx(Events, { onLoadComplete: () => {
+                        console.log("--");
+                    } }), _jsx(Action, { name: "skin_setup_littleplanetintro", content: `
+            copy(lp_scene, xml.scene);
+            copy(lp_hlookat, view.hlookat);
+            copy(lp_vlookat, view.vlookat);
+            copy(lp_fov, view.fov);
+            copy(lp_fovmax, view.fovmax);
+            copy(lp_limitview, view.limitview);
+            set(view.fovmax, 170);
+            set(view.limitview, lookto);
+            set(view.vlookatmin, 90);
+            set(view.vlookatmax, 90);
+            lookat(calc(lp_hlookat - 180), 90, 150, 1, 0, 0);
+            set(events[lp_events].onloadcomplete,
+              delayedcall(0.5,
+                if(lp_scene === xml.scene,
+                  set(control.usercontrol, off);
+                  copy(view.limitview, lp_limitview);
+                  set(view.vlookatmin, null);
+                  set(view.vlookatmax, null);
+                  tween(view.hlookat|view.vlookat|view.fov|view.distortion, calc('' + lp_hlookat + '|' + lp_vlookat + '|' + lp_fov + '|' + 0.0),
+                    3.0, easeOutQuad,
+                    set(control.usercontrol, all);
+                    tween(view.fovmax, get(lp_fovmax));
+                    );
+                  );
+                );
+              );
+          ` })] }) }));
+};

+ 22 - 0
@dage/krpano/build/components/Krpano.d.ts

@@ -0,0 +1,22 @@
+import React from "react";
+import { KrpanoActionProxy } from "../models";
+import { IKrpanoConfig } from "../types";
+export interface KrpanoProps extends Omit<IKrpanoConfig, "onready" | "target"> {
+    className?: string;
+    style?: React.CSSProperties;
+    children?: React.ReactNode;
+    currentScene?: string;
+    target?: string;
+    /**
+     * webvr.xml 地址,需遵循同源策略
+     */
+    webvrUrl?: string;
+    webvrConfig?: Record<string, unknown>;
+    /**
+     * 小行星视角
+     */
+    littlePlanetIntro?: boolean;
+    onReady?: (renderer: KrpanoActionProxy) => void;
+}
+export declare const Krpano: React.FC<KrpanoProps>;
+//# sourceMappingURL=Krpano.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Krpano.d.ts.map


Файловите разлики са ограничени, защото са твърде много
+ 107 - 0
@dage/krpano/build/components/Krpano.js


+ 20 - 0
@dage/krpano/build/components/Layer.d.ts

@@ -0,0 +1,20 @@
+import { FC } from "react";
+/**
+ * @see https://krpano.com/docu/xml/#layer.html
+ */
+export interface LayerProps {
+    name: string;
+    keep?: boolean;
+    type?: "image" | "text" | "container";
+    align?: "lefttop" | "left" | "leftbottom" | "top" | "center" | "bottom" | "righttop" | "right";
+    x?: number;
+    y?: number;
+    html?: string;
+    visible?: boolean;
+    background?: boolean;
+    border?: boolean;
+    enabled?: boolean;
+    css?: string;
+}
+export declare const Layer: FC<LayerProps>;
+//# sourceMappingURL=Layer.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Layer.d.ts.map


+ 18 - 0
@dage/krpano/build/components/Layer.js

@@ -0,0 +1,18 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { memo, useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const Layer = memo((_a) => {
+    var { name } = _a, rest = __rest(_a, ["name"]);
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        renderer === null || renderer === void 0 ? void 0 : renderer.addLayer(name, {});
+        return () => {
+            renderer === null || renderer === void 0 ? void 0 : renderer.removeLayer(name);
+        };
+    }, []);
+    useEffect(() => {
+        renderer === null || renderer === void 0 ? void 0 : renderer.setTag("layer", name, Object.assign({}, rest), true);
+    }, [renderer, name, rest]);
+    return _jsx("div", { className: "layer" });
+});

+ 3 - 0
@dage/krpano/build/components/Loading/index.d.ts

@@ -0,0 +1,3 @@
+import "index.scss";
+export declare const KrpanoLoading: () => import("react/jsx-runtime").JSX.Element;
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Loading/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Loading/index.tsx"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,eAAO,MAAM,aAAa,+CAazB,CAAC"}

+ 5 - 0
@dage/krpano/build/components/Loading/index.js

@@ -0,0 +1,5 @@
+import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
+import "index.scss";
+export const KrpanoLoading = () => {
+    return (_jsxs("div", { className: "krpano-loading", children: [_jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" }), _jsx("div", { className: "krpano-loading__item" })] }));
+};

+ 7 - 0
@dage/krpano/build/components/Plugin.d.ts

@@ -0,0 +1,7 @@
+import { FC } from "react";
+export interface PluginProps {
+    name: string;
+    [key: string]: unknown;
+}
+export declare const Plugin: FC<PluginProps>;
+//# sourceMappingURL=Plugin.d.ts.map

+ 1 - 0
@dage/krpano/build/components/Plugin.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/components/Plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAIlD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CA2BlC,CAAC"}

+ 27 - 0
@dage/krpano/build/components/Plugin.js

@@ -0,0 +1,27 @@
+import { __rest } from "tslib";
+import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+import { buildKrpanoAction, is121Version } from "../utils";
+export const Plugin = (_a) => {
+    var { name } = _a, attribute = __rest(_a, ["name"]);
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        if (is121Version) {
+            const arr = [];
+            for (const key in attribute) {
+                arr.push(`${key}=${attribute[key]}`);
+            }
+            renderer.call(buildKrpanoAction("addplugin", name, ...arr));
+            return () => {
+                renderer.call(buildKrpanoAction("removeplugin", name));
+            };
+        }
+        else {
+            renderer.tagAction.pushSyncTag("plugin", Object.assign(Object.assign({}, attribute), { name }));
+        }
+    }, [renderer, name, attribute]);
+    return _jsx(_Fragment, {});
+};

+ 27 - 0
@dage/krpano/build/components/Scene.d.ts

@@ -0,0 +1,27 @@
+/// <reference types="react" />
+export interface SceneImageAttributes {
+    type: "cube" | "sphere";
+    /** 瓦片尺寸 */
+    tileSize?: number;
+    multires?: boolean;
+}
+export interface SceneImage {
+    url: string;
+}
+export interface SceneImageWithMultires extends SceneImage {
+    tiledImageWidth: number;
+    tiledImageHeight: number;
+}
+export interface SceneProps {
+    name: string;
+    children?: React.ReactNode;
+    previewUrl?: string;
+    /** 直接指定scene的xml内容。指定后会忽略其他设置 */
+    content?: string;
+    /** image标签属性 */
+    imageTagAttributes: SceneImageAttributes;
+    /** Scene包含的图片。数组的长度大于1时按multires解析为多个level */
+    images?: [SceneImage] | SceneImageWithMultires[];
+}
+export declare const Scene: React.FC<SceneProps>;
+//# sourceMappingURL=Scene.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/Scene.d.ts.map


+ 52 - 0
@dage/krpano/build/components/Scene.js

@@ -0,0 +1,52 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { CurrentSceneContext, KrpanoRendererContext } from "../contexts";
+import { buildXML } from "../utils";
+export const Scene = ({ name, previewUrl, imageTagAttributes, images = [], content, children, }) => {
+    const renderer = useContext(KrpanoRendererContext);
+    const currentScene = useContext(CurrentSceneContext);
+    useEffect(() => {
+        const contentImageMeta = {
+            tag: "image",
+            // @ts-ignore
+            attrs: imageTagAttributes,
+            children: [],
+        };
+        // multires
+        if (images.length > 1) {
+            contentImageMeta.children.push(...images.map((_a) => {
+                var { tiledImageWidth, tiledImageHeight } = _a, img = __rest(_a, ["tiledImageWidth", "tiledImageHeight"]);
+                const imgXML = {
+                    tag: "level",
+                    attrs: {
+                        tiledImageWidth,
+                        tiledImageHeight,
+                    },
+                    children: [
+                        {
+                            tag: imageTagAttributes.type,
+                            attrs: Object.assign({}, img),
+                        },
+                    ],
+                };
+                return imgXML;
+            }));
+        }
+        else if (images.length === 1) {
+            const img = __rest(images[0], []);
+            contentImageMeta.children.push({
+                tag: imageTagAttributes.type,
+                attrs: Object.assign({}, img),
+            });
+        }
+        renderer === null || renderer === void 0 ? void 0 : renderer.setTag("scene", name, {
+            content: content ||
+                `${previewUrl ? `<preview url="${previewUrl}" />` : ""}${images.length > 0 ? buildXML(contentImageMeta) : ""}`,
+        });
+        return () => {
+            renderer === null || renderer === void 0 ? void 0 : renderer.removeScene(name);
+        };
+    }, [renderer, name, images, imageTagAttributes, content, previewUrl]);
+    return _jsx("div", { className: "scene", children: currentScene === name ? children : null });
+};

+ 48 - 0
@dage/krpano/build/components/VideoScene.d.ts

@@ -0,0 +1,48 @@
+import { FC } from "react";
+export interface VideoSceneProps {
+    name: string;
+    videointerfaceXmlUrl: string;
+    videoplayerUrl: string;
+    /**
+     * 视频源列表
+     * @example
+     * [{
+     *   // 分辨率
+     *   res: '1920x960',
+     *   // | 分割视频文件 url,krpano会自动根据浏览器的兼容性选择合适的视频格式播放
+     *   url: '/path/video-1920x960.mp4|/path/video-1920x960.webm',
+     *   // 封面图片 url
+     *   poster: '/path/video-1920x960-poster.jpg'
+     * }]
+     */
+    sourceList: {
+        res: string;
+        url: string;
+        poster: string;
+    }[];
+    /**
+     * 播放分辨率
+     * @example '1920x960'
+     */
+    playRes: string;
+    /**
+     * 插件属性,参数见文档
+     * @see https://krpano.com/plugins/videoplayer/#attributes
+     * @default
+     * {
+     *   loop: true,
+     *   volume: 0
+     * }
+     */
+    pluginAttrs?: {
+        loop?: boolean;
+        volume?: number;
+    };
+    children?: React.ReactNode;
+    /**
+     * 页面可见状态发生变化回调
+     */
+    onVisibility?: () => void;
+}
+export declare const VideoScene: FC<VideoSceneProps>;
+//# sourceMappingURL=VideoScene.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/VideoScene.d.ts.map


+ 70 - 0
@dage/krpano/build/components/VideoScene.js

@@ -0,0 +1,70 @@
+import { jsx as _jsx } from "react/jsx-runtime";
+import { useContext, useEffect } from "react";
+import { observer } from "mobx-react";
+import { KrpanoRendererContext } from "../contexts";
+import { videoSceneModel } from "../models";
+const DEFAULT_PLUGIN_ATTRS = {
+    loop: true,
+    volume: 0,
+};
+export const VideoScene = observer(({ name, videointerfaceXmlUrl, videoplayerUrl, sourceList, playRes, pluginAttrs, children, onVisibility, }) => {
+    const renderer = useContext(KrpanoRendererContext);
+    const model = videoSceneModel;
+    const getSourceListStr = () => {
+        let str = "";
+        sourceList.forEach((item) => {
+            str += `videointerface_addsource('${item.res}', '${item.url}', '${item.poster}');`;
+        });
+        return str;
+    };
+    const objectToString = (obj) => {
+        let stack = [];
+        Object.keys(obj).forEach((key) => {
+            stack.push(`${key}="${obj[key]}"`);
+        });
+        return stack.join(" ");
+    };
+    const visibilityHandler = () => {
+        if (document.visibilityState === "hidden") {
+            model.pause();
+        }
+        onVisibility === null || onVisibility === void 0 ? void 0 : onVisibility();
+    };
+    useEffect(() => {
+        window.addEventListener("visibilitychange", visibilityHandler);
+        return () => {
+            window.removeEventListener("visibilitychange", visibilityHandler);
+        };
+    }, []);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        const _pluginAttrs = objectToString(Object.assign({}, DEFAULT_PLUGIN_ATTRS, pluginAttrs, {
+            pausedonstart: !model.playing,
+        }));
+        renderer.tagAction.pushSyncTag("scene", {
+            name,
+        }, `
+          <!-- include the videoplayer interface / skin -->
+          <include url="${videointerfaceXmlUrl}" />
+
+          <!-- include the videoplayer plugin -->
+          <plugin ${_pluginAttrs} name="video"
+            url="${videoplayerUrl}"
+            onloaded="add_video_sources();"
+          />
+
+          <!-- use the videoplayer plugin as panoramic image source -->
+          <image>
+            <sphere url="plugin:video" />
+          </image>
+
+          <action name="add_video_sources" >
+            ${getSourceListStr()}
+
+            videointerface_play('${playRes}');
+          </action>
+        `);
+    }, [renderer]);
+    return _jsx("div", { className: "video-scene", children: children });
+});

+ 83 - 0
@dage/krpano/build/components/View.d.ts

@@ -0,0 +1,83 @@
+import React from "react";
+/**
+ * @see https://krpano.com/docu/xml/#view
+ */
+export interface ViewProps {
+    /**
+     * 水平视角
+     * @range -180-180
+     */
+    hlookat?: number;
+    /**
+     * 垂直视角
+     * @range -90-90
+     */
+    vlookat?: number;
+    /**
+     * 用户视图的广度,数值越大,视角越宽广
+     */
+    fov?: number;
+    /**
+     * 视角的最小限制
+     */
+    fovMin?: number;
+    /**
+     * 视角的最大限制
+     */
+    fovMax?: number;
+    camRoll?: number;
+    /**
+     * @see https://krpano.com/docu/xml/#view.fovtype
+     */
+    fovType?: "VFOV" | "HFOV" | "DFOV" | "MFOV" | "SFOV";
+    /**
+     * 最大缩放系数,如果存在将覆盖 fovMin
+     */
+    maxPixelZoom?: number;
+    mFovRatio?: number;
+    distortion?: number;
+    distortionFovLink?: number;
+    stereographic?: boolean;
+    pannini?: number;
+    architectural?: number;
+    architecturalOnlyMiddle?: boolean;
+    /**
+     * @see https://krpano.com/docu/xml/#view.limitview
+     */
+    limitView?: "off" | "auto" | "lookat" | "range" | "fullrange" | "offrange";
+    /**
+     * 最大向左角度
+     * 需要设置 limitView=range
+     * @range -180-180
+     */
+    hlookatMin?: number;
+    /**
+     * 最大向右角度
+     * 需要设置 limitView=range
+     * @range -180-180
+     */
+    hlookatMax?: number;
+    /**
+     * 最大向上角度
+     * 需要设置 limitView=range
+     * @range -90-90
+     */
+    vlookatMin?: number;
+    /**
+     * 最大向下角度
+     * 需要设置 limitView=range
+     * @range -90-90
+     */
+    vlookatMax?: number;
+    rx?: number;
+    ry?: number;
+    tx?: number;
+    ty?: number;
+    tz?: number;
+    ox?: number;
+    oy?: number;
+    oz?: number;
+    children?: null;
+}
+export declare const View: React.FC<ViewProps>;
+//# sourceMappingURL=View.d.ts.map

Файловите разлики са ограничени, защото са твърде много
+ 1 - 0
@dage/krpano/build/components/View.d.ts.map


+ 24 - 0
@dage/krpano/build/components/View.js

@@ -0,0 +1,24 @@
+import { __rest } from "tslib";
+import { jsx as _jsx } from "react/jsx-runtime";
+import { memo, useContext, useEffect } from "react";
+import { KrpanoRendererContext } from "../contexts";
+export const View = memo((_a) => {
+    var { children } = _a, viewAttrs = __rest(_a, ["children"]);
+    const renderer = useContext(KrpanoRendererContext);
+    useEffect(() => {
+        if (!renderer)
+            return;
+        if (renderer.littlePlanetIntro) {
+            renderer === null || renderer === void 0 ? void 0 : renderer.setTag("view", null, Object.assign({}, viewAttrs));
+            // TOFIX: 如果开启小行星入场,会导致 limitview 设置失效
+            setTimeout(() => {
+                // 等待入场动画结束覆盖属性
+                renderer === null || renderer === void 0 ? void 0 : renderer.setTag("view", null, Object.assign({}, viewAttrs));
+            }, 4000);
+        }
+        else {
+            renderer === null || renderer === void 0 ? void 0 : renderer.setTag("view", null, Object.assign({}, viewAttrs), true);
+        }
+    }, [renderer, viewAttrs]);
+    return _jsx("div", { className: "view", children: children });
+});

+ 7 - 0
@dage/krpano/build/components/WebVR/index.d.ts

@@ -0,0 +1,7 @@
+import { FC } from "react";
+export interface WebVRProps {
+    url: string;
+    [key: string]: unknown;
+}
+export declare const WebVR: FC<WebVRProps>;
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/components/WebVR/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/WebVR/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAQ,MAAM,OAAO,CAAC;AAIjC,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAiBD,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAiB/B,CAAC"}

+ 24 - 0
@dage/krpano/build/components/WebVR/index.js

@@ -0,0 +1,24 @@
+import { __rest } from "tslib";
+import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
+import { memo } from "react";
+import { Include, Plugin } from "..";
+import { is121Version } from "../../utils";
+const DEFAULT_WEBVR_121_CONFIG = {
+    keep: true,
+    devices: "webgl",
+};
+const DEFAULT_WEBVR_119_CONFIG = {
+    name: "WebVR",
+    keep: true,
+    devices: "html5",
+    "multireslock.desktop": true,
+    "multireslock.mobile.or.tablet": false,
+    mobilevr_support: true,
+    mobilevr_fake_support: true,
+};
+export const WebVR = memo((_a) => {
+    var { url } = _a, attrs = __rest(_a, ["url"]);
+    return (_jsxs(_Fragment, { children: [_jsx(Include, { url: url }), _jsx(Plugin, Object.assign({ name: "WebVR" }, Object.assign(Object.assign({}, (is121Version
+                ? DEFAULT_WEBVR_121_CONFIG
+                : DEFAULT_WEBVR_119_CONFIG)), attrs)))] }));
+});

+ 13 - 0
@dage/krpano/build/components/index.d.ts

@@ -0,0 +1,13 @@
+export * from "./Action";
+export * from "./Krpano";
+export * from "./Scene";
+export * from "./View";
+export * from "./HotSpot";
+export * from "./Autorotate";
+export * from "./Events";
+export * from "./Include";
+export * from "./Plugin";
+export * from "./Layer";
+export * from "./VideoScene";
+export * from "./Control";
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/components/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}

+ 12 - 0
@dage/krpano/build/components/index.js

@@ -0,0 +1,12 @@
+export * from "./Action";
+export * from "./Krpano";
+export * from "./Scene";
+export * from "./View";
+export * from "./HotSpot";
+export * from "./Autorotate";
+export * from "./Events";
+export * from "./Include";
+export * from "./Plugin";
+export * from "./Layer";
+export * from "./VideoScene";
+export * from "./Control";

+ 3 - 0
@dage/krpano/build/contexts/CurrentSceneContext.d.ts

@@ -0,0 +1,3 @@
+import React from "react";
+export declare const CurrentSceneContext: React.Context<string | null>;
+//# sourceMappingURL=CurrentSceneContext.d.ts.map

+ 1 - 0
@dage/krpano/build/contexts/CurrentSceneContext.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"CurrentSceneContext.d.ts","sourceRoot":"","sources":["../../src/contexts/CurrentSceneContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,mBAAmB,8BAA2C,CAAC"}

+ 2 - 0
@dage/krpano/build/contexts/CurrentSceneContext.js

@@ -0,0 +1,2 @@
+import React from "react";
+export const CurrentSceneContext = React.createContext(null);

+ 4 - 0
@dage/krpano/build/contexts/KrpanoRendererContext.d.ts

@@ -0,0 +1,4 @@
+import React from "react";
+import { KrpanoActionProxy } from "../models";
+export declare const KrpanoRendererContext: React.Context<KrpanoActionProxy | null>;
+//# sourceMappingURL=KrpanoRendererContext.d.ts.map

+ 1 - 0
@dage/krpano/build/contexts/KrpanoRendererContext.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"KrpanoRendererContext.d.ts","sourceRoot":"","sources":["../../src/contexts/KrpanoRendererContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,qBAAqB,yCACmB,CAAC"}

+ 2 - 0
@dage/krpano/build/contexts/KrpanoRendererContext.js

@@ -0,0 +1,2 @@
+import React from "react";
+export const KrpanoRendererContext = React.createContext(null);

+ 10 - 0
@dage/krpano/build/contexts/VideoSceneContext.d.ts

@@ -0,0 +1,10 @@
+import React from "react";
+export interface IVideoSceneContext {
+    /**
+     * 播放中,如果设置则 pluginAttrs.pausedonstart 失效
+     * @default true
+     */
+    playing: boolean;
+}
+export declare const VideoSceneContext: React.Context<IVideoSceneContext>;
+//# sourceMappingURL=VideoSceneContext.d.ts.map

+ 1 - 0
@dage/krpano/build/contexts/VideoSceneContext.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"VideoSceneContext.d.ts","sourceRoot":"","sources":["../../src/contexts/VideoSceneContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,iBAAiB,mCAE5B,CAAC"}

+ 4 - 0
@dage/krpano/build/contexts/VideoSceneContext.js

@@ -0,0 +1,4 @@
+import React from "react";
+export const VideoSceneContext = React.createContext({
+    playing: true,
+});

+ 3 - 0
@dage/krpano/build/contexts/index.d.ts

@@ -0,0 +1,3 @@
+export * from "./CurrentSceneContext";
+export * from "./KrpanoRendererContext";
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/contexts/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}

+ 2 - 0
@dage/krpano/build/contexts/index.js

@@ -0,0 +1,2 @@
+export * from "./CurrentSceneContext";
+export * from "./KrpanoRendererContext";

+ 3 - 0
@dage/krpano/build/hooks/index.d.ts

@@ -0,0 +1,3 @@
+export * from "./useEventCallback";
+export * from "./useMounted";
+//# sourceMappingURL=index.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/index.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}

+ 2 - 0
@dage/krpano/build/hooks/index.js

@@ -0,0 +1,2 @@
+export * from "./useEventCallback";
+export * from "./useMounted";

+ 2 - 0
@dage/krpano/build/hooks/useCreate.d.ts

@@ -0,0 +1,2 @@
+export declare function useMounted(cb: Function): void;
+//# sourceMappingURL=useCreate.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/useCreate.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"useCreate.d.ts","sourceRoot":"","sources":["../../src/hooks/useCreate.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,QAStC"}

+ 10 - 0
@dage/krpano/build/hooks/useCreate.js

@@ -0,0 +1,10 @@
+import { useEffect, useRef } from "react";
+export function useMounted(cb) {
+    const initialized = useRef(false);
+    useEffect(() => {
+        if (!initialized.current) {
+            initialized.current = true;
+            cb();
+        }
+    }, []);
+}

+ 1 - 0
@dage/krpano/build/hooks/useCurrentScene.d.ts

@@ -0,0 +1 @@
+//# sourceMappingURL=useCurrentScene.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/useCurrentScene.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"useCurrentScene.d.ts","sourceRoot":"","sources":["../../src/hooks/useCurrentScene.ts"],"names":[],"mappings":""}

+ 1 - 0
@dage/krpano/build/hooks/useCurrentScene.js

@@ -0,0 +1 @@
+"use strict";

+ 3 - 0
@dage/krpano/build/hooks/useEventCallback.d.ts

@@ -0,0 +1,3 @@
+/// <reference types="react" />
+export declare function useEventCallback<T>(callback: T): React.MutableRefObject<T>;
+//# sourceMappingURL=useEventCallback.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/useEventCallback.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"useEventCallback.d.ts","sourceRoot":"","sources":["../../src/hooks/useEventCallback.ts"],"names":[],"mappings":";AAEA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAQ1E"}

+ 8 - 0
@dage/krpano/build/hooks/useEventCallback.js

@@ -0,0 +1,8 @@
+import { useLayoutEffect, useRef } from "react";
+export function useEventCallback(callback) {
+    const callbackRef = useRef(callback);
+    useLayoutEffect(() => {
+        callbackRef.current = callback;
+    }, [callback]);
+    return callbackRef;
+}

+ 2 - 0
@dage/krpano/build/hooks/useMounted.d.ts

@@ -0,0 +1,2 @@
+export declare function useMounted(cb: Function): void;
+//# sourceMappingURL=useMounted.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/useMounted.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"useMounted.d.ts","sourceRoot":"","sources":["../../src/hooks/useMounted.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,QAStC"}

+ 10 - 0
@dage/krpano/build/hooks/useMounted.js

@@ -0,0 +1,10 @@
+import { useEffect, useRef } from "react";
+export function useMounted(cb) {
+    const initialized = useRef(false);
+    useEffect(() => {
+        if (!initialized.current) {
+            initialized.current = true;
+            cb();
+        }
+    }, []);
+}

+ 1 - 0
@dage/krpano/build/hooks/useSceneState.d.ts

@@ -0,0 +1 @@
+//# sourceMappingURL=useSceneState.d.ts.map

+ 1 - 0
@dage/krpano/build/hooks/useSceneState.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"useSceneState.d.ts","sourceRoot":"","sources":["../../src/hooks/useSceneState.ts"],"names":[],"mappings":""}

+ 0 - 0
@dage/krpano/build/hooks/useSceneState.js


Някои файлове не бяха показани, защото твърде много файлове са промени