@sepveneto/dnde 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -125,7 +125,9 @@ declare const _default: Vue.DefineComponent<Vue.ExtractPropTypes<{
125
125
  _view: "page";
126
126
  list: any[];
127
127
  }): void;
128
- }, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {}, string, Vue.PublicProps, Readonly<Vue.ExtractPropTypes<{
128
+ }, {}, {}, {}, Vue.ComponentOptionsMixin, Vue.ComponentOptionsMixin, {
129
+ change: (...args: any[]) => void;
130
+ }, string, Vue.PublicProps, Readonly<Vue.ExtractPropTypes<{
129
131
  readonly remoteUrl: {
130
132
  readonly type: StringConstructor;
131
133
  readonly required: true;
@@ -138,7 +140,9 @@ declare const _default: Vue.DefineComponent<Vue.ExtractPropTypes<{
138
140
  readonly type: Vue.PropType<Record<string, any>>;
139
141
  readonly default: () => {};
140
142
  };
141
- }>> & Readonly<{}>, {
143
+ }>> & Readonly<{
144
+ onChange?: ((...args: any[]) => any) | undefined;
145
+ }>, {
142
146
  readonly widgets: import("./store").LikeWidget[];
143
147
  readonly extra: Record<string, any>;
144
148
  }, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
package/dist/editor.js CHANGED
@@ -18013,7 +18013,7 @@ function apply(func, thisArg, args) {
18013
18013
  * _.times(2, _.noop);
18014
18014
  * // => [undefined, undefined]
18015
18015
  */
18016
- function noop$2() {
18016
+ function noop$3() {
18017
18017
  // No operation performed.
18018
18018
  }
18019
18019
 
@@ -22651,7 +22651,7 @@ var INFINITY$1 = 1 / 0;
22651
22651
  * @param {Array} values The values to add to the set.
22652
22652
  * @returns {Object} Returns the new set.
22653
22653
  */
22654
- var createSet = !(Set$1 && (1 / setToArray(new Set$1([,-0]))[1]) == INFINITY$1) ? noop$2 : function(values) {
22654
+ var createSet = !(Set$1 && (1 / setToArray(new Set$1([,-0]))[1]) == INFINITY$1) ? noop$3 : function(values) {
22655
22655
  return new Set$1(values);
22656
22656
  };
22657
22657
 
@@ -22786,7 +22786,7 @@ const isDef = (val) => typeof val !== "undefined";
22786
22786
  const isFunction = (val) => typeof val === "function";
22787
22787
  const isString$1 = (val) => typeof val === "string";
22788
22788
  const clamp$1 = (n, min, max) => Math.min(max, Math.max(min, n));
22789
- const noop$1 = () => {
22789
+ const noop$2 = () => {
22790
22790
  };
22791
22791
  const isIOS = isClient$1 && ((_a$2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a$2.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
22792
22792
 
@@ -22794,7 +22794,7 @@ function resolveUnref(r) {
22794
22794
  return typeof r === "function" ? r() : unref(r);
22795
22795
  }
22796
22796
 
22797
- function createFilterWrapper(filter, fn) {
22797
+ function createFilterWrapper$1(filter, fn) {
22798
22798
  function wrapper(...args) {
22799
22799
  return new Promise((resolve, reject) => {
22800
22800
  Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
@@ -22802,14 +22802,14 @@ function createFilterWrapper(filter, fn) {
22802
22802
  }
22803
22803
  return wrapper;
22804
22804
  }
22805
- function debounceFilter(ms, options = {}) {
22805
+ function debounceFilter$1(ms, options = {}) {
22806
22806
  let timer;
22807
22807
  let maxTimer;
22808
- let lastRejector = noop$1;
22808
+ let lastRejector = noop$2;
22809
22809
  const _clearTimeout = (timer2) => {
22810
22810
  clearTimeout(timer2);
22811
22811
  lastRejector();
22812
- lastRejector = noop$1;
22812
+ lastRejector = noop$2;
22813
22813
  };
22814
22814
  const filter = (invoke) => {
22815
22815
  const duration = resolveUnref(ms);
@@ -22847,14 +22847,14 @@ function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = fa
22847
22847
  let lastExec = 0;
22848
22848
  let timer;
22849
22849
  let isLeading = true;
22850
- let lastRejector = noop$1;
22850
+ let lastRejector = noop$2;
22851
22851
  let lastValue;
22852
22852
  const clear = () => {
22853
22853
  if (timer) {
22854
22854
  clearTimeout(timer);
22855
22855
  timer = void 0;
22856
22856
  lastRejector();
22857
- lastRejector = noop$1;
22857
+ lastRejector = noop$2;
22858
22858
  }
22859
22859
  };
22860
22860
  const filter = (_invoke) => {
@@ -22972,13 +22972,13 @@ function reactiveComputed(fn) {
22972
22972
  return toReactive(computed(fn));
22973
22973
  }
22974
22974
 
22975
- function useDebounceFn(fn, ms = 200, options = {}) {
22976
- return createFilterWrapper(debounceFilter(ms, options), fn);
22975
+ function useDebounceFn$1(fn, ms = 200, options = {}) {
22976
+ return createFilterWrapper$1(debounceFilter$1(ms, options), fn);
22977
22977
  }
22978
22978
 
22979
22979
  function refDebounced(value, ms = 200, options = {}) {
22980
22980
  const debounced = ref(value.value);
22981
- const updater = useDebounceFn(() => {
22981
+ const updater = useDebounceFn$1(() => {
22982
22982
  debounced.value = value.value;
22983
22983
  }, ms, options);
22984
22984
  watch(value, () => updater());
@@ -22986,7 +22986,7 @@ function refDebounced(value, ms = 200, options = {}) {
22986
22986
  }
22987
22987
 
22988
22988
  function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
22989
- return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
22989
+ return createFilterWrapper$1(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
22990
22990
  }
22991
22991
 
22992
22992
  function tryOnMounted(fn, sync = true) {
@@ -23057,7 +23057,7 @@ function useEventListener$1(...args) {
23057
23057
  [target, events, listeners, options] = args;
23058
23058
  }
23059
23059
  if (!target)
23060
- return noop$1;
23060
+ return noop$2;
23061
23061
  if (!Array.isArray(events))
23062
23062
  events = [events];
23063
23063
  if (!Array.isArray(listeners))
@@ -23094,7 +23094,7 @@ function onClickOutside(target, handler, options = {}) {
23094
23094
  return;
23095
23095
  if (isIOS && !_iOSWorkaround) {
23096
23096
  _iOSWorkaround = true;
23097
- Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop$1));
23097
+ Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop$2));
23098
23098
  }
23099
23099
  let shouldListen = true;
23100
23100
  const shouldIgnore = (event) => {
@@ -23351,7 +23351,7 @@ function useIntersectionObserver(target, callback, options = {}) {
23351
23351
  window = defaultWindow$1
23352
23352
  } = options;
23353
23353
  const isSupported = useSupported(() => window && "IntersectionObserver" in window);
23354
- let cleanup = noop$1;
23354
+ let cleanup = noop$2;
23355
23355
  const stopWatch = isSupported.value ? watch(() => ({
23356
23356
  el: unrefElement$1(target),
23357
23357
  root: unrefElement$1(root)
@@ -23367,9 +23367,9 @@ function useIntersectionObserver(target, callback, options = {}) {
23367
23367
  observer.observe(el);
23368
23368
  cleanup = () => {
23369
23369
  observer.disconnect();
23370
- cleanup = noop$1;
23370
+ cleanup = noop$2;
23371
23371
  };
23372
- }, { immediate: true, flush: "post" }) : noop$1;
23372
+ }, { immediate: true, flush: "post" }) : noop$2;
23373
23373
  const stop = () => {
23374
23374
  cleanup();
23375
23375
  stopWatch();
@@ -82334,10 +82334,71 @@ const isClient = typeof window !== "undefined" && typeof document !== "undefined
82334
82334
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
82335
82335
  const toString = Object.prototype.toString;
82336
82336
  const isObject = (val) => toString.call(val) === "[object Object]";
82337
+ const noop$1 = () => {
82338
+ };
82339
+
82340
+ function createFilterWrapper(filter, fn) {
82341
+ function wrapper(...args) {
82342
+ return new Promise((resolve, reject) => {
82343
+ Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
82344
+ });
82345
+ }
82346
+ return wrapper;
82347
+ }
82348
+ function debounceFilter(ms, options = {}) {
82349
+ let timer;
82350
+ let maxTimer;
82351
+ let lastRejector = noop$1;
82352
+ const _clearTimeout = (timer2) => {
82353
+ clearTimeout(timer2);
82354
+ lastRejector();
82355
+ lastRejector = noop$1;
82356
+ };
82357
+ let lastInvoker;
82358
+ const filter = (invoke) => {
82359
+ const duration = toValue(ms);
82360
+ const maxDuration = toValue(options.maxWait);
82361
+ if (timer)
82362
+ _clearTimeout(timer);
82363
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
82364
+ if (maxTimer) {
82365
+ _clearTimeout(maxTimer);
82366
+ maxTimer = null;
82367
+ }
82368
+ return Promise.resolve(invoke());
82369
+ }
82370
+ return new Promise((resolve, reject) => {
82371
+ lastRejector = options.rejectOnCancel ? reject : resolve;
82372
+ lastInvoker = invoke;
82373
+ if (maxDuration && !maxTimer) {
82374
+ maxTimer = setTimeout(() => {
82375
+ if (timer)
82376
+ _clearTimeout(timer);
82377
+ maxTimer = null;
82378
+ resolve(lastInvoker());
82379
+ }, maxDuration);
82380
+ }
82381
+ timer = setTimeout(() => {
82382
+ if (maxTimer)
82383
+ _clearTimeout(maxTimer);
82384
+ maxTimer = null;
82385
+ resolve(invoke());
82386
+ }, duration);
82387
+ });
82388
+ };
82389
+ return filter;
82390
+ }
82337
82391
  function toArray(value) {
82338
82392
  return Array.isArray(value) ? value : [value];
82339
82393
  }
82340
82394
 
82395
+ function useDebounceFn(fn, ms = 200, options = {}) {
82396
+ return createFilterWrapper(
82397
+ debounceFilter(ms, options),
82398
+ fn
82399
+ );
82400
+ }
82401
+
82341
82402
  function watchImmediate(source, cb, options) {
82342
82403
  return watch(
82343
82404
  source,
@@ -105495,7 +105556,7 @@ const useEditor = defineStore("editor", () => {
105495
105556
  }
105496
105557
  function setData(data) {
105497
105558
  const widget2 = app.widgetMap.get(data._view) || defaultPage;
105498
- const { style, list, data: props } = data;
105559
+ const { style, list = [], data: props } = data;
105499
105560
  const info = {
105500
105561
  props,
105501
105562
  style,
@@ -106796,9 +106857,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
106796
106857
  name: "widgets",
106797
106858
  entry: `${props.remoteUrl}/mf-manifest.json`
106798
106859
  }
106799
- // TODO: 重构后需要重新验证
106800
106860
  // 必须开启,否则从其它页面切换回编辑器会导致渲染异常
106801
- ]);
106861
+ ], { force: true });
106802
106862
  const ViewRender = loadFromRemote("widgets", "viewRender");
106803
106863
  app.setWidgets(props.widgets);
106804
106864
  const refConfigPanel = useTemplateRef("configPanelRef");
@@ -106894,7 +106954,9 @@ const App = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["styles", [_style_0]]]);
106894
106954
  const _sfc_main = /* @__PURE__ */ defineComponent({
106895
106955
  __name: "Editor",
106896
106956
  props: editorProps,
106897
- setup(__props, { expose: __expose }) {
106957
+ emits: ["change"],
106958
+ setup(__props, { expose: __expose, emit: __emit }) {
106959
+ const emit = __emit;
106898
106960
  runtimeExports.init({
106899
106961
  name: "editor",
106900
106962
  remotes: [],
@@ -106920,6 +106982,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
106920
106982
  }
106921
106983
  const editor = useEditor();
106922
106984
  editor.shadowRoot = useShadowRoot();
106985
+ const updateModelValue = useDebounceFn(() => {
106986
+ const data = editor.getData();
106987
+ emit("change", data);
106988
+ }, 1e3);
106989
+ watch(() => editor.rootNode, () => {
106990
+ updateModelValue();
106991
+ }, { deep: true });
106923
106992
  window.__shadowdom_css_runtime__ = async (tagLink) => {
106924
106993
  try {
106925
106994
  const res = await fetch(tagLink.href);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sepveneto/dnde",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "GPL",