index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var __create = Object.create;
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __getProtoOf = Object.getPrototypeOf;
  6. var __hasOwnProp = Object.prototype.hasOwnProperty;
  7. var __export = (target, all) => {
  8. for (var name in all)
  9. __defProp(target, name, { get: all[name], enumerable: true });
  10. };
  11. var __copyProps = (to, from, except, desc) => {
  12. if (from && typeof from === "object" || typeof from === "function") {
  13. for (let key of __getOwnPropNames(from))
  14. if (!__hasOwnProp.call(to, key) && key !== except)
  15. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  16. }
  17. return to;
  18. };
  19. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  20. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  21. mod
  22. ));
  23. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  24. var stdin_exports = {};
  25. __export(stdin_exports, {
  26. Lazyload: () => Lazyload
  27. });
  28. module.exports = __toCommonJS(stdin_exports);
  29. var import_lazy = __toESM(require("./lazy"));
  30. var import_lazy_component = __toESM(require("./lazy-component"));
  31. var import_lazy_container = __toESM(require("./lazy-container"));
  32. var import_lazy_image = __toESM(require("./lazy-image"));
  33. const Lazyload = {
  34. install(app, options = {}) {
  35. const LazyClass = (0, import_lazy.default)();
  36. const lazy = new LazyClass(options);
  37. const lazyContainer = new import_lazy_container.default({ lazy });
  38. app.config.globalProperties.$Lazyload = lazy;
  39. if (options.lazyComponent) {
  40. app.component("LazyComponent", (0, import_lazy_component.default)(lazy));
  41. }
  42. if (options.lazyImage) {
  43. app.component("LazyImage", (0, import_lazy_image.default)(lazy));
  44. }
  45. app.directive("lazy", {
  46. beforeMount: lazy.add.bind(lazy),
  47. updated: lazy.update.bind(lazy),
  48. unmounted: lazy.remove.bind(lazy)
  49. });
  50. app.directive("lazy-container", {
  51. beforeMount: lazyContainer.bind.bind(lazyContainer),
  52. updated: lazyContainer.update.bind(lazyContainer),
  53. unmounted: lazyContainer.unbind.bind(lazyContainer)
  54. });
  55. }
  56. };