@razaman2/reactive-view 0.0.34-beta.4 → 0.0.34-beta.6
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 +23 -16
- package/dist/index.mjs +23 -16
- 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.6";
|
|
172
172
|
|
|
173
173
|
// src/ReactiveView.ts
|
|
174
174
|
var setup = {
|
|
@@ -214,7 +214,16 @@ 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
|
+
const diff = (before, after) => {
|
|
219
|
+
const change = after.paths().reduce((change2, path) => {
|
|
220
|
+
if (before.get(path) !== after.get(path)) {
|
|
221
|
+
change2.set(path, after.get(path));
|
|
222
|
+
}
|
|
223
|
+
return change2;
|
|
224
|
+
}, import_object_manager.default.on({}));
|
|
225
|
+
return { before: before.get(), after: after.get(), change: change.get() };
|
|
226
|
+
};
|
|
218
227
|
const template = (component2, vue2) => {
|
|
219
228
|
return (0, import_vue.createVNode)(
|
|
220
229
|
"div",
|
|
@@ -226,21 +235,21 @@ var ReactiveView_default = {
|
|
|
226
235
|
};
|
|
227
236
|
const isValid = (0, import_vue.ref)(false);
|
|
228
237
|
const isReady = (0, import_vue.ref)(false);
|
|
229
|
-
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
230
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
231
|
-
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
238
|
+
const isFunctionData = ["Function"].includes((_a = props.data) == null ? void 0 : _a.constructor.name);
|
|
239
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes((_b = props.data) == null ? void 0 : _b.constructor.name);
|
|
240
|
+
const isPromiseData = ["Promise"].includes((_c = props.data) == null ? void 0 : _c.constructor.name) || isAsyncFunctionData;
|
|
232
241
|
const defer = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
233
242
|
const vue = (0, import_vue.getCurrentInstance)();
|
|
234
243
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
235
244
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
236
245
|
}
|
|
237
246
|
const defaultData = props.getDefaultData(
|
|
238
|
-
((
|
|
247
|
+
((_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) ? [] : {} : {}
|
|
239
248
|
);
|
|
240
249
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
241
250
|
const config = {
|
|
242
251
|
data: (0, import_vue.reactive)(import_object_manager.default.on(
|
|
243
|
-
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((
|
|
252
|
+
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
|
|
244
253
|
).clone()),
|
|
245
254
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
246
255
|
notifications: props.notifications,
|
|
@@ -256,8 +265,8 @@ var ReactiveView_default = {
|
|
|
256
265
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
257
266
|
if (typeof beforeSetData === "function") {
|
|
258
267
|
const before = target.getData();
|
|
259
|
-
const after =
|
|
260
|
-
if (beforeSetData(
|
|
268
|
+
const after = params.length ? import_object_manager.default.on(datatype).set(...params) : import_object_manager.default.on(datatype).set(defaultData);
|
|
269
|
+
if (beforeSetData(diff(import_object_manager.default.on(before), after), target)) {
|
|
261
270
|
target[key](...params);
|
|
262
271
|
}
|
|
263
272
|
} else {
|
|
@@ -285,9 +294,8 @@ var ReactiveView_default = {
|
|
|
285
294
|
}
|
|
286
295
|
(0, import_vue.watch)(isFunctionData || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
287
296
|
var _a3;
|
|
288
|
-
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
289
297
|
if (typeof config2.callback === "function") {
|
|
290
|
-
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
298
|
+
model.replaceData((_a3 = config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component })) != null ? _a3 : after);
|
|
291
299
|
} else {
|
|
292
300
|
model.replaceData(after);
|
|
293
301
|
}
|
|
@@ -297,15 +305,14 @@ var ReactiveView_default = {
|
|
|
297
305
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
298
306
|
callback: context.attrs["onUpdate:model"],
|
|
299
307
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
300
|
-
deep: (
|
|
301
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
302
|
-
} : (
|
|
308
|
+
deep: (_g = context.attrs["model:deep"]) != null ? _g : true
|
|
309
|
+
}, 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)
|
|
310
|
+
} : (_i = context.attrs["onUpdate:model"]) != null ? _i : {};
|
|
303
311
|
if (context.attrs["model:log"]) {
|
|
304
312
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
305
313
|
}
|
|
306
314
|
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
307
|
-
|
|
308
|
-
config2.callback(diff, { component });
|
|
315
|
+
config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
309
316
|
}, config2.options);
|
|
310
317
|
}
|
|
311
318
|
setTimeout(async () => {
|
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.6";
|
|
129
129
|
|
|
130
130
|
// src/ReactiveView.ts
|
|
131
131
|
var setup = {
|
|
@@ -171,7 +171,16 @@ 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
|
+
const diff = (before, after) => {
|
|
176
|
+
const change = after.paths().reduce((change2, path) => {
|
|
177
|
+
if (before.get(path) !== after.get(path)) {
|
|
178
|
+
change2.set(path, after.get(path));
|
|
179
|
+
}
|
|
180
|
+
return change2;
|
|
181
|
+
}, ObjectManager.on({}));
|
|
182
|
+
return { before: before.get(), after: after.get(), change: change.get() };
|
|
183
|
+
};
|
|
175
184
|
const template = (component2, vue2) => {
|
|
176
185
|
return createVNode(
|
|
177
186
|
"div",
|
|
@@ -183,21 +192,21 @@ var ReactiveView_default = {
|
|
|
183
192
|
};
|
|
184
193
|
const isValid = ref(false);
|
|
185
194
|
const isReady = ref(false);
|
|
186
|
-
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
187
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
188
|
-
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
195
|
+
const isFunctionData = ["Function"].includes((_a = props.data) == null ? void 0 : _a.constructor.name);
|
|
196
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes((_b = props.data) == null ? void 0 : _b.constructor.name);
|
|
197
|
+
const isPromiseData = ["Promise"].includes((_c = props.data) == null ? void 0 : _c.constructor.name) || isAsyncFunctionData;
|
|
189
198
|
const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
190
199
|
const vue = getCurrentInstance();
|
|
191
200
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
192
201
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
193
202
|
}
|
|
194
203
|
const defaultData = props.getDefaultData(
|
|
195
|
-
((
|
|
204
|
+
((_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) ? [] : {} : {}
|
|
196
205
|
);
|
|
197
206
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
198
207
|
const config = {
|
|
199
208
|
data: reactive(ObjectManager.on(
|
|
200
|
-
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((
|
|
209
|
+
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? props.data : datatype
|
|
201
210
|
).clone()),
|
|
202
211
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
203
212
|
notifications: props.notifications,
|
|
@@ -213,8 +222,8 @@ var ReactiveView_default = {
|
|
|
213
222
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
214
223
|
if (typeof beforeSetData === "function") {
|
|
215
224
|
const before = target.getData();
|
|
216
|
-
const after =
|
|
217
|
-
if (beforeSetData(
|
|
225
|
+
const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
|
|
226
|
+
if (beforeSetData(diff(ObjectManager.on(before), after), target)) {
|
|
218
227
|
target[key](...params);
|
|
219
228
|
}
|
|
220
229
|
} else {
|
|
@@ -242,9 +251,8 @@ var ReactiveView_default = {
|
|
|
242
251
|
}
|
|
243
252
|
watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
244
253
|
var _a3;
|
|
245
|
-
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
246
254
|
if (typeof config2.callback === "function") {
|
|
247
|
-
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
255
|
+
model.replaceData((_a3 = config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a3 : after);
|
|
248
256
|
} else {
|
|
249
257
|
model.replaceData(after);
|
|
250
258
|
}
|
|
@@ -254,15 +262,14 @@ var ReactiveView_default = {
|
|
|
254
262
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
255
263
|
callback: context.attrs["onUpdate:model"],
|
|
256
264
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
257
|
-
deep: (
|
|
258
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
259
|
-
} : (
|
|
265
|
+
deep: (_g = context.attrs["model:deep"]) != null ? _g : true
|
|
266
|
+
}, 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)
|
|
267
|
+
} : (_i = context.attrs["onUpdate:model"]) != null ? _i : {};
|
|
260
268
|
if (context.attrs["model:log"]) {
|
|
261
269
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
262
270
|
}
|
|
263
271
|
watch(() => model.getData(), (after, before) => {
|
|
264
|
-
|
|
265
|
-
config2.callback(diff, { component });
|
|
272
|
+
config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
266
273
|
}, config2.options);
|
|
267
274
|
}
|
|
268
275
|
setTimeout(async () => {
|
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.6",
|
|
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",
|