phecda-vue 3.0.0-beta.17 → 3.0.0-beta.18
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.d.ts +7 -7
- package/dist/index.js +20 -20
- package/dist/index.mjs +20 -20
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -50,17 +50,17 @@ declare function isObject(o: any): boolean;
|
|
|
50
50
|
declare function mergeReactiveObjects<T extends Record<any, unknown> | Map<unknown, unknown> | Set<unknown>>(target: T, patchToApply: DeepPartial<T>): T;
|
|
51
51
|
declare function createSharedReactive<F extends (...args: any) => any>(composable: F): () => ReturnType<F>;
|
|
52
52
|
|
|
53
|
-
declare function useO<T extends Construct>(
|
|
54
|
-
declare function useRaw<T extends Construct>(
|
|
55
|
-
declare function usePatch<T extends Construct>(
|
|
56
|
-
declare function useR<T extends Construct>(
|
|
57
|
-
declare function useV<T extends Construct>(
|
|
53
|
+
declare function useO<T extends Construct>(model: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
54
|
+
declare function useRaw<T extends Construct>(model: T): InstanceType<T>;
|
|
55
|
+
declare function usePatch<T extends Construct>(model: T, Data: DeepPartial<InstanceType<T>>): void;
|
|
56
|
+
declare function useR<T extends Construct>(model: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
57
|
+
declare function useV<T extends Construct>(model: T): ReplaceInstanceValues<InstanceType<T>>;
|
|
58
58
|
declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event: Events[Key]) => void): {
|
|
59
59
|
emit: (arg: Events[Key]) => void;
|
|
60
60
|
cancel: () => void;
|
|
61
61
|
};
|
|
62
|
-
declare function initialize<M extends Construct>(
|
|
62
|
+
declare function initialize<M extends Construct>(model: M, deleteOtherProperty?: boolean): InstanceType<M> | void;
|
|
63
63
|
|
|
64
|
-
declare function Shallow(
|
|
64
|
+
declare function Shallow(model: any): void;
|
|
65
65
|
|
|
66
66
|
export { DeepPartial, RE, Raw, RawSymbol, ReplaceInstanceValues, SchemaToObj, Shallow, createFilter, createPhecda, createSharedReactive, initialize, isObject, markRaw, mergeReactiveObjects, phecdaSymbol, useEvent, useO, usePatch, useR, useRaw, useV };
|
package/dist/index.js
CHANGED
|
@@ -222,40 +222,40 @@ __name(createSharedReactive, "createSharedReactive");
|
|
|
222
222
|
|
|
223
223
|
// src/composable.ts
|
|
224
224
|
var REF_SYMBOL = Symbol("ref");
|
|
225
|
-
function useO(
|
|
225
|
+
function useO(model) {
|
|
226
226
|
const { state, origin } = (0, import_phecda_web2.getActiveInstance)();
|
|
227
|
-
const proxyFn = (0, import_phecda_web2.get)(
|
|
228
|
-
if ((0, import_phecda_web2.get)(
|
|
229
|
-
const instance = proxyFn(new
|
|
227
|
+
const proxyFn = (0, import_phecda_web2.get)(model.prototype, "shallow") ? import_vue4.shallowReactive : import_vue4.reactive;
|
|
228
|
+
if ((0, import_phecda_web2.get)(model.prototype, "isolate")) {
|
|
229
|
+
const instance = proxyFn(new model());
|
|
230
230
|
instance._promise = (0, import_phecda_web2.invokeHandler)("init", instance);
|
|
231
231
|
return instance;
|
|
232
232
|
}
|
|
233
|
-
const tag = (0, import_phecda_web2.getTag)(
|
|
233
|
+
const tag = (0, import_phecda_web2.getTag)(model);
|
|
234
234
|
if (!(tag in state)) {
|
|
235
|
-
const instance = proxyFn(new
|
|
235
|
+
const instance = proxyFn(new model());
|
|
236
236
|
instance._promise = (0, import_phecda_web2.invokeHandler)("init", instance);
|
|
237
237
|
state[tag] = instance;
|
|
238
|
-
origin.set(instance,
|
|
238
|
+
origin.set(instance, model);
|
|
239
239
|
}
|
|
240
240
|
return state[tag];
|
|
241
241
|
}
|
|
242
242
|
__name(useO, "useO");
|
|
243
|
-
function useRaw(
|
|
244
|
-
return (0, import_vue4.toRaw)(useO(
|
|
243
|
+
function useRaw(model) {
|
|
244
|
+
return (0, import_vue4.toRaw)(useO(model));
|
|
245
245
|
}
|
|
246
246
|
__name(useRaw, "useRaw");
|
|
247
|
-
function usePatch(
|
|
248
|
-
const instance = useO(
|
|
247
|
+
function usePatch(model, Data) {
|
|
248
|
+
const instance = useO(model);
|
|
249
249
|
mergeReactiveObjects(instance, Data);
|
|
250
250
|
}
|
|
251
251
|
__name(usePatch, "usePatch");
|
|
252
|
-
function useR(
|
|
253
|
-
return useO(
|
|
252
|
+
function useR(model) {
|
|
253
|
+
return useO(model);
|
|
254
254
|
}
|
|
255
255
|
__name(useR, "useR");
|
|
256
|
-
function useV(
|
|
256
|
+
function useV(model) {
|
|
257
257
|
const { cache: cacheMap } = (0, import_phecda_web2.getActiveInstance)();
|
|
258
|
-
const instance = useO(
|
|
258
|
+
const instance = useO(model);
|
|
259
259
|
const cache = cacheMap.get(instance) || {};
|
|
260
260
|
if (cache[REF_SYMBOL])
|
|
261
261
|
return cache[REF_SYMBOL];
|
|
@@ -297,9 +297,9 @@ function useEvent(eventName, cb) {
|
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
__name(useEvent, "useEvent");
|
|
300
|
-
function initialize(
|
|
301
|
-
const instance = useO(
|
|
302
|
-
const newInstance = new
|
|
300
|
+
function initialize(model, deleteOtherProperty = true) {
|
|
301
|
+
const instance = useO(model);
|
|
302
|
+
const newInstance = new model();
|
|
303
303
|
Object.assign(instance, newInstance);
|
|
304
304
|
if (deleteOtherProperty) {
|
|
305
305
|
for (const key in instance) {
|
|
@@ -312,8 +312,8 @@ __name(initialize, "initialize");
|
|
|
312
312
|
|
|
313
313
|
// src/decorator.ts
|
|
314
314
|
var import_phecda_web3 = require("phecda-web");
|
|
315
|
-
function Shallow(
|
|
316
|
-
(0, import_phecda_web3.set)(
|
|
315
|
+
function Shallow(model) {
|
|
316
|
+
(0, import_phecda_web3.set)(model.prototype, "shallow", true);
|
|
317
317
|
}
|
|
318
318
|
__name(Shallow, "Shallow");
|
|
319
319
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -182,40 +182,40 @@ __name(createSharedReactive, "createSharedReactive");
|
|
|
182
182
|
|
|
183
183
|
// src/composable.ts
|
|
184
184
|
var REF_SYMBOL = Symbol("ref");
|
|
185
|
-
function useO(
|
|
185
|
+
function useO(model) {
|
|
186
186
|
const { state, origin } = getActiveInstance2();
|
|
187
|
-
const proxyFn = get(
|
|
188
|
-
if (get(
|
|
189
|
-
const instance = proxyFn(new
|
|
187
|
+
const proxyFn = get(model.prototype, "shallow") ? shallowReactive : reactive;
|
|
188
|
+
if (get(model.prototype, "isolate")) {
|
|
189
|
+
const instance = proxyFn(new model());
|
|
190
190
|
instance._promise = invokeHandler2("init", instance);
|
|
191
191
|
return instance;
|
|
192
192
|
}
|
|
193
|
-
const tag = getTag(
|
|
193
|
+
const tag = getTag(model);
|
|
194
194
|
if (!(tag in state)) {
|
|
195
|
-
const instance = proxyFn(new
|
|
195
|
+
const instance = proxyFn(new model());
|
|
196
196
|
instance._promise = invokeHandler2("init", instance);
|
|
197
197
|
state[tag] = instance;
|
|
198
|
-
origin.set(instance,
|
|
198
|
+
origin.set(instance, model);
|
|
199
199
|
}
|
|
200
200
|
return state[tag];
|
|
201
201
|
}
|
|
202
202
|
__name(useO, "useO");
|
|
203
|
-
function useRaw(
|
|
204
|
-
return toRaw(useO(
|
|
203
|
+
function useRaw(model) {
|
|
204
|
+
return toRaw(useO(model));
|
|
205
205
|
}
|
|
206
206
|
__name(useRaw, "useRaw");
|
|
207
|
-
function usePatch(
|
|
208
|
-
const instance = useO(
|
|
207
|
+
function usePatch(model, Data) {
|
|
208
|
+
const instance = useO(model);
|
|
209
209
|
mergeReactiveObjects(instance, Data);
|
|
210
210
|
}
|
|
211
211
|
__name(usePatch, "usePatch");
|
|
212
|
-
function useR(
|
|
213
|
-
return useO(
|
|
212
|
+
function useR(model) {
|
|
213
|
+
return useO(model);
|
|
214
214
|
}
|
|
215
215
|
__name(useR, "useR");
|
|
216
|
-
function useV(
|
|
216
|
+
function useV(model) {
|
|
217
217
|
const { cache: cacheMap } = getActiveInstance2();
|
|
218
|
-
const instance = useO(
|
|
218
|
+
const instance = useO(model);
|
|
219
219
|
const cache = cacheMap.get(instance) || {};
|
|
220
220
|
if (cache[REF_SYMBOL])
|
|
221
221
|
return cache[REF_SYMBOL];
|
|
@@ -257,9 +257,9 @@ function useEvent(eventName, cb) {
|
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
__name(useEvent, "useEvent");
|
|
260
|
-
function initialize(
|
|
261
|
-
const instance = useO(
|
|
262
|
-
const newInstance = new
|
|
260
|
+
function initialize(model, deleteOtherProperty = true) {
|
|
261
|
+
const instance = useO(model);
|
|
262
|
+
const newInstance = new model();
|
|
263
263
|
Object.assign(instance, newInstance);
|
|
264
264
|
if (deleteOtherProperty) {
|
|
265
265
|
for (const key in instance) {
|
|
@@ -272,8 +272,8 @@ __name(initialize, "initialize");
|
|
|
272
272
|
|
|
273
273
|
// src/decorator.ts
|
|
274
274
|
import { set } from "phecda-web";
|
|
275
|
-
function Shallow(
|
|
276
|
-
set(
|
|
275
|
+
function Shallow(model) {
|
|
276
|
+
set(model.prototype, "shallow", true);
|
|
277
277
|
}
|
|
278
278
|
__name(Shallow, "Shallow");
|
|
279
279
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.18",
|
|
4
4
|
"description": "provide phecda function to vue",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"vue": "^3.2.45",
|
|
16
|
-
"phecda-web": "1.0.1-beta.
|
|
16
|
+
"phecda-web": "1.0.1-beta.11"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"tsup": "^6.5.0"
|