@razaman2/reactive-view 0.0.34-beta.5 → 0.0.34-beta.7
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 +29 -18
- package/dist/index.mjs +29 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -168,7 +168,7 @@ var import_vue = require("vue");
|
|
|
168
168
|
|
|
169
169
|
// package.json
|
|
170
170
|
var name = "@razaman2/reactive-view";
|
|
171
|
-
var version = "0.0.34-beta.
|
|
171
|
+
var version = "0.0.34-beta.7";
|
|
172
172
|
|
|
173
173
|
// src/ReactiveView.ts
|
|
174
174
|
var setup = {
|
|
@@ -214,7 +214,7 @@ var ReactiveView_default = {
|
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
setup(props, context) {
|
|
217
|
-
var _a, _b, _c, _d, _e, _f;
|
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
218
218
|
const diff = (before, after) => {
|
|
219
219
|
const change = after.paths().reduce((change2, path) => {
|
|
220
220
|
if (before.get(path) !== after.get(path)) {
|
|
@@ -224,6 +224,13 @@ var ReactiveView_default = {
|
|
|
224
224
|
}, import_object_manager.default.on({}));
|
|
225
225
|
return { before: before.get(), after: after.get(), change: change.get() };
|
|
226
226
|
};
|
|
227
|
+
const dataPath = (path) => {
|
|
228
|
+
try {
|
|
229
|
+
return context.attrs["data:path"](path);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
return path;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
227
234
|
const template = (component2, vue2) => {
|
|
228
235
|
return (0, import_vue.createVNode)(
|
|
229
236
|
"div",
|
|
@@ -235,21 +242,21 @@ var ReactiveView_default = {
|
|
|
235
242
|
};
|
|
236
243
|
const isValid = (0, import_vue.ref)(false);
|
|
237
244
|
const isReady = (0, import_vue.ref)(false);
|
|
238
|
-
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
239
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
240
|
-
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
245
|
+
const isFunctionData = ["Function"].includes((_a = props.data) == null ? void 0 : _a.constructor.name);
|
|
246
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes((_b = props.data) == null ? void 0 : _b.constructor.name);
|
|
247
|
+
const isPromiseData = ["Promise"].includes((_c = props.data) == null ? void 0 : _c.constructor.name) || isAsyncFunctionData;
|
|
241
248
|
const defer = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
242
249
|
const vue = (0, import_vue.getCurrentInstance)();
|
|
243
250
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
244
251
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
245
252
|
}
|
|
246
253
|
const defaultData = props.getDefaultData(
|
|
247
|
-
((
|
|
254
|
+
((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_e = vue.vnode.props) == null ? void 0 : _e.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
248
255
|
);
|
|
249
256
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
250
257
|
const config = {
|
|
251
258
|
data: (0, import_vue.reactive)(import_object_manager.default.on(
|
|
252
|
-
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((
|
|
259
|
+
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? props.data : datatype
|
|
253
260
|
).clone()),
|
|
254
261
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
255
262
|
notifications: props.notifications,
|
|
@@ -279,15 +286,17 @@ var ReactiveView_default = {
|
|
|
279
286
|
}
|
|
280
287
|
}
|
|
281
288
|
});
|
|
282
|
-
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
289
|
+
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, dataPath, isValid } });
|
|
283
290
|
if (props.debug) {
|
|
284
291
|
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
285
292
|
}
|
|
286
293
|
const watchDataProp = (dataProp) => {
|
|
287
|
-
var _a2, _b2, _c2;
|
|
294
|
+
var _a2, _b2, _c2, _d2;
|
|
288
295
|
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
289
296
|
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
290
|
-
options: Object.assign(__spreadValues(__spreadValues(
|
|
297
|
+
options: Object.assign(__spreadValues(__spreadValues({
|
|
298
|
+
deep: (_c2 = context.attrs["data:deep"]) != null ? _c2 : true
|
|
299
|
+
}, context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {}), context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}), ((_d2 = context.attrs["onUpdate:data"]) != null ? _d2 : {}).options)
|
|
291
300
|
};
|
|
292
301
|
if (context.attrs["data:log"]) {
|
|
293
302
|
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
@@ -305,9 +314,9 @@ var ReactiveView_default = {
|
|
|
305
314
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
306
315
|
callback: context.attrs["onUpdate:model"],
|
|
307
316
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
308
|
-
deep: (
|
|
309
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
310
|
-
} : (
|
|
317
|
+
deep: (_g = context.attrs["model:deep"]) != null ? _g : true
|
|
318
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_h = context.attrs["onUpdate:model"]) != null ? _h : {}).options)
|
|
319
|
+
} : (_i = context.attrs["onUpdate:model"]) != null ? _i : {};
|
|
311
320
|
if (context.attrs["model:log"]) {
|
|
312
321
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
313
322
|
}
|
|
@@ -315,11 +324,13 @@ var ReactiveView_default = {
|
|
|
315
324
|
config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
316
325
|
}, config2.options);
|
|
317
326
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
if (isFunctionData || isPromiseData) {
|
|
328
|
+
setTimeout(async () => {
|
|
329
|
+
var _a2;
|
|
330
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
331
|
+
watchDataProp(data);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
323
334
|
setTimeout(async () => {
|
|
324
335
|
var _a2;
|
|
325
336
|
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
package/dist/index.mjs
CHANGED
|
@@ -125,7 +125,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
|
|
|
125
125
|
|
|
126
126
|
// package.json
|
|
127
127
|
var name = "@razaman2/reactive-view";
|
|
128
|
-
var version = "0.0.34-beta.
|
|
128
|
+
var version = "0.0.34-beta.7";
|
|
129
129
|
|
|
130
130
|
// src/ReactiveView.ts
|
|
131
131
|
var setup = {
|
|
@@ -171,7 +171,7 @@ var ReactiveView_default = {
|
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
setup(props, context) {
|
|
174
|
-
var _a, _b, _c, _d, _e, _f;
|
|
174
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
175
175
|
const diff = (before, after) => {
|
|
176
176
|
const change = after.paths().reduce((change2, path) => {
|
|
177
177
|
if (before.get(path) !== after.get(path)) {
|
|
@@ -181,6 +181,13 @@ var ReactiveView_default = {
|
|
|
181
181
|
}, ObjectManager.on({}));
|
|
182
182
|
return { before: before.get(), after: after.get(), change: change.get() };
|
|
183
183
|
};
|
|
184
|
+
const dataPath = (path) => {
|
|
185
|
+
try {
|
|
186
|
+
return context.attrs["data:path"](path);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
return path;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
184
191
|
const template = (component2, vue2) => {
|
|
185
192
|
return createVNode(
|
|
186
193
|
"div",
|
|
@@ -192,21 +199,21 @@ var ReactiveView_default = {
|
|
|
192
199
|
};
|
|
193
200
|
const isValid = ref(false);
|
|
194
201
|
const isReady = ref(false);
|
|
195
|
-
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
196
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
197
|
-
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
202
|
+
const isFunctionData = ["Function"].includes((_a = props.data) == null ? void 0 : _a.constructor.name);
|
|
203
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes((_b = props.data) == null ? void 0 : _b.constructor.name);
|
|
204
|
+
const isPromiseData = ["Promise"].includes((_c = props.data) == null ? void 0 : _c.constructor.name) || isAsyncFunctionData;
|
|
198
205
|
const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
199
206
|
const vue = getCurrentInstance();
|
|
200
207
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
201
208
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
202
209
|
}
|
|
203
210
|
const defaultData = props.getDefaultData(
|
|
204
|
-
((
|
|
211
|
+
((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_e = vue.vnode.props) == null ? void 0 : _e.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
205
212
|
);
|
|
206
213
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
207
214
|
const config = {
|
|
208
215
|
data: reactive(ObjectManager.on(
|
|
209
|
-
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((
|
|
216
|
+
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? props.data : datatype
|
|
210
217
|
).clone()),
|
|
211
218
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
212
219
|
notifications: props.notifications,
|
|
@@ -236,15 +243,17 @@ var ReactiveView_default = {
|
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
});
|
|
239
|
-
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
246
|
+
const component = ref({ parent: { self: vue.proxy }, self: { template, model, dataPath, isValid } });
|
|
240
247
|
if (props.debug) {
|
|
241
248
|
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
242
249
|
}
|
|
243
250
|
const watchDataProp = (dataProp) => {
|
|
244
|
-
var _a2, _b2, _c2;
|
|
251
|
+
var _a2, _b2, _c2, _d2;
|
|
245
252
|
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
246
253
|
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
247
|
-
options: Object.assign(__spreadValues(__spreadValues(
|
|
254
|
+
options: Object.assign(__spreadValues(__spreadValues({
|
|
255
|
+
deep: (_c2 = context.attrs["data:deep"]) != null ? _c2 : true
|
|
256
|
+
}, context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {}), context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}), ((_d2 = context.attrs["onUpdate:data"]) != null ? _d2 : {}).options)
|
|
248
257
|
};
|
|
249
258
|
if (context.attrs["data:log"]) {
|
|
250
259
|
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
@@ -262,9 +271,9 @@ var ReactiveView_default = {
|
|
|
262
271
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
263
272
|
callback: context.attrs["onUpdate:model"],
|
|
264
273
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
265
|
-
deep: (
|
|
266
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
267
|
-
} : (
|
|
274
|
+
deep: (_g = context.attrs["model:deep"]) != null ? _g : true
|
|
275
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_h = context.attrs["onUpdate:model"]) != null ? _h : {}).options)
|
|
276
|
+
} : (_i = context.attrs["onUpdate:model"]) != null ? _i : {};
|
|
268
277
|
if (context.attrs["model:log"]) {
|
|
269
278
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
270
279
|
}
|
|
@@ -272,11 +281,13 @@ var ReactiveView_default = {
|
|
|
272
281
|
config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
273
282
|
}, config2.options);
|
|
274
283
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
284
|
+
if (isFunctionData || isPromiseData) {
|
|
285
|
+
setTimeout(async () => {
|
|
286
|
+
var _a2;
|
|
287
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
288
|
+
watchDataProp(data);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
280
291
|
setTimeout(async () => {
|
|
281
292
|
var _a2;
|
|
282
293
|
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.34-beta.
|
|
3
|
+
"version": "0.0.34-beta.7",
|
|
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",
|