@razaman2/reactive-view 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -159,7 +159,7 @@ var import_vue = require("vue");
159
159
 
160
160
  // package.json
161
161
  var name = "@razaman2/reactive-view";
162
- var version = "0.0.23";
162
+ var version = "0.0.25";
163
163
 
164
164
  // src/ReactiveView.ts
165
165
  var setup = {
@@ -221,10 +221,10 @@ var ReactiveView_default = {
221
221
  const ready = (0, import_vue.ref)(false);
222
222
  const instance = (0, import_vue.getCurrentInstance)();
223
223
  const deferred = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
224
- const state = typeof props.data === "function" ? props.data() : props.data;
225
- const async = state instanceof Promise;
224
+ const data = typeof props.data === "function" ? props.data() : props.data;
225
+ const async = data instanceof Promise;
226
226
  if (props.debug) {
227
- console.log("[ReactiveView]:", { props, context });
227
+ console.log("[ReactiveView]:", { props, context, isValid, ready, instance, deferred, data, async });
228
228
  }
229
229
  if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
230
230
  console.error("[ReactiveView]: defaultData is required for async data.");
@@ -236,14 +236,15 @@ var ReactiveView_default = {
236
236
  ((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
237
237
  );
238
238
  const datatype = Array.isArray(defaultData) ? [] : {};
239
- const data = async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? state : datatype;
240
239
  const config = {
241
- name: props.modelName,
240
+ data: (0, import_vue.reactive)(
241
+ import_object_manager.default.on(async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
242
+ ),
242
243
  defaultData: import_object_manager.default.on(defaultData).clone(),
243
- data: (0, import_vue.reactive)(import_object_manager.default.on(data).clone()),
244
244
  notifications: props.notifications,
245
245
  subscriptions: props.subscriptions,
246
- logging: props.logging
246
+ logging: props.logging,
247
+ name: props.modelName
247
248
  };
248
249
  const model = new Proxy(props.model ? typeof props.model === "function" ? props.model(config) : props.model : new import_data_manager.default(config), {
249
250
  get(target, key, receiver) {
@@ -270,8 +271,7 @@ var ReactiveView_default = {
270
271
  const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
271
272
  callback: context.attrs["onUpdate:data"]
272
273
  } : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
273
- console.log("log dataProp:", dataProp);
274
- (0, import_vue.watch)(typeof dataProp === "function" || (0, import_vue.isRef)(dataProp) ? dataProp : () => dataProp, (after, before) => {
274
+ (0, import_vue.watch)(typeof dataProp === "function" || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
275
275
  var _a3;
276
276
  const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
277
277
  if (typeof config2.callback === "function") {
@@ -281,13 +281,9 @@ var ReactiveView_default = {
281
281
  }
282
282
  }, config2.options);
283
283
  };
284
- if (async) {
285
- setTimeout(async () => {
286
- watchDataProp(await state);
287
- });
288
- } else {
289
- watchDataProp(state);
290
- }
284
+ setTimeout(async () => {
285
+ watchDataProp(await data);
286
+ });
291
287
  setTimeout(async () => {
292
288
  var _a2;
293
289
  ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
@@ -304,10 +300,11 @@ var ReactiveView_default = {
304
300
  const component = (0, import_vue.ref)({ parent: { self: instance.proxy }, self: { template, model, isValid } });
305
301
  if (access(component).ReactiveView) {
306
302
  component.value = [access(component)].reduce((options, parent) => {
307
- var _a2;
303
+ var _a2, _b2;
308
304
  while (parent) {
309
305
  if (typeof parent.setup === "function") {
310
- options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
306
+ const ups = parent.setup(component, options);
307
+ options = { parent: options, self: (_b2 = (_a2 = ups.value) != null ? _a2 : ups) != null ? _b2 : {} };
311
308
  if (access(parent.$parent).ReactiveView) {
312
309
  break;
313
310
  } else {
package/dist/index.mjs CHANGED
@@ -115,11 +115,11 @@ import { createVNode as createVNode2, isRef as isRef2 } from "vue";
115
115
  // src/ReactiveView.ts
116
116
  import ObjectManager from "@razaman2/object-manager";
117
117
  import DataManager from "@razaman2/data-manager";
118
- import { ref, reactive, watch, isRef, createVNode, getCurrentInstance } from "vue";
118
+ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstance } from "vue";
119
119
 
120
120
  // package.json
121
121
  var name = "@razaman2/reactive-view";
122
- var version = "0.0.23";
122
+ var version = "0.0.25";
123
123
 
124
124
  // src/ReactiveView.ts
125
125
  var setup = {
@@ -181,10 +181,10 @@ var ReactiveView_default = {
181
181
  const ready = ref(false);
182
182
  const instance = getCurrentInstance();
183
183
  const deferred = ref(typeof props.defer === "function" ? props.defer() : props.defer);
184
- const state = typeof props.data === "function" ? props.data() : props.data;
185
- const async = state instanceof Promise;
184
+ const data = typeof props.data === "function" ? props.data() : props.data;
185
+ const async = data instanceof Promise;
186
186
  if (props.debug) {
187
- console.log("[ReactiveView]:", { props, context });
187
+ console.log("[ReactiveView]:", { props, context, isValid, ready, instance, deferred, data, async });
188
188
  }
189
189
  if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
190
190
  console.error("[ReactiveView]: defaultData is required for async data.");
@@ -196,14 +196,15 @@ var ReactiveView_default = {
196
196
  ((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
197
197
  );
198
198
  const datatype = Array.isArray(defaultData) ? [] : {};
199
- const data = async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? state : datatype;
200
199
  const config = {
201
- name: props.modelName,
200
+ data: reactive(
201
+ ObjectManager.on(async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
202
+ ),
202
203
  defaultData: ObjectManager.on(defaultData).clone(),
203
- data: reactive(ObjectManager.on(data).clone()),
204
204
  notifications: props.notifications,
205
205
  subscriptions: props.subscriptions,
206
- logging: props.logging
206
+ logging: props.logging,
207
+ name: props.modelName
207
208
  };
208
209
  const model = new Proxy(props.model ? typeof props.model === "function" ? props.model(config) : props.model : new DataManager(config), {
209
210
  get(target, key, receiver) {
@@ -230,8 +231,7 @@ var ReactiveView_default = {
230
231
  const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
231
232
  callback: context.attrs["onUpdate:data"]
232
233
  } : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
233
- console.log("log dataProp:", dataProp);
234
- watch(typeof dataProp === "function" || isRef(dataProp) ? dataProp : () => dataProp, (after, before) => {
234
+ watch(typeof dataProp === "function" || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
235
235
  var _a3;
236
236
  const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
237
237
  if (typeof config2.callback === "function") {
@@ -241,13 +241,9 @@ var ReactiveView_default = {
241
241
  }
242
242
  }, config2.options);
243
243
  };
244
- if (async) {
245
- setTimeout(async () => {
246
- watchDataProp(await state);
247
- });
248
- } else {
249
- watchDataProp(state);
250
- }
244
+ setTimeout(async () => {
245
+ watchDataProp(await data);
246
+ });
251
247
  setTimeout(async () => {
252
248
  var _a2;
253
249
  ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
@@ -264,10 +260,11 @@ var ReactiveView_default = {
264
260
  const component = ref({ parent: { self: instance.proxy }, self: { template, model, isValid } });
265
261
  if (access(component).ReactiveView) {
266
262
  component.value = [access(component)].reduce((options, parent) => {
267
- var _a2;
263
+ var _a2, _b2;
268
264
  while (parent) {
269
265
  if (typeof parent.setup === "function") {
270
- options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
266
+ const ups = parent.setup(component, options);
267
+ options = { parent: options, self: (_b2 = (_a2 = ups.value) != null ? _a2 : ups) != null ? _b2 : {} };
271
268
  if (access(parent.$parent).ReactiveView) {
272
269
  break;
273
270
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razaman2/reactive-view",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "This library enables you to build vue apps in an object oriented way. It provides a convenient approach to extend and override ui components. It provides a built in eventing system along with component data management.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",