;
45 | }) => IBindings;
46 | declare type ParamsCallback any;
48 | }> = {
49 | [name in keyof P]: ReturnType
;
50 | };
51 | export declare function createDI
any;
53 | }>(params: P, next: (callback: any) => any): ParamsCallback
;
54 | export {};
55 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/mitt.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | /** Mitt: Tiny (~200b) functional event emitter / pubsub.
4 | * @name mitt
5 | * @returns {Mitt}
6 | */
7 | function mitt(all) {
8 | all = all || new Map();
9 | return {
10 | /**
11 | * Register an event handler for the given type.
12 | * @param {string|symbol} type Type of event to listen for, or `"*"` for all events
13 | * @param {Function} handler Function to call in response to given event
14 | * @memberOf mitt
15 | */
16 | on: function (type, handler) {
17 | var _this_1 = this;
18 | var handlers = all.get(type);
19 | var added = handlers && handlers.unshift(handler);
20 | if (!added) {
21 | all.set(type, [handler]);
22 | }
23 | return function () {
24 | _this_1.off(type, handler);
25 | };
26 | },
27 | once: function (type, handler) {
28 | var _this = this;
29 | var mergeHandle = function () {
30 | var params = [];
31 | for (var _i = 0; _i < arguments.length; _i++) {
32 | params[_i] = arguments[_i];
33 | }
34 | handler.apply(null, params);
35 | _this.off(type, mergeHandle);
36 | };
37 | return this.on(type, mergeHandle);
38 | },
39 | /**
40 | * Remove an event handler for the given type.
41 | *
42 | * @param {string|symbol} type Type of event to unregister `handler` from, or `"*"`
43 | * @param {Function} handler Handler function to remove
44 | * @memberOf mitt
45 | */
46 | off: function (type, handler) {
47 | var handlers = all.get(type);
48 | if (handlers) {
49 | handlers.splice(handlers.indexOf(handler) >>> 0, 1);
50 | }
51 | },
52 | clear: function () {
53 | all.clear();
54 | },
55 | /**
56 | * Invoke all handlers for the given type.
57 | * If present, `"*"` handlers are invoked after type-matched handlers.
58 | *
59 | * Note: Manually firing "*" handlers is not supported.
60 | *
61 | * @param {string|symbol} type The event type to invoke
62 | * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
63 | * @memberOf mitt
64 | */
65 | emit: function (type, evt) {
66 | (all.get(type) || []).slice().map(function (handler) { handler(evt); });
67 | (all.get('*') || []).slice().map(function (handler) { handler(type, evt); });
68 | }
69 | };
70 | }
71 | exports.mitt = mitt;
72 |
--------------------------------------------------------------------------------
/packages/reactivity/src/ref.ts:
--------------------------------------------------------------------------------
1 | import { clone } from '@jsmini/clone'
2 | import { isEqual } from '@jsmini/isequal'
3 |
4 | import { Dep } from './dep'
5 | import { isFunction } from './utils'
6 |
7 | export interface IRef {
8 | value: T
9 | /** 提取值 */
10 | get(): T
11 | /**
12 | * @param {any} params 值
13 | * @param {object} config
14 | * @param {boolean} config.notify - 是否强制更新
15 | */
16 | set(params: T | ((value: T) => T), config?: { notify: boolean }): void
17 |
18 | __v_isRef: boolean
19 | /**
20 | * 更新通知
21 | */
22 | observe: (callback: (newValue: T, oldValue: T) => any) => /** 清除句柄 */ () => any
23 | /**
24 | * 清除所有的监听
25 | */
26 | __v_clear: () => void
27 | }
28 |
29 | export function isRef (r: IRef | unknown): r is IRef
30 | export function isRef (r: any): r is IRef{
31 | return r ? r.__v_isRef === true : false
32 | }
33 |
34 | /**
35 | * @param {any} value - 初始值
36 | * ```js
37 | const number = useRef(0)
38 | number.set({
39 | name: 2
40 | });
41 | *
42 | * ```
43 | */
44 | export function useRef (value: T): IRef{
45 | return createRef(value)
46 | }
47 |
48 | function createRef (viewDate: T){
49 | /** 视图层的数据,只有在set的时候才能被获取更改 */
50 | viewDate = clone(viewDate)
51 | /** 对外的数据,允许更改 */
52 | let outDate = clone(viewDate)
53 |
54 | const dep = new Dep()
55 | const ref = Object.create(null)
56 |
57 | Object.defineProperties(ref, {
58 | value: {
59 | get () {
60 | return outDate
61 | },
62 | set () {
63 | console.error(`
64 | 请不要直接修改 ref.value 值
65 | `)
66 | }
67 | },
68 | get: {
69 | value: () => {
70 | return outDate
71 | },
72 | configurable: false,
73 | writable: false,
74 | enumerable: false
75 | },
76 | set: {
77 | value: (value: ((params: T) => T) | T, config = { notify: false }) => {
78 | let updateValue: T
79 | if (isFunction(value)) {
80 | updateValue = value(clone(outDate))
81 | } else {
82 | updateValue = value
83 | }
84 |
85 | if (config.notify || !isEqual(viewDate, updateValue)) {
86 | let beforeViewDate = clone(viewDate)
87 |
88 | viewDate = clone(updateValue)
89 | outDate = clone(updateValue)
90 |
91 | dep.notify(updateValue, beforeViewDate)
92 | }
93 | },
94 | configurable: false,
95 | writable: false,
96 | enumerable: false
97 | },
98 | toString: {
99 | value: () => String(viewDate),
100 | configurable: false,
101 | writable: false,
102 | enumerable: false
103 | },
104 | __v_isRef: {
105 | value: true,
106 | configurable: false,
107 | writable: false,
108 | enumerable: false
109 | },
110 | observe: {
111 | value: (callback: Function) => {
112 | return dep.depend(callback)
113 | },
114 | configurable: false,
115 | writable: false,
116 | enumerable: false
117 | },
118 | __v_clear: {
119 | value: () => {
120 | dep.clear()
121 | },
122 | configurable: false,
123 | writable: false,
124 | enumerable: false
125 | }
126 | })
127 |
128 | return ref
129 | }
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/shared.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var miniprogram_reactivity_1 = require("miniprogram-reactivity");
4 | var utils_1 = require("./utils");
5 | var diff_1 = require("./diff");
6 | var over_1 = require("./over");
7 | var lifecycle_1 = require("./lifecycle");
8 | var watch_1 = require("./watch");
9 | /** 副作用, 如果是方法,返回null */
10 | exports.deepToRaw = over_1.overCloneDeep(function (x) {
11 | if (utils_1.isFunction(x)) {
12 | return null;
13 | }
14 | if (miniprogram_reactivity_1.isRef(x)) {
15 | return x.value;
16 | }
17 | if (utils_1.isArray(x)) {
18 | return x.map(function (item) { return exports.deepToRaw(item); });
19 | }
20 | if (utils_1.isPlainObject(x)) {
21 | var obj_1 = {};
22 | Object.keys(x).forEach(function (key) {
23 | obj_1[key] = exports.deepToRaw(x[key]);
24 | });
25 | return obj_1;
26 | }
27 | return x;
28 | });
29 | /**
30 | * Page/Component 与 watch 中转
31 | * @return {function} 抛弃监听
32 | */
33 | function deepWatch(target, key, value) {
34 | var deepEffects = [];
35 | (function observerEffects(x) {
36 | /**
37 | * isObserve必须是在最前面,因为会被isPlainObject解析
38 | */
39 | if (miniprogram_reactivity_1.isObserve(x)) {
40 | return void deepEffects.push(x);
41 | }
42 | if (utils_1.isArray(x)) {
43 | return void x.map(function (item) { return observerEffects(item); });
44 | }
45 | if (utils_1.isPlainObject(x)) {
46 | return void Object.keys(x).forEach(function (key) {
47 | observerEffects(x[key]);
48 | });
49 | }
50 | })(value);
51 | if (!deepEffects.length) {
52 | return;
53 | }
54 | return watch_1.useEffect(function () {
55 | var _a, _b;
56 | target.setData(diff_1.diff((_a = {},
57 | _a[key] = exports.deepToRaw(value),
58 | _a), (_b = {},
59 | _b[key] = target.data[key],
60 | _b)));
61 | }, deepEffects);
62 | }
63 | exports.deepWatch = deepWatch;
64 | /**
65 | * 执行注册的生命周期
66 | */
67 | function createLifecycleMethods(lifecycle, options) {
68 | var lifeMethod = typeof options === 'function'
69 | ? options
70 | : typeof options === 'undefined'
71 | ? undefined
72 | : options[lifecycle];
73 | return function () {
74 | var args = [];
75 | for (var _i = 0; _i < arguments.length; _i++) {
76 | args[_i] = arguments[_i];
77 | }
78 | var injectLifes = lifecycle_1.conductHook(this, lifecycle, args);
79 | if (lifeMethod) {
80 | injectLifes.push(lifeMethod.call(this, args));
81 | }
82 | return injectLifes;
83 | };
84 | }
85 | exports.createLifecycleMethods = createLifecycleMethods;
86 | function createDI(params, next) {
87 | if (!params) {
88 | // @ts-ignore
89 | return {};
90 | }
91 | var result = {};
92 | Object.keys(params).forEach(function (KEY) {
93 | result[KEY] = next(params[KEY]);
94 | });
95 | return result;
96 | }
97 | exports.createDI = createDI;
98 |
--------------------------------------------------------------------------------
/packages/reactivity/lib/ref.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var clone_1 = require("@jsmini/clone");
4 | var isequal_1 = require("@jsmini/isequal");
5 | var dep_1 = require("./dep");
6 | var utils_1 = require("./utils");
7 | function isRef(r) {
8 | return r ? r.__v_isRef === true : false;
9 | }
10 | exports.isRef = isRef;
11 | /**
12 | * @param {any} value - 初始值
13 | * ```js
14 | const number = useRef(0)
15 | number.set({
16 | name: 2
17 | });
18 | *
19 | * ```
20 | */
21 | function useRef(value) {
22 | return createRef(value);
23 | }
24 | exports.useRef = useRef;
25 | function createRef(viewDate) {
26 | /** 视图层的数据,只有在set的时候才能被获取更改 */
27 | viewDate = clone_1.clone(viewDate);
28 | /** 对外的数据,允许更改 */
29 | var outDate = clone_1.clone(viewDate);
30 | var dep = new dep_1.Dep();
31 | var ref = Object.create(null);
32 | Object.defineProperties(ref, {
33 | value: {
34 | get: function () {
35 | return outDate;
36 | },
37 | set: function () {
38 | console.error("\n \u8BF7\u4E0D\u8981\u76F4\u63A5\u4FEE\u6539 ref.value \u503C\n ");
39 | }
40 | },
41 | get: {
42 | value: function () {
43 | return outDate;
44 | },
45 | configurable: false,
46 | writable: false,
47 | enumerable: false
48 | },
49 | set: {
50 | value: function (value, config) {
51 | if (config === void 0) { config = { notify: false }; }
52 | var updateValue;
53 | if (utils_1.isFunction(value)) {
54 | updateValue = value(clone_1.clone(outDate));
55 | }
56 | else {
57 | updateValue = value;
58 | }
59 | if (config.notify || !isequal_1.isEqual(viewDate, updateValue)) {
60 | var beforeViewDate = clone_1.clone(viewDate);
61 | viewDate = clone_1.clone(updateValue);
62 | outDate = clone_1.clone(updateValue);
63 | dep.notify(updateValue, beforeViewDate);
64 | }
65 | },
66 | configurable: false,
67 | writable: false,
68 | enumerable: false
69 | },
70 | toString: {
71 | value: function () { return String(viewDate); },
72 | configurable: false,
73 | writable: false,
74 | enumerable: false
75 | },
76 | __v_isRef: {
77 | value: true,
78 | configurable: false,
79 | writable: false,
80 | enumerable: false
81 | },
82 | __v_change: {
83 | value: function (callback) {
84 | return dep.depend(callback);
85 | },
86 | configurable: false,
87 | writable: false,
88 | enumerable: false
89 | },
90 | __v_clear: {
91 | value: function () {
92 | dep.clear();
93 | },
94 | configurable: false,
95 | writable: false,
96 | enumerable: false
97 | }
98 | });
99 | return ref;
100 | }
101 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/inject.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var clone_1 = require("@jsmini/clone");
4 | var isequal_1 = require("@jsmini/isequal");
5 | var instance_1 = require("./instance");
6 | var provides = getApp();
7 | /**
8 | *
9 | * create and use point
10 | */
11 | function useProvide(callback) {
12 | var args = [];
13 | for (var _i = 1; _i < arguments.length; _i++) {
14 | args[_i - 1] = arguments[_i];
15 | }
16 | return instance_1.overInCurrentModule(function (_current) {
17 | var current = _current ? _current : provides;
18 | if (!current["__loc_inject__" /* LOC_INJECT */]) {
19 | current["__loc_inject__" /* LOC_INJECT */] = [];
20 | }
21 | var targetInject = current["__loc_inject__" /* LOC_INJECT */];
22 | var findFunctionIndex = targetInject.findIndex(function (target) {
23 | return target.function_target === callback;
24 | });
25 | if (!~findFunctionIndex) {
26 | targetInject.unshift({
27 | function_target: callback,
28 | caches: [],
29 | });
30 | findFunctionIndex = 0;
31 | }
32 | var findFunctionResultIndex = targetInject[findFunctionIndex].caches.findIndex(function (cache) {
33 | return isequal_1.isEqual(cache[0], args);
34 | });
35 | if (!~findFunctionResultIndex) {
36 | targetInject[findFunctionIndex].caches.unshift([
37 | clone_1.clone(args),
38 | callback.apply(void 0, args),
39 | ]);
40 | findFunctionResultIndex = 0;
41 | }
42 | return targetInject[findFunctionIndex].caches[findFunctionResultIndex][1];
43 | });
44 | }
45 | exports.useProvide = useProvide;
46 | /**
47 | *
48 | * use point
49 | */
50 | function useInject(callback) {
51 | var args = [];
52 | for (var _i = 1; _i < arguments.length; _i++) {
53 | args[_i - 1] = arguments[_i];
54 | }
55 | var CANT_FIND_KEY = Symbol();
56 | function getProvide(target) {
57 | if (!target) {
58 | return CANT_FIND_KEY;
59 | }
60 | var targetInject = target["__loc_inject__" /* LOC_INJECT */] || [];
61 | if (!targetInject.length) {
62 | return getProvide(target["__parent__" /* PARENT */]);
63 | }
64 | var findFunctionIndex = targetInject.findIndex(function (target) {
65 | return target.function_target === callback;
66 | });
67 | if (!~findFunctionIndex) {
68 | return getProvide(target["__parent__" /* PARENT */]);
69 | }
70 | var findFunctionResultIndex = targetInject[findFunctionIndex].caches.findIndex(function (cache) {
71 | return isequal_1.isEqual(cache[0], args);
72 | });
73 | if (!~findFunctionResultIndex) {
74 | return getProvide(target["__parent__" /* PARENT */]);
75 | }
76 | return targetInject[findFunctionIndex].caches[findFunctionResultIndex][1];
77 | }
78 | return instance_1.overInCurrentModule(function (_current) {
79 | var current = _current ? _current : provides;
80 | var runResult = getProvide(current);
81 | if (runResult === CANT_FIND_KEY) {
82 | return callback.apply(void 0, args);
83 | }
84 | return runResult;
85 | });
86 | }
87 | exports.useInject = useInject;
88 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/mitt.ts:
--------------------------------------------------------------------------------
1 | export type EventType = string | symbol;
2 |
3 | // An event handler can take an optional event argument
4 | // and should not return a value
5 | export type Handler = (event?: any) => void;
6 | export type WildcardHandler= (type: EventType, event?: any) => void
7 |
8 | // An array of all currently registered event handlers for a type
9 | export type EventHandlerList = Array;
10 | export type WildCardEventHandlerList = Array;
11 |
12 | // A map of event types and their corresponding event handlers.
13 | export type EventHandlerMap = Map;
14 |
15 | export interface Emitter {
16 | on(type: EventType, handler: Handler): () => void;
17 | on(type: '*', handler: WildcardHandler): () => void;
18 |
19 | once(type: EventType, handler: Handler): () => void;
20 | once(type: '*', handler: WildcardHandler): () => void;
21 |
22 | off(type: EventType, handler: Handler): void;
23 | off(type: '*', handler: WildcardHandler): void;
24 |
25 | clear(): void;
26 |
27 | emit(type: EventType, event?: T): void;
28 | emit(type: '*', event?: any): void;
29 | }
30 |
31 | /** Mitt: Tiny (~200b) functional event emitter / pubsub.
32 | * @name mitt
33 | * @returns {Mitt}
34 | */
35 | export function mitt(all?: EventHandlerMap): Emitter {
36 | all = all || new Map();
37 |
38 | return {
39 |
40 | /**
41 | * Register an event handler for the given type.
42 | * @param {string|symbol} type Type of event to listen for, or `"*"` for all events
43 | * @param {Function} handler Function to call in response to given event
44 | * @memberOf mitt
45 | */
46 | on(type: EventType, handler: Handler) {
47 | const handlers = all.get(type);
48 | const added = handlers && handlers.unshift(handler);
49 | if (!added) {
50 | all.set(type, [handler]);
51 | }
52 |
53 | return () => {
54 | this.off(type, handler)
55 | }
56 | },
57 |
58 | once(type: EventType, handler: Handler) {
59 | const _this = this;
60 | const mergeHandle = function (...params: any[]) {
61 | handler.apply(null, params);
62 | _this.off(type, mergeHandle);
63 | }
64 |
65 | return this.on(type, mergeHandle);
66 | },
67 |
68 | /**
69 | * Remove an event handler for the given type.
70 | *
71 | * @param {string|symbol} type Type of event to unregister `handler` from, or `"*"`
72 | * @param {Function} handler Handler function to remove
73 | * @memberOf mitt
74 | */
75 | off(type: EventType, handler: Handler) {
76 | const handlers = all.get(type);
77 | if (handlers) {
78 | handlers.splice(handlers.indexOf(handler) >>> 0, 1);
79 | }
80 | },
81 |
82 | clear() {
83 | all.clear();
84 | },
85 |
86 | /**
87 | * Invoke all handlers for the given type.
88 | * If present, `"*"` handlers are invoked after type-matched handlers.
89 | *
90 | * Note: Manually firing "*" handlers is not supported.
91 | *
92 | * @param {string|symbol} type The event type to invoke
93 | * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
94 | * @memberOf mitt
95 | */
96 | emit(type: EventType, evt: any) {
97 | ((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });
98 | ((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });
99 | }
100 | };
101 | }
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/inject.ts:
--------------------------------------------------------------------------------
1 | import { clone } from '@jsmini/clone'
2 | import { isEqual } from '@jsmini/isequal'
3 |
4 | import { overInCurrentModule, ICurrentModuleInstance } from './instance'
5 | import { ExtendLefecycle } from './lifecycle'
6 | import { Parameters, ReturnType } from './interface'
7 |
8 | /**
9 | *
10 | * create new (function block) if not init that
11 | */
12 | export function useProvide any> (
13 | callback: T,
14 | ...args: Parameters
15 | ): ReturnType{
16 | const that = this
17 |
18 | return overInCurrentModule((current) => {
19 | current = current ? current : that
20 |
21 | if (!current) {
22 | throw new Error('useProvide 缺少 页面实例, 或者你想 useProvide.call(this)?')
23 | }
24 |
25 | if (!current[ExtendLefecycle.LOC_INJECT]) {
26 | current[ExtendLefecycle.LOC_INJECT] = []
27 | }
28 |
29 | let targetInject = current[ExtendLefecycle.LOC_INJECT]
30 | let findFunctionIndex = targetInject.findIndex((target) => {
31 | return target.function_target === callback
32 | })
33 | if (!~findFunctionIndex) {
34 | targetInject.unshift({
35 | function_target: callback,
36 | caches: []
37 | })
38 | findFunctionIndex = 0
39 | }
40 |
41 | let findFunctionResultIndex = targetInject[
42 | findFunctionIndex
43 | ].caches.findIndex((cache) => {
44 | return isEqual(cache[0], args)
45 | })
46 |
47 | if (!~findFunctionResultIndex) {
48 | targetInject[findFunctionIndex].caches.unshift([ clone(args), callback(...args) ])
49 | findFunctionResultIndex = 0
50 | }
51 |
52 | return targetInject[findFunctionIndex].caches[findFunctionResultIndex][1]
53 | })
54 | }
55 |
56 | /**
57 | *
58 | * find and use (function block) if created
59 | * if not find, run useProvide
60 | */
61 | export function useInject any> (
62 | callback: T,
63 | ...args: Parameters
64 | ): ReturnType{
65 | const that = this
66 | const CANT_FIND_KEY = Symbol()
67 |
68 | /** find (function block) */
69 | function getProvide (target: ICurrentModuleInstance): typeof CANT_FIND_KEY | ReturnType{
70 | if (!target) {
71 | return CANT_FIND_KEY
72 | }
73 |
74 | /** if not find parent, return app */
75 | function getParent (target: ICurrentModuleInstance){
76 | const app = getApp() as ICurrentModuleInstance
77 |
78 | if (target === app) {
79 | return null
80 | }
81 |
82 | return target[ExtendLefecycle.PARENT] || app
83 | }
84 |
85 | const targetInject = target[ExtendLefecycle.LOC_INJECT] || []
86 | if (!targetInject.length) {
87 | return getProvide(getParent(target))
88 | }
89 |
90 | const findFunctionIndex = targetInject.findIndex((target) => {
91 | return target.function_target === callback
92 | })
93 |
94 | if (!~findFunctionIndex) {
95 | return getProvide(getParent(target))
96 | }
97 |
98 | const findFunctionResultIndex = targetInject[
99 | findFunctionIndex
100 | ].caches.findIndex((cache) => {
101 | return isEqual(cache[0], args)
102 | })
103 |
104 | if (!~findFunctionResultIndex) {
105 | return getProvide(getParent(target))
106 | }
107 |
108 | return targetInject[findFunctionIndex].caches[findFunctionResultIndex][1]
109 | }
110 |
111 | return overInCurrentModule((current) => {
112 | current = current ? current : that
113 |
114 | if (!current) {
115 | throw new Error('useInject 缺少 页面实例, 或者你想 useInject.call(this)?')
116 | }
117 |
118 | const runResult = getProvide(current)
119 | if (runResult !== CANT_FIND_KEY) {
120 | return runResult
121 | }
122 |
123 | return useProvide.call(current, callback, ...args)
124 | })
125 | }
126 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/diff.ts:
--------------------------------------------------------------------------------
1 | const ARRAYTYPE = '[object Array]'
2 | const OBJECTTYPE = '[object Object]'
3 | const FUNCTIONTYPE = '[object Function]'
4 |
5 | export function diff (current, pre){
6 | const result = {}
7 | syncKeys(current, pre)
8 | console.log(current, pre)
9 | _diff(current, pre, '', result)
10 | return result
11 | }
12 |
13 | function syncKeys (current, pre){
14 | if (current === pre) return
15 | const rootCurrentType = type(current)
16 | const rootPreType = type(pre)
17 | if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
18 | // if (Object.keys(current).length >= Object.keys(pre).length) {
19 | for (let key in pre) {
20 | const currentValue = current[key]
21 | if (currentValue === undefined) {
22 | current[key] = null
23 | } else {
24 | syncKeys(currentValue, pre[key])
25 | }
26 | }
27 | // }
28 | } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
29 | if (current.length >= pre.length) {
30 | pre.forEach((item, index) => {
31 | syncKeys(current[index], item)
32 | })
33 | }
34 | }
35 | }
36 |
37 | function _diff (current, pre, path, result){
38 | if (current === pre) return
39 | const rootCurrentType = type(current)
40 | const rootPreType = type(pre)
41 | if (rootCurrentType == OBJECTTYPE) {
42 | if (
43 | rootPreType != OBJECTTYPE ||
44 | Object.keys(current).length < Object.keys(pre).length
45 | ) {
46 | setResult(result, path, current)
47 | } else {
48 | for (let key in current) {
49 | const currentValue = current[key]
50 | const preValue = pre[key]
51 | const currentType = type(currentValue)
52 | const preType = type(preValue)
53 | if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
54 | if (currentValue != pre[key]) {
55 | setResult(
56 | result,
57 | (path == '' ? '' : path + '.') + key,
58 | currentValue
59 | )
60 | }
61 | } else if (currentType == ARRAYTYPE) {
62 | if (preType != ARRAYTYPE) {
63 | setResult(
64 | result,
65 | (path == '' ? '' : path + '.') + key,
66 | currentValue
67 | )
68 | } else {
69 | if (currentValue.length < preValue.length) {
70 | setResult(
71 | result,
72 | (path == '' ? '' : path + '.') + key,
73 | currentValue
74 | )
75 | } else {
76 | currentValue.forEach((item, index) => {
77 | _diff(
78 | item,
79 | preValue[index],
80 | (path == '' ? '' : path + '.') +
81 | key +
82 | '[' +
83 | index +
84 | ']',
85 | result
86 | )
87 | })
88 | }
89 | }
90 | } else if (currentType == OBJECTTYPE) {
91 | if (
92 | preType != OBJECTTYPE ||
93 | Object.keys(currentValue).length < Object.keys(preValue).length
94 | ) {
95 | setResult(
96 | result,
97 | (path == '' ? '' : path + '.') + key,
98 | currentValue
99 | )
100 | } else {
101 | for (let subKey in currentValue) {
102 | _diff(
103 | currentValue[subKey],
104 | preValue[subKey],
105 | (path == '' ? '' : path + '.') + key + '.' + subKey,
106 | result
107 | )
108 | }
109 | }
110 | }
111 | }
112 | }
113 | } else if (rootCurrentType == ARRAYTYPE) {
114 | if (rootPreType != ARRAYTYPE) {
115 | setResult(result, path, current)
116 | } else {
117 | if (current.length < pre.length) {
118 | setResult(result, path, current)
119 | } else {
120 | current.forEach((item, index) => {
121 | _diff(item, pre[index], path + '[' + index + ']', result)
122 | })
123 | }
124 | }
125 | } else {
126 | setResult(result, path, current)
127 | }
128 | }
129 |
130 | function setResult (result, k, v){
131 | if (type(v) != FUNCTIONTYPE) {
132 | result[k] = v
133 | }
134 | }
135 |
136 | function type (obj){
137 | return Object.prototype.toString.call(obj)
138 | }
139 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/page.ts:
--------------------------------------------------------------------------------
1 | import { isFunction, wrapFuns } from './utils'
2 | import { PageLifecycle, conductHook, ExtendLefecycle, CommonLifecycle } from './lifecycle'
3 | import { createContext } from './context'
4 | import {
5 | createDI,
6 | createLifecycleMethods,
7 | createSingleCallbackResultLifecycle,
8 | ISetup
9 | } from './shared'
10 | import { ICurrentModuleInstance, overCurrentModule } from './instance'
11 | import { useInject, useProvide } from './inject'
12 |
13 | export function definePage<
14 | PROVIDE extends {
15 | [key: string]: () => any
16 | },
17 | INJECT extends {
18 | [key: string]: () => any
19 | }
20 | > (
21 | pageOptions:
22 | | {
23 | /** 注册服务 */
24 | provide?: PROVIDE
25 | /** 注入 */
26 | inject?: INJECT
27 | /** 静态属性,可以被覆盖,初始化显示更快 */
28 | data?: {
29 | [key: string]: any
30 | }
31 | setup?: ISetup
32 | }
33 | | ISetup
34 | ): any{
35 | let setupFun: Function
36 |
37 | let options: {
38 | methods?: {
39 | [key: string]: (...args: any[]) => any
40 | }
41 | [key: string]: any
42 | }
43 |
44 | if (isFunction(pageOptions)) {
45 | setupFun = pageOptions
46 | options = {}
47 | } else {
48 | if (pageOptions.setup === void 0) {
49 | return Page(pageOptions)
50 | }
51 |
52 | const { setup: setupOption, ...otherOptions } = pageOptions
53 | setupFun = setupOption
54 | options = otherOptions
55 | }
56 |
57 | /** 绑定上下文 */
58 | options['$'] = function (
59 | this: ICurrentModuleInstance,
60 | { detail }: { detail: ICurrentModuleInstance }
61 | ){
62 | detail[ExtendLefecycle.PARENT] = this
63 | }
64 |
65 | options[PageLifecycle.ON_LOAD] = overCurrentModule(
66 | wrapFuns(
67 | function (this: ICurrentModuleInstance){
68 | typeof this.triggerEvent === 'function' &&
69 | this.triggerEvent('component', this)
70 | },
71 | function (params){
72 | const context = createContext(this)
73 | const inject = createDI(options.inject, useInject)
74 | const provide = createDI(options.provide, useProvide)
75 | const binds = setupFun.call(
76 | this,
77 | params,
78 | Object.assign(context, { inject, provide })
79 | )
80 | if (binds instanceof Promise) {
81 | return console.error(`
82 | setup不支持返回promise
83 | `)
84 | }
85 | context.setData(binds)
86 | },
87 | createLifecycleMethods(CommonLifecycle.ON_LOAD, options[PageLifecycle.ON_LOAD])
88 | )
89 | )
90 |
91 | options[PageLifecycle.ON_READY] = createLifecycleMethods(
92 | CommonLifecycle.ON_READY,
93 | options[PageLifecycle.ON_READY]
94 | )
95 |
96 | options[PageLifecycle.ON_UNLOAD] = wrapFuns(function (){
97 | conductHook(this, ExtendLefecycle.EFFECT, [])
98 | }, createLifecycleMethods(CommonLifecycle.ON_UN_LOAD, options[PageLifecycle.ON_UNLOAD]))
99 |
100 | options[PageLifecycle.ON_SHOW] = createLifecycleMethods(
101 | PageLifecycle.ON_SHOW,
102 | options[PageLifecycle.ON_SHOW]
103 | )
104 |
105 | options[PageLifecycle.ON_HIDE] = createLifecycleMethods(
106 | PageLifecycle.ON_HIDE,
107 | options[PageLifecycle.ON_HIDE]
108 | )
109 |
110 | options[PageLifecycle.ON_RESIZE] = createLifecycleMethods(
111 | PageLifecycle.ON_RESIZE,
112 | options[PageLifecycle.ON_RESIZE]
113 | )
114 |
115 | options[PageLifecycle.ON_TAB_ITEM_TAP] = createLifecycleMethods(
116 | PageLifecycle.ON_TAB_ITEM_TAP,
117 | options[PageLifecycle.ON_TAB_ITEM_TAP]
118 | )
119 |
120 | options[PageLifecycle.ON_PULL_DOWN_REFRESH] = createLifecycleMethods(
121 | PageLifecycle.ON_PULL_DOWN_REFRESH,
122 | options[PageLifecycle.ON_PULL_DOWN_REFRESH]
123 | )
124 |
125 | options[PageLifecycle.ON_REACH_BOTTOM] = createLifecycleMethods(
126 | PageLifecycle.ON_REACH_BOTTOM,
127 | options[PageLifecycle.ON_REACH_BOTTOM]
128 | )
129 |
130 | options[PageLifecycle.ON_PAGE_SCROLL] = createLifecycleMethods(
131 | PageLifecycle.ON_PAGE_SCROLL,
132 | options[PageLifecycle.ON_PAGE_SCROLL]
133 | )
134 |
135 | options[PageLifecycle.ON_ADD_TO_FAVORITES] = createSingleCallbackResultLifecycle(
136 | PageLifecycle.ON_ADD_TO_FAVORITES,
137 | options[PageLifecycle.ON_ADD_TO_FAVORITES]
138 | )
139 |
140 | options[PageLifecycle.ON_SHARE_APP_MESSAGE] = createSingleCallbackResultLifecycle(
141 | PageLifecycle.ON_SHARE_APP_MESSAGE,
142 | options[PageLifecycle.ON_SHARE_APP_MESSAGE]
143 | )
144 |
145 | options[PageLifecycle.ON_SHARE_TIME_LINE] = createSingleCallbackResultLifecycle(
146 | PageLifecycle.ON_SHARE_TIME_LINE,
147 | options[PageLifecycle.ON_SHARE_TIME_LINE]
148 | )
149 |
150 | return Page(options)
151 | }
152 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/page.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var __rest = (this && this.__rest) || function (s, e) {
3 | var t = {};
4 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5 | t[p] = s[p];
6 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
7 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9 | t[p[i]] = s[p[i]];
10 | }
11 | return t;
12 | };
13 | var __spreadArrays = (this && this.__spreadArrays) || function () {
14 | for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
15 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
16 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
17 | r[k] = a[j];
18 | return r;
19 | };
20 | Object.defineProperty(exports, "__esModule", { value: true });
21 | var utils_1 = require("./utils");
22 | var lifecycle_1 = require("./lifecycle");
23 | var context_1 = require("./context");
24 | var shared_1 = require("./shared");
25 | var instance_1 = require("./instance");
26 | var inject_1 = require("./inject");
27 | function definePage(pageOptions) {
28 | var setupFun;
29 | var options;
30 | if (utils_1.isFunction(pageOptions)) {
31 | setupFun = pageOptions;
32 | options = {};
33 | }
34 | else {
35 | if (pageOptions.setup === void 0) {
36 | return Page(pageOptions);
37 | }
38 | var setupOption = pageOptions.setup, otherOptions = __rest(pageOptions, ["setup"]);
39 | setupFun = setupOption;
40 | options = otherOptions;
41 | }
42 | /** 绑定上下文 */
43 | options['$'] = function (_a) {
44 | var detail = _a.detail;
45 | detail["__parent__" /* PARENT */] = this;
46 | };
47 | options["onLoad" /* ON_LOAD */] = instance_1.overCurrentModule(utils_1.wrapFuns(function () {
48 | typeof this.triggerEvent === 'function' &&
49 | this.triggerEvent('component', this);
50 | }, function (params) {
51 | var context = context_1.createContext(this);
52 | var inject = shared_1.createDI(options.inject, inject_1.useInject);
53 | var provide = shared_1.createDI(options.provide, inject_1.useProvide);
54 | var binds = setupFun.call(this, params, Object.assign(context, { inject: inject, provide: provide }));
55 | if (binds instanceof Promise) {
56 | return console.error("\n setup\u4E0D\u652F\u6301\u8FD4\u56DEpromise\n ");
57 | }
58 | context.setData(binds);
59 | }, shared_1.createLifecycleMethods("onLoad" /* ON_LOAD */, options["onLoad" /* ON_LOAD */])));
60 | options["onReady" /* ON_READY */] = shared_1.createLifecycleMethods("onReady" /* ON_READY */, options["onReady" /* ON_READY */]);
61 | options["onUnload" /* ON_UNLOAD */] = utils_1.wrapFuns(function () {
62 | lifecycle_1.conductHook(this, "effect" /* EFFECT */, []);
63 | }, shared_1.createLifecycleMethods("onUnload" /* ON_UN_LOAD */, options["onUnload" /* ON_UNLOAD */]));
64 | options["onShow" /* ON_SHOW */] = shared_1.createLifecycleMethods("onShow" /* ON_SHOW */, options);
65 | options["onHide" /* ON_HIDE */] = shared_1.createLifecycleMethods("onHide" /* ON_HIDE */, options);
66 | options["onResize" /* ON_RESIZE */] = shared_1.createLifecycleMethods("onResize" /* ON_RESIZE */, options);
67 | options["onTabItemTap" /* ON_TAB_ITEM_TAP */] = shared_1.createLifecycleMethods("onTabItemTap" /* ON_TAB_ITEM_TAP */, options);
68 | options["onPullDownRefresh" /* ON_PULL_DOWN_REFRESH */] = shared_1.createLifecycleMethods("onPullDownRefresh" /* ON_PULL_DOWN_REFRESH */, options);
69 | options["onReachBottom" /* ON_REACH_BOTTOM */] = shared_1.createLifecycleMethods("onReachBottom" /* ON_REACH_BOTTOM */, options);
70 | options["onPageScroll" /* ON_PAGE_SCROLL */] = shared_1.createLifecycleMethods("onPageScroll" /* ON_PAGE_SCROLL */, options);
71 | options["onShareAppMessage" /* ON_SHARE_APP_MESSAGE */] = (function () {
72 | var lifecycleMethod = shared_1.createLifecycleMethods("onShareAppMessage" /* ON_SHARE_APP_MESSAGE */, options);
73 | return function () {
74 | var args = [];
75 | for (var _i = 0; _i < arguments.length; _i++) {
76 | args[_i] = arguments[_i];
77 | }
78 | var runResults = lifecycleMethod.apply.apply(lifecycleMethod, __spreadArrays([this], args));
79 | return runResults[runResults.length - 1];
80 | };
81 | })();
82 | return Page(options);
83 | }
84 | exports.definePage = definePage;
85 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/lifecycle.ts:
--------------------------------------------------------------------------------
1 | import { createShortName } from './utils'
2 | import { ICurrentModuleInstance, overInCurrentModule } from './instance'
3 |
4 | export const enum AppLifecycle {
5 | ON_LAUNCH = 'onLaunch',
6 | ON_SHOW = 'onShow',
7 | ON_HIDE = 'onHide',
8 | ON_ERROR = 'onError',
9 | ON_PAGE_NOT_FOUND = 'onPageNotFound',
10 | ON_THEME_CHANGE = 'onThemeChange'
11 | }
12 |
13 | export const enum ComponentLifecycle {
14 | CREATED = 'created',
15 | ATTACHED = 'attached',
16 | READY = 'ready',
17 | DETACHED = 'detached'
18 | }
19 |
20 | export const enum PageLifecycle {
21 | ON_LOAD = 'onLoad',
22 | ON_SHOW = 'onShow',
23 | ON_READY = 'onReady',
24 | ON_HIDE = 'onHide',
25 | ON_UNLOAD = 'onUnload',
26 | ON_PULL_DOWN_REFRESH = 'onPullDownRefresh',
27 | ON_REACH_BOTTOM = 'onReachBottom',
28 | ON_PAGE_SCROLL = 'onPageScroll',
29 | ON_SHARE_APP_MESSAGE = 'onShareAppMessage',
30 | ON_RESIZE = 'onResize',
31 | ON_TAB_ITEM_TAP = 'onTabItemTap',
32 | ON_ADD_TO_FAVORITES = 'onAddToFavorites',
33 | ON_SHARE_TIME_LINE = 'onShareTimeline'
34 | }
35 |
36 | export const enum CommonLifecycle {
37 | ON_LOAD = 'onLoad',
38 | ON_UN_LOAD = 'onUnload',
39 | ON_READY = 'onReady'
40 | }
41 |
42 | export const enum ExtendLefecycle {
43 | /** 副作用 */
44 | EFFECT = 'effect',
45 | /** props代理 */
46 | WATCH_PROPERTY = '__watchProperty__',
47 | /** 父实例 */
48 | PARENT = '__parent__',
49 | /** 依赖实例容器 */
50 | LOC_INJECT = '__loc_inject__'
51 | }
52 |
53 | /**注入hooks */
54 | export function injectHook (
55 | currentInstance: ICurrentModuleInstance,
56 | lifecycle: PageLifecycle | ComponentLifecycle | ExtendLefecycle | CommonLifecycle,
57 | hook: Function
58 | ){
59 | const hiddenField = createShortName(lifecycle)
60 | if (currentInstance[hiddenField] === undefined) {
61 | currentInstance[hiddenField] = []
62 | }
63 |
64 | currentInstance[hiddenField].push(hook)
65 | }
66 |
67 | /**执行hooks */
68 | export function conductHook (
69 | currentInstance: ICurrentModuleInstance,
70 | lifecycle: PageLifecycle | ComponentLifecycle | ExtendLefecycle | CommonLifecycle,
71 | params: any[]
72 | ){
73 | const hiddenField = createShortName(lifecycle)
74 | const injectLifes: Function[] = currentInstance[hiddenField] || []
75 |
76 | return injectLifes.map(
77 | (life) => typeof life === 'function' && life.apply(currentInstance, params)
78 | )
79 | }
80 |
81 | function createCurrentModuleHook (
82 | lifecycle: ComponentLifecycle | PageLifecycle | CommonLifecycle
83 | ){
84 | return function (callback: T){
85 | overInCurrentModule((currentInstance) => {
86 | currentInstance && injectHook(currentInstance, lifecycle, callback)
87 | })
88 | }
89 | }
90 |
91 | /** 实例被加载, Page.onLoad, Components.attached, App.onLaunch */
92 | export const onLoad = createCurrentModuleHook(CommonLifecycle.ON_LOAD)
93 |
94 | /** 实例装载完成, Page.onReady, Components.ready, App.onLaunch */
95 | export const onReady = createCurrentModuleHook(CommonLifecycle.ON_READY)
96 |
97 | /** 实例被销毁, Page.onUnLoad, Components.destory */
98 | export const onUnLoad = createCurrentModuleHook(CommonLifecycle.ON_UN_LOAD)
99 |
100 | /** 页面显示, Page.onShow, App.onShow */
101 | export const onShow = createCurrentModuleHook(PageLifecycle.ON_SHOW)
102 |
103 | /** 页面隐藏 Page.onHide, App.onHide */
104 | export const onHide = createCurrentModuleHook(PageLifecycle.ON_HIDE)
105 |
106 | /** 下拉刷新 */
107 | export const onPullDownRefresh = createCurrentModuleHook(PageLifecycle.ON_PULL_DOWN_REFRESH)
108 |
109 | /** 滚动到底部 */
110 | export const onReachBottom = createCurrentModuleHook(PageLifecycle.ON_REACH_BOTTOM)
111 |
112 | /** 页面滚动 */
113 | export const onPageScroll = createCurrentModuleHook(PageLifecycle.ON_PAGE_SCROLL)
114 |
115 | /** 小程序屏幕旋转时触发 */
116 | export const onResize = createCurrentModuleHook(PageLifecycle.ON_RESIZE)
117 |
118 | /** tab页面点击时触发 */
119 | export const onTabItemTap = createCurrentModuleHook<
120 | (
121 | e: {
122 | index: string
123 | pagePath: string
124 | text: string
125 | }
126 | ) => any
127 | >(PageLifecycle.ON_TAB_ITEM_TAP)
128 |
129 | /** 用户点击右上角收藏 */
130 | export const onAddToFavorites = createCurrentModuleHook<
131 | (
132 | e: { webviewUrl?: string }
133 | ) => {
134 | title?: string
135 | imageUrl?: string
136 | query?: string
137 | }
138 | >(PageLifecycle.ON_ADD_TO_FAVORITES)
139 |
140 | /** 转发 */
141 | export const onShareAppMessage = createCurrentModuleHook<
142 | (
143 | e: { from: 'button' | 'menu'; target: any; webViewUrl?: string }
144 | ) => {
145 | title?: string
146 | path?: string
147 | imageUrl?: string
148 | }
149 | >(PageLifecycle.ON_SHARE_APP_MESSAGE)
150 |
151 | /** 用户点击右上角转发到朋友圈 */
152 | export const onShareTimeline = createCurrentModuleHook<
153 | () => {
154 | title?: string
155 | query?: string
156 | imageUrl?: string
157 | }
158 | >(PageLifecycle.ON_SHARE_TIME_LINE)
159 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/diff.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var ARRAYTYPE = '[object Array]';
4 | var OBJECTTYPE = '[object Object]';
5 | var FUNCTIONTYPE = '[object Function]';
6 | function diff(current, pre) {
7 | var result = {};
8 | syncKeys(current, pre);
9 | _diff(current, pre, '', result);
10 | return result;
11 | }
12 | exports.diff = diff;
13 | function syncKeys(current, pre) {
14 | if (current === pre)
15 | return;
16 | var rootCurrentType = type(current);
17 | var rootPreType = type(pre);
18 | if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
19 | //if(Object.keys(current).length >= Object.keys(pre).length){
20 | for (var key in pre) {
21 | var currentValue = current[key];
22 | if (currentValue === undefined) {
23 | current[key] = null;
24 | }
25 | else {
26 | syncKeys(currentValue, pre[key]);
27 | }
28 | }
29 | //}
30 | }
31 | else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
32 | if (current.length >= pre.length) {
33 | pre.forEach(function (item, index) {
34 | syncKeys(current[index], item);
35 | });
36 | }
37 | }
38 | }
39 | function _diff(current, pre, path, result) {
40 | if (current === pre)
41 | return;
42 | var rootCurrentType = type(current);
43 | var rootPreType = type(pre);
44 | if (rootCurrentType == OBJECTTYPE) {
45 | if (rootPreType != OBJECTTYPE ||
46 | Object.keys(current).length < Object.keys(pre).length) {
47 | setResult(result, path, current);
48 | }
49 | else {
50 | var _loop_1 = function (key) {
51 | var currentValue = current[key];
52 | var preValue = pre[key];
53 | var currentType = type(currentValue);
54 | var preType = type(preValue);
55 | if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
56 | if (currentValue != pre[key]) {
57 | setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
58 | }
59 | }
60 | else if (currentType == ARRAYTYPE) {
61 | if (preType != ARRAYTYPE) {
62 | setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
63 | }
64 | else {
65 | if (currentValue.length < preValue.length) {
66 | setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
67 | }
68 | else {
69 | currentValue.forEach(function (item, index) {
70 | _diff(item, preValue[index], (path == '' ? '' : path + '.') +
71 | key +
72 | '[' +
73 | index +
74 | ']', result);
75 | });
76 | }
77 | }
78 | }
79 | else if (currentType == OBJECTTYPE) {
80 | if (preType != OBJECTTYPE ||
81 | Object.keys(currentValue).length < Object.keys(preValue).length) {
82 | setResult(result, (path == '' ? '' : path + '.') + key, currentValue);
83 | }
84 | else {
85 | for (var subKey in currentValue) {
86 | _diff(currentValue[subKey], preValue[subKey], (path == '' ? '' : path + '.') + key + '.' + subKey, result);
87 | }
88 | }
89 | }
90 | };
91 | for (var key in current) {
92 | _loop_1(key);
93 | }
94 | }
95 | }
96 | else if (rootCurrentType == ARRAYTYPE) {
97 | if (rootPreType != ARRAYTYPE) {
98 | setResult(result, path, current);
99 | }
100 | else {
101 | if (current.length < pre.length) {
102 | setResult(result, path, current);
103 | }
104 | else {
105 | current.forEach(function (item, index) {
106 | _diff(item, pre[index], path + '[' + index + ']', result);
107 | });
108 | }
109 | }
110 | }
111 | else {
112 | setResult(result, path, current);
113 | }
114 | }
115 | function setResult(result, k, v) {
116 | if (type(v) != FUNCTIONTYPE) {
117 | result[k] = v;
118 | }
119 | }
120 | function type(obj) {
121 | return Object.prototype.toString.call(obj);
122 | }
123 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/shared.ts:
--------------------------------------------------------------------------------
1 | import { isRef, IRef, isObserve, useRef } from 'miniprogram-reactivity'
2 | import { isPlainObject, isArray, isFunction } from './utils'
3 | import { diff } from './diff'
4 | import { overCloneDeep } from './over'
5 | import {
6 | ComponentLifecycle,
7 | PageLifecycle,
8 | conductHook,
9 | CommonLifecycle,
10 | } from './lifecycle'
11 | import { ICurrentModuleInstance } from './instance'
12 | import { IContext } from './context'
13 | import { useEffect } from './watch'
14 |
15 | /** 副作用, 如果是方法,返回null */
16 | export const deepToRaw = overCloneDeep(function (x: unknown) {
17 | if (isFunction(x)) {
18 | return null
19 | }
20 | if (isRef(x)) {
21 | return x.value
22 | }
23 | if (isArray(x)) {
24 | return x.map((item) => deepToRaw(item))
25 | }
26 | if (isPlainObject(x)) {
27 | const obj: { [key: string]: unknown } = {}
28 | Object.keys(x).forEach((key) => {
29 | obj[key] = deepToRaw(x[key])
30 | })
31 | return obj
32 | }
33 |
34 | return x
35 | })
36 |
37 | /**
38 | * Page/Component 与 watch 中转
39 | * @return {function} 抛弃监听
40 | */
41 | export function deepWatch(target: any, key: string, value: any) {
42 | const deepEffects: IRef[] = []
43 | ;(function observerEffects(x: any) {
44 | /**
45 | * isObserve必须是在最前面,因为会被isPlainObject解析
46 | */
47 | if (isObserve(x)) {
48 | return void deepEffects.push(x)
49 | }
50 | if (isArray(x)) {
51 | return void x.map((item) => observerEffects(item))
52 | }
53 | if (isPlainObject(x)) {
54 | return void Object.keys(x).forEach((key) => {
55 | observerEffects(x[key])
56 | })
57 | }
58 | })(value)
59 |
60 | if (!deepEffects.length) {
61 | return
62 | }
63 |
64 | return useEffect(() => {
65 | target.setData(
66 | diff(
67 | {
68 | [key]: deepToRaw(value),
69 | },
70 | {
71 | [key]: target.data[key],
72 | }
73 | )
74 | )
75 | }, deepEffects)
76 | }
77 |
78 | /**
79 | *
80 | * 执行注册的声明周期
81 | * @param {string} lifecycle 需要执行的某个生命周期
82 | * @param {string} extendFunction 额外需要追加执行的方法
83 | * @return {function} 返回一个方法, 调用时, 执行该this下所有指定的生命周期
84 | */
85 | export function createLifecycleMethods(
86 | lifecycle: ComponentLifecycle | PageLifecycle | CommonLifecycle,
87 | extendFunction?: Function | undefined
88 | ): (...args: any[]) => any[] {
89 |
90 | return function (this: ICurrentModuleInstance, ...args: any[]) {
91 | const injectLifes: any[] = conductHook(this, lifecycle, args)
92 |
93 | if (extendFunction) {
94 | injectLifes.push(extendFunction.call(this, args))
95 | }
96 |
97 | return injectLifes
98 | }
99 | }
100 |
101 |
102 | /**
103 | *
104 | * 适配于需要一个返回值
105 | * @param lifecycle
106 | * @param extendFunction
107 | */
108 | export function createSingleCallbackResultLifecycle (
109 | lifecycle: PageLifecycle,
110 | extendFunction: Function | undefined
111 | ){
112 | const lifecycleMethod = createLifecycleMethods(lifecycle, extendFunction)
113 | return function (...args: any){
114 | const runResults = lifecycleMethod.apply(this, ...args)
115 | return runResults[runResults.length - 1]
116 | }
117 | }
118 |
119 | export type IBindings = { [key: string]: any }
120 |
121 | type IAnyObject = Record
122 | type PropertyType =
123 | | StringConstructor
124 | | NumberConstructor
125 | | BooleanConstructor
126 | | ArrayConstructor
127 | | ObjectConstructor
128 | | null
129 | type ValueType = T extends StringConstructor
130 | ? string
131 | : T extends NumberConstructor
132 | ? number
133 | : T extends BooleanConstructor
134 | ? boolean
135 | : T extends ArrayConstructor
136 | ? any[]
137 | : T extends ObjectConstructor
138 | ? IAnyObject
139 | : any
140 | type FullProperty = {
141 | /** 属性类型 */
142 | type: T
143 | /** 默认值 */
144 | value?: ValueType
145 | }
146 | export type AllFullProperty =
147 | | FullProperty
148 | | FullProperty
149 | | FullProperty
150 | | FullProperty
151 | | FullProperty
152 | | FullProperty
153 | type ShortProperty =
154 | | StringConstructor
155 | | NumberConstructor
156 | | BooleanConstructor
157 | | ArrayConstructor
158 | | ObjectConstructor
159 | | null
160 |
161 | export type AllProperty = AllFullProperty | ShortProperty
162 |
163 | interface IProps {
164 | [keyName: string]: AllProperty
165 | }
166 |
167 | type PropertyToData = T extends ShortProperty
168 | ? ValueType
169 | : T extends AllFullProperty
170 | ? ValueType
171 | : any
172 |
173 | type PropertyOptionToData = {
174 | [name in keyof P]: IRef>
175 | }
176 |
177 | export type ISetup<
178 | P extends IProps,
179 | PROVIDE extends {
180 | [key: string]: () => any
181 | },
182 | INJECT extends {
183 | [key: string]: () => any
184 | }
185 | > = (
186 | this: ICurrentModuleInstance,
187 | props: PropertyOptionToData,
188 | context: IContext & {
189 | provide: ParamsCallback
190 | inject: ParamsCallback
191 | }
192 | ) => IBindings
193 |
194 | type ParamsFunDI = () => any
195 |
196 | type ParamsCallback<
197 | P extends {
198 | [key: string]: ParamsFunDI
199 | }
200 | > = {
201 | [name in keyof P]: ReturnType
202 | }
203 |
204 | export function createDI<
205 | P extends {
206 | [key: string]: ParamsFunDI
207 | }
208 | >(params: P, next: (callback: any) => any): ParamsCallback
{
209 | if (!params) {
210 | // @ts-ignore
211 | return {}
212 | }
213 | const result: any = {}
214 | Object.keys(params).forEach((KEY) => {
215 | result[KEY] = next(params[KEY])
216 | })
217 |
218 | return result
219 | }
220 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/lib/component.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var __rest = (this && this.__rest) || function (s, e) {
3 | var t = {};
4 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5 | t[p] = s[p];
6 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
7 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9 | t[p[i]] = s[p[i]];
10 | }
11 | return t;
12 | };
13 | Object.defineProperty(exports, "__esModule", { value: true });
14 | var lifecycle_1 = require("./lifecycle");
15 | var utils_1 = require("./utils");
16 | var instance_1 = require("./instance");
17 | var context_1 = require("./context");
18 | var shared_1 = require("./shared");
19 | var inject_1 = require("./inject");
20 | var miniprogram_reactivity_1 = require("miniprogram-reactivity");
21 | function defineComponent(componentOptions) {
22 | var setupFun;
23 | var options;
24 | if (utils_1.isFunction(componentOptions)) {
25 | setupFun = componentOptions;
26 | options = {};
27 | }
28 | else {
29 | componentOptions.properties =
30 | componentOptions.props || componentOptions.properties || {};
31 | if (componentOptions.setup === void 0) {
32 | return Component(componentOptions);
33 | }
34 | var setupOption = componentOptions.setup, otherOptions = __rest(componentOptions, ["setup"]);
35 | setupFun = setupOption;
36 | options = otherOptions;
37 | }
38 | options.properties &&
39 | Object.keys(options.properties).forEach(function (KEY) {
40 | var prop = options.properties[KEY];
41 | var proxy_prop;
42 | if (typeof prop === 'function' || prop === null) {
43 | proxy_prop = {
44 | type: prop,
45 | value: null,
46 | };
47 | }
48 | else {
49 | proxy_prop = prop;
50 | }
51 | proxy_prop.observer = function (newValue) {
52 | var sortName = "__watchProperty__" /* WATCH_PROPERTY */;
53 | this[sortName] &&
54 | this[sortName][KEY] &&
55 | this[sortName][KEY](newValue);
56 | };
57 | options.properties[KEY] = proxy_prop;
58 | });
59 | function createProxyProperty() {
60 | var _this = this;
61 | var proxy = {};
62 | options.properties &&
63 | Object.keys(options.properties).forEach(function (KEY) {
64 | proxy[KEY] = miniprogram_reactivity_1.useRef(_this.properties[KEY]);
65 | if (!_this["__watchProperty__" /* WATCH_PROPERTY */]) {
66 | _this["__watchProperty__" /* WATCH_PROPERTY */] = {};
67 | }
68 | _this["__watchProperty__" /* WATCH_PROPERTY */][KEY] = function (value) {
69 | proxy[KEY].set(value);
70 | };
71 | });
72 | return proxy;
73 | }
74 | options.methods = options.methods || {};
75 | /** 绑定上下文 */
76 | options.methods['$'] = function (_a) {
77 | var detail = _a.detail;
78 | detail["__parent__" /* PARENT */] = this;
79 | };
80 | /**
81 | *
82 | * TODO 下一个版本将props转化为ref对象,进行监听
83 | */
84 | options["attached" /* ATTACHED */] = instance_1.overCurrentModule(utils_1.wrapFuns(function () {
85 | this.triggerEvent('component', this);
86 | }, function () {
87 | var context = context_1.createContext(this);
88 | var inject = shared_1.createDI(options.inject, inject_1.useInject);
89 | var provide = shared_1.createDI(options.provide, inject_1.useProvide);
90 | var props = createProxyProperty.call(this);
91 | var binds = setupFun.call(this, props, Object.assign(context, { inject: inject, provide: provide }));
92 | if (binds instanceof Promise) {
93 | return console.error("\n setup\u8FD4\u56DE\u503C\u4E0D\u652F\u6301promise\n ");
94 | }
95 | var calcKeys = Object.keys(binds).filter(function (val) {
96 | return Object.keys(props).indexOf(val) > -1;
97 | });
98 | if (calcKeys.length) {
99 | console.error("\u6CE8\u610F!" + calcKeys + "\u5DF2\u5B58\u5728props\u4E2D,setup\u671F\u95F4\u8FD4\u56DE\u540C\u540D\u5C5E\u6027,\u5C06\u4F1A\u89E6\u53D1props\u503C\u6539\u53D8");
100 | }
101 | context.setData(binds);
102 | }, shared_1.createLifecycleMethods("onLoad" /* ON_LOAD */, options["attached" /* ATTACHED */])));
103 | options["ready" /* READY */] = shared_1.createLifecycleMethods("onReady" /* ON_READY */, options["ready" /* READY */]);
104 | options["detached" /* DETACHED */] = utils_1.wrapFuns(function () {
105 | lifecycle_1.conductHook(this, "effect" /* EFFECT */, []);
106 | }, shared_1.createLifecycleMethods("onUnload" /* ON_UN_LOAD */, options["detached" /* DETACHED */]));
107 | options.methods["onShow" /* ON_SHOW */] = shared_1.createLifecycleMethods("onShow" /* ON_SHOW */, options["onShow" /* ON_SHOW */]);
108 | options.methods["onHide" /* ON_HIDE */] = shared_1.createLifecycleMethods("onHide" /* ON_HIDE */, options["onHide" /* ON_HIDE */]);
109 | options.methods["onPullDownRefresh" /* ON_PULL_DOWN_REFRESH */] = shared_1.createLifecycleMethods("onPullDownRefresh" /* ON_PULL_DOWN_REFRESH */, options["onPullDownRefresh" /* ON_PULL_DOWN_REFRESH */]);
110 | options.methods["onReachBottom" /* ON_REACH_BOTTOM */] = shared_1.createLifecycleMethods("onReachBottom" /* ON_REACH_BOTTOM */, options["onReachBottom" /* ON_REACH_BOTTOM */]);
111 | options.methods["onPageScroll" /* ON_PAGE_SCROLL */] = shared_1.createLifecycleMethods("onPageScroll" /* ON_PAGE_SCROLL */, options["onPageScroll" /* ON_PAGE_SCROLL */]);
112 | options.methods["onShareAppMessage" /* ON_SHARE_APP_MESSAGE */] = (function () {
113 | var lifecycleMethod = shared_1.createLifecycleMethods("onShareAppMessage" /* ON_SHARE_APP_MESSAGE */, options["onShareAppMessage" /* ON_SHARE_APP_MESSAGE */]);
114 | return function () {
115 | var params = [];
116 | for (var _i = 0; _i < arguments.length; _i++) {
117 | params[_i] = arguments[_i];
118 | }
119 | var runResults = lifecycleMethod.apply(this, params);
120 | return runResults[runResults.length - 1];
121 | };
122 | })();
123 | return Component(options);
124 | }
125 | exports.defineComponent = defineComponent;
126 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/src/component.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ComponentLifecycle,
3 | PageLifecycle,
4 | conductHook,
5 | ExtendLefecycle,
6 | CommonLifecycle
7 | } from './lifecycle'
8 | import { isFunction, wrapFuns } from './utils'
9 | import { ICurrentModuleInstance, overCurrentModule } from './instance'
10 | import { createContext } from './context'
11 | import {
12 | createLifecycleMethods,
13 | createSingleCallbackResultLifecycle,
14 | ISetup,
15 | AllProperty,
16 | createDI
17 | } from './shared'
18 | import { useInject, useProvide } from './inject'
19 | import { useRef, IRef } from 'miniprogram-reactivity'
20 |
21 | export function defineComponent<
22 | PROPS extends {
23 | [key: string]: AllProperty
24 | },
25 | PROVIDE extends {
26 | [key: string]: () => any
27 | },
28 | INJECT extends {
29 | [key: string]: () => any
30 | }
31 | > (
32 | componentOptions:
33 | | {
34 | props?: PROPS
35 | /** 注册 */
36 | provide?: PROVIDE
37 | /** 注入 */
38 | inject?: INJECT
39 | /** 静态属性,可以被覆盖,初始化显示更快 */
40 | data?: {
41 | [key: string]: any
42 | }
43 | setup?: ISetup
44 | [key: string]: any
45 | }
46 | | ISetup
47 | ): any{
48 | let setupFun: Function
49 | let options: {
50 | methods?: {
51 | [key: string]: (...args: any[]) => any
52 | }
53 | properties?: {
54 | [key: string]: AllProperty
55 | }
56 | [key: string]: any
57 | }
58 |
59 | if (isFunction(componentOptions)) {
60 | setupFun = componentOptions
61 | options = {}
62 | } else {
63 | componentOptions.properties =
64 | componentOptions.props || componentOptions.properties || {}
65 |
66 | if (componentOptions.setup === void 0) {
67 | return Component(componentOptions)
68 | }
69 |
70 | const { setup: setupOption, ...otherOptions } = componentOptions
71 | setupFun = setupOption
72 | options = otherOptions
73 | }
74 |
75 | options.methods = options.methods || {}
76 |
77 | options.properties &&
78 | Object.keys(options.properties).forEach((KEY) => {
79 | let prop = options.properties[KEY]
80 | let proxy_prop
81 | if (typeof prop === 'function' || prop === null) {
82 | proxy_prop = {
83 | type: prop,
84 | value: null
85 | }
86 | } else {
87 | proxy_prop = prop
88 | }
89 |
90 | proxy_prop.observer = function (this: ICurrentModuleInstance, newValue){
91 | const sortName = ExtendLefecycle.WATCH_PROPERTY
92 |
93 | this[sortName] && this[sortName][KEY] && this[sortName][KEY](newValue)
94 | }
95 |
96 | options.properties[KEY] = proxy_prop
97 | })
98 |
99 | function createProxyProperty (this: ICurrentModuleInstance){
100 | const proxy: {
101 | [key: string]: IRef
102 | } = {}
103 |
104 | options.properties &&
105 | Object.keys(options.properties).forEach((KEY) => {
106 | proxy[KEY] = useRef(this.properties[KEY])
107 |
108 | if (!this[ExtendLefecycle.WATCH_PROPERTY]) {
109 | this[ExtendLefecycle.WATCH_PROPERTY] = {}
110 | }
111 | this[ExtendLefecycle.WATCH_PROPERTY][KEY] = function (value){
112 | proxy[KEY].set(value)
113 | }
114 | })
115 |
116 | return proxy
117 | }
118 |
119 | /** 子组件通知 */
120 | options.methods['$'] = function (
121 | this: ICurrentModuleInstance,
122 | { detail: child }: { detail: ICurrentModuleInstance }
123 | ){
124 | child[ExtendLefecycle.PARENT] = this
125 | }
126 |
127 | /**
128 | *
129 | * TODO 下一个版本将props转化为ref对象,进行监听
130 | */
131 | options[ComponentLifecycle.ATTACHED] = overCurrentModule(
132 | wrapFuns(
133 | function (this: ICurrentModuleInstance){
134 | this.triggerEvent('component', this)
135 | },
136 | function (this: ICurrentModuleInstance){
137 | const context = createContext(this)
138 | const inject = createDI(options.inject, useInject)
139 | const provide = createDI(options.provide, useProvide)
140 | const props = createProxyProperty.call(this)
141 | const binds = setupFun.call(
142 | this,
143 | props,
144 | Object.assign(context, { inject, provide })
145 | )
146 | if (binds instanceof Promise) {
147 | return console.error(`
148 | setup返回值不支持promise
149 | `)
150 | }
151 |
152 | const calcKeys = Object.keys(binds).filter(function (val){
153 | return Object.keys(props).indexOf(val) > -1
154 | })
155 |
156 | if (calcKeys.length) {
157 | console.error(`注意!${calcKeys}已存在props中,setup期间返回同名属性,将会触发props值改变`)
158 | }
159 |
160 | context.setData(binds)
161 | },
162 | createLifecycleMethods(
163 | CommonLifecycle.ON_LOAD,
164 | options[ComponentLifecycle.ATTACHED]
165 | )
166 | )
167 | )
168 |
169 | options[ComponentLifecycle.READY] = createLifecycleMethods(
170 | CommonLifecycle.ON_READY,
171 | options[ComponentLifecycle.READY]
172 | )
173 |
174 | options[ComponentLifecycle.DETACHED] = wrapFuns(function (){
175 | conductHook(this, ExtendLefecycle.EFFECT, [])
176 | }, createLifecycleMethods(CommonLifecycle.ON_UN_LOAD, options[ComponentLifecycle.DETACHED]))
177 |
178 | options.methods[PageLifecycle.ON_SHOW] = createLifecycleMethods(
179 | PageLifecycle.ON_SHOW,
180 | options.methods[PageLifecycle.ON_SHOW]
181 | )
182 |
183 | options.methods[PageLifecycle.ON_HIDE] = createLifecycleMethods(
184 | PageLifecycle.ON_HIDE,
185 | options.methods[PageLifecycle.ON_HIDE]
186 | )
187 |
188 | options.methods[PageLifecycle.ON_RESIZE] = createLifecycleMethods(
189 | PageLifecycle.ON_RESIZE,
190 | options.methods[PageLifecycle.ON_RESIZE]
191 | )
192 |
193 | options.methods[PageLifecycle.ON_TAB_ITEM_TAP] = createLifecycleMethods(
194 | PageLifecycle.ON_TAB_ITEM_TAP,
195 | options.methods[PageLifecycle.ON_TAB_ITEM_TAP]
196 | )
197 |
198 | options.methods[PageLifecycle.ON_PULL_DOWN_REFRESH] = createLifecycleMethods(
199 | PageLifecycle.ON_PULL_DOWN_REFRESH,
200 | options.methods[PageLifecycle.ON_PULL_DOWN_REFRESH]
201 | )
202 |
203 | options.methods[PageLifecycle.ON_REACH_BOTTOM] = createLifecycleMethods(
204 | PageLifecycle.ON_REACH_BOTTOM,
205 | options.methods[PageLifecycle.ON_REACH_BOTTOM]
206 | )
207 |
208 | options.methods[PageLifecycle.ON_PAGE_SCROLL] = createLifecycleMethods(
209 | PageLifecycle.ON_PAGE_SCROLL,
210 | options.methods[PageLifecycle.ON_PAGE_SCROLL]
211 | )
212 |
213 | options.methods[PageLifecycle.ON_ADD_TO_FAVORITES] = createSingleCallbackResultLifecycle(
214 | PageLifecycle.ON_ADD_TO_FAVORITES,
215 | options.methods[PageLifecycle.ON_ADD_TO_FAVORITES]
216 | )
217 |
218 | options.methods[PageLifecycle.ON_SHARE_APP_MESSAGE] = createSingleCallbackResultLifecycle(
219 | PageLifecycle.ON_SHARE_APP_MESSAGE,
220 | options.methods[PageLifecycle.ON_SHARE_APP_MESSAGE]
221 | )
222 |
223 | options.methods[PageLifecycle.ON_SHARE_TIME_LINE] = createSingleCallbackResultLifecycle(
224 | PageLifecycle.ON_SHARE_TIME_LINE,
225 | options.methods[PageLifecycle.ON_SHARE_TIME_LINE]
226 | )
227 |
228 | return Component(options)
229 | }
230 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 尝试在小程序里使用 composition-api
2 |
3 | - [案例](./EXAMPLE.md)
4 | - [版本更新](./TODO.md)
5 |
6 | ### 下载
7 |
8 | > npm install miniprogram-composition-api --save
9 | > [仓库地址](https://github.com/clevok/miniprogram-composition-api)
10 |
11 | ### 使用前请考虑
12 |
13 | 这个框架只是参考vue composition api思路, 因为得考虑到 `IOS10` 以下的客户无法使用Proxy, 出于这个原因, 没有采用`@vue/reactivity`做响应式数据, 所以api是不一致的, 最后的如果不再考虑Proxy兼容性, 将不维护这个了
14 |
15 | 1. 它是过度产品, 是因为我想使用`function api`的方式写小程序, 但是可能会面临`兼容性问题`可能会被上司要求解决,除非可以让用户升级系统版本(曾经考虑过`Object.defineProperty`和脏检查)
16 |
17 | 2. 最终ref对象采用的是[mobx box方案](https://cn.mobx.js.org/refguide/boxed.html)方案, 意味着要通过`.set`读取值, `.get/.value`获取值, 有些人可能会很不喜欢, 因为`.set`方式 和 直接修改`.value`值的方式, 直觉上的相差太多, 并且常常会忘记需要 `.value` 来获取真正的值
18 |
19 | 3. 已经有真正使用`@vue/reactivity` 的[小程序框架 了](https://github.com/yangmingshan/vue-mini) 直接采用了[@vue/reactivity](https://github.com/vuejs/vue-next/tree/master/packages/reactivity) 做响应式数据, 不考虑proxy问题,可以考虑这个框架
20 |
21 | ---
22 |
23 | ### 必读
24 |
25 | 1. 比较别扭的是, 更新 useRef 对象的值必须通过 `.set`方法, `读取`必须是 `.value`或者`.get()`
26 |
27 | 2. 响应式数据, 会通过 `westore.diff` 转换到 视图层, 某些情况下, 视图层数据 会与逻辑层中不一致
28 | 1. 删除数组中的某一项, 其实会把 这个项目变成 null, 例如 [1,2,3] => [1,null,3]
29 | 2. 删除对象某个属性, 会把这个属性设置成 null 例如 { name: 'along' } => {name: null}
30 | 3. 之后会尝试优化 westore 的 diff, 如果设置成了空 数组 或者空对象, 就直接变成 全部复制, 以及提供 diff: false, 不经过他的 diff, 直接整个赋值
31 | 4. 将会建立自己一套 diff 树,目前更新颗粒度只有一层..
32 | 3. `useRef`将改名为`useBox`,ref对象将和vue3保持一致
33 |
34 | ### 解决什么
35 |
36 | 1. 带来新的代码复用方案(比 mixins 更友好)
37 | 2. 带来另一个种全局状态管理思路
38 | 3. `计算属性computed`,`监听watch`也都有, 没有基础库限制要求(定义的时候需要用户主动传入依赖项)
39 | 4. 新的写法,不再是 {data:{},methods,生命周期方法}这类写法
40 |
41 | ## 使用入门
42 |
43 | ### 基础概念
44 |
45 | 最基础的思想: 通过 将`响应式对象` _注入_ 到 `视图层` 中, (`响应式对象`的值更改, 将同步更新视图层)
46 | (缺陷: 因为版本兼容性问题, 还是通过显式的 `.set` 方式更新 `响应式对象值`)
47 |
48 | 而不在是 页面定义 data, 通过 setData 更新页面值
49 |
50 | 将 `同一个响应式对象`注入到`多个页面`的中, 就实现了 多个页面的的数据保持一致(`状态管理`), (将这个响应式对象放在 app 中,每个页面拿过来注入到视图层中,就实现了`全局状态`)
51 |
52 | ### setup 入口
53 |
54 | setup 函数是一个新声明周期, 在 onLoad 期间调用, 它会起到将`返回值`*注入*到`视图层`中的作用
55 |
56 | `函数`也同样也可以`return`回去,便成了页面点击回调事件
57 |
58 | > 也就是只有需要在视图层上需要渲染的变量/方法,才需 return 回去, 否者将不会会渲染到视图中
59 |
60 | ```html
61 | {{name}}
62 |
78 | ```
79 |
80 | ### useRef 对象
81 |
82 | 这是一套响应式数据
83 | 通过`setup`可以将`响应式对象`*`注入`*到`视图层`中,只要这个`响应式对象`值变化了,那么注入到的视图层里的值都会变,(也就是说定义一个叫 cart 的 ref 对象,A 页面注入了 cart,B 页面也注入了 cart, 只要 cart 值变了, A 页面和 B 页面的对应的值都会变化)
84 |
85 | ```js
86 | // global.js
87 | export const cart = useRef({ name: "小兰" })
88 | ```
89 |
90 | ```html
91 | // A页面和B页面都这样写
92 | {{cart.name}}
93 |
105 | ```
106 |
107 | A 页面和 B 页面注入了 同一个响应式对象, 只要 `cart`发送了变化, 所有页面上的 name 值都会变化!这就是响应式对象
108 |
109 | ### 包裹对象 useRef
110 |
111 | **创建 ref 对象**
112 | useRef 对象接受一个参数作为初始值, 通过 .value 获取值
113 |
114 | ```js
115 | const count = useRef(0)
116 | console.log(count.value) // 0
117 | ```
118 |
119 | **如何更新 ref 对象的值**
120 | 必须通过`.set`更新 ref 的值,才能正常使用
121 |
122 | ```js
123 | const count = useRef(0)
124 | console.log(count.value) // 0
125 |
126 | count.set(1)
127 |
128 | console.log(count.value) // 1
129 | ```
130 |
131 | .set 有两种用法
132 |
133 | 1. 接受一个一个非方法对象,将会直接改变这个 ref 的值
134 | 2. 接受一个方法, 将会调用这个方法并传入原来的值, 接受这个方法返回的值作为更改后的值
135 |
136 | ```js
137 | const count = useRef(0)
138 |
139 | count.set((value) => value + 1)
140 | count.set(value + 1)
141 | ```
142 |
143 | 为了避免按引用类型对象不小心被刚刚坑,我们断绝了除 .set 方法外一切 可能更改 ref 内部值的途径
144 |
145 | ```js
146 | var a = { name: 123 }
147 | var b = useRef(a)
148 | var c = b.value
149 | var d = b.get()
150 |
151 | // 他们的关系分别是
152 | // a , b , [ c, d ], 只有 c和d 是指针指向相同的
153 | // a !== b !== (c === d)
154 | ```
155 |
156 | 1. 在视图层中读取
157 |
158 | 更新值已经做了 diff, 两次赋同一值将不会触发改变
159 |
160 | 采用了[westore](https://github.com/Tencent/westore) 的 json diff,用于对比文件并提取需要更改的路径, 用于最小化 setData
161 |
162 | 当该值被`setup`返回, 将进入 data 值, 可在模板中被读取到, 会自动解套,无需在模板中额外书写`.value`
163 |
164 | ```html
165 |
166 | {{ count }}
167 |
168 |
181 | ```
182 |
183 | ### 计算属性
184 |
185 | **`useComputed`**
186 | 返回一个 不可手动修改的 ref 对象。可以理解为没有 set 方法返回的 useRef
187 |
188 | ```js
189 | const count = useRef(1)
190 | const plusOne = useComputed(() => count.value + 1, [count])
191 |
192 | console.log(plusOne.value) // 2
193 | ```
194 |
195 | `参数`
196 |
197 | 1. `callback` 监听变化的回调, 返回任意值
198 | 2. `any[]` 这个框架没有做依赖收集, 需要用户主动传入所有的依赖, 当里面的依赖变化时, 会触发回调函数执行,计算
199 |
200 | 计算属性总是最少会执行一次,为了第一次赋值
201 |
202 | ---
203 |
204 | ### 监听 Ref 值更新
205 |
206 | **`useEffect`**
207 | 当被监听的 ref 对象变化时, 将触发, 返回值是个方法, 用于停止监听
208 |
209 | `参数`
210 |
211 | 1. `callback` 监听变化的回调
212 | 2. `any[]` 这个框架没有做依赖收集, 需要用户主动传入所有的依赖, 当里面的依赖变化时, 会触发回调函数执行
213 |
214 | ```js
215 | const count = useRef(1)
216 | const stopHandle = useEffect(() => {
217 | console.log("我发送了变化")
218 | stopHandle()
219 | }, [count])
220 |
221 | count.set(2)
222 | ```
223 |
224 | ---
225 |
226 | ### 声明周期函数
227 |
228 | 可以直接导入 `onXXX` 一族的函数来注册生命周期钩子:
229 | 特殊, Component 和 Page 都是 onLoad, onUnLoad, onReady
230 |
231 | ```js
232 | import { onLoad, onUnLoad onHide, onReady, onShow } from 'vue'
233 |
234 | const MyComponent = {
235 | setup() {
236 | onLoad(() => {
237 | console.log('onLoad!')
238 | })
239 | onUnLoad(() => {
240 | console.log('onUnLoad!')
241 | })
242 | onReady(() => {
243 | console.log('onReady!')
244 | })
245 | onHide(() => {
246 | console.log('updated!')
247 | })
248 | onShow(() => {
249 | console.log('unmounted!')
250 | })
251 | },
252 | }
253 |
254 | ```
255 |
256 | ## 高级功能
257 |
258 | ### 依赖注入
259 |
260 | 依赖注入参考了 angular, 这一点和 vue 的 inject,provied 有所区别一样
261 | 依赖注入除了逻辑复用外,还实现了组件树上共享数据,不再需要疯狂传递 props,疯狂 targetEvent 事件
262 |
263 | 这里直接上代码体现它的用处
264 |
265 | #### 需求
266 |
267 | 有个店铺消息模块,可以更新店铺名字,
268 | 有一个页面,上面需要展示店铺名字,他还有很多页面级别组件,需要修改姓名,也需要显示店铺姓名,传统主页面通过 props 传下去也可以,修改姓名的话,再通过事件传上来,调用页面上修改店铺姓名的方法。如果层级多就很麻烦,而且还没有 ts 提示
269 |
270 | #### 改用依赖注入
271 |
272 | 可以先创建公共的模块
273 |
274 | ```js
275 | function useShopInfo() {
276 | const shopInfo = useRef({ name: '店铺名字' });
277 | const updateShopName = (name: string) => {
278 | shopInfo.set(value => { ...value, name })
279 | }
280 |
281 | return {
282 | shopInfo,
283 | updateShopName
284 | }
285 | }
286 |
287 | ```
288 |
289 | 页面
290 |
291 | ```js
292 | import { useShopInfo } from "shopServices"
293 | definePage({
294 | provide: { useShopInfo },
295 | setup(props, { provide }) {
296 | const { useShopInfo } = provide
297 | return {
298 | shopInfo: useShopInfo.shopInfo,
299 | }
300 | },
301 | })
302 | ```
303 |
304 | 组件
305 |
306 | ```js
307 |
308 | import { useShopInfo } from 'shopServices';
309 | defineComponent({
310 | inject: {useShopInfo},
311 | setup(props, { inject } ) {
312 | const { useShopInfo } = inject
313 |
314 | return {
315 | shopInfo: useShopInfo.shopInfo
316 | onChangeName() {
317 | useShopInfo.updateShopName('along')
318 | }
319 | }
320 | }
321 | })
322 | ```
323 |
324 | 以上代码页面和组件将共用一个数据
325 | 因为 inject 将会往其父级寻找已经`实例`的该函数,如果组件数上没有找到,那么将会往 app 上寻找,如果还没有,那么自身将会`主动实例化`,最后一点和 vue 不一样,因为 vue 你还得考虑父级没有的情况.
326 |
327 | 注意了,找上级需要建立组件树, 因为小程序目前的 api 问题,需要开发者主动通过 在组件上写 `bind:component="$"` 建立上下关系, 因为目前小程序 api 问题
328 |
329 | 除了 `inject`, `provide` 方式,也可以使用 `useInject`, `useProvide` 来手动注入一些需要参数的`函数api`, 注意咯, 不同的函数会实现不同的注入
330 |
331 | ```js
332 |
333 |
334 |
335 | ```
336 |
337 | #### 我设想的结构
338 |
339 | hooks
340 |
341 | ```js
342 | // 用户信息
343 | function useUserInfo() {
344 | return {
345 | userInfo: useRef(),
346 | }
347 | }
348 | function useShopInfo() {
349 | return {
350 | shopInfo: useRef(),
351 | }
352 | }
353 | ```
354 |
355 | app
356 |
357 | ```js
358 | defineApp({
359 | provide: { useUserInfo, useShopInfo },
360 | })
361 | ```
362 |
363 | pageA
364 |
365 | ```js
366 | defineComponent({
367 | inject: { useUserInfo, useShopInfo },
368 | setup(props, { inject }) {
369 | const { useUserInfo, useShopInfo } = inject
370 |
371 | const onUpdate = () => {
372 | useUserInfo.update()
373 | }
374 |
375 | return {
376 | userInfo: useUserInfo.userInfo,
377 | onUpdate,
378 | }
379 | },
380 | })
381 | ```
382 |
383 | ### 不要这样做
384 |
385 | 1. setup 不能是异步
386 |
387 | 2. `useEffect`, `useComputed`尽量在 setup 内做, 如果不是的话,注意做好清除清除监听
388 |
389 | 3. 在未来某个时间 `useEffect`, `useComputed`, 在 setup 期间执行的监听操作都将绑定在该实例上, 在该实例销毁后, 也会同步取消监听事件, 如果你注册的监听,恰好某个组件执行了 setup, 会出现, 他销毁后, 你注册的监听不起效果了, 一开始是不做这样的处理的, 只是为了避免大量的取消监听的写法, 于是做了这样的处理
390 | 我也很纠结, 这个问题一旦碰上了, 那就很致命了, 哎, 可是也没有特别好的办法
391 |
392 | ---
393 |
394 | ### 注意
395 |
396 | 1. 暂不支持 ref 嵌套 ref 的情况, 也是可以支持的, 而且容易有问题, 就是 更改最外层的 ref 的值, 是否会能直接更改里面 ref 的值, 所以不支持这样
397 |
--------------------------------------------------------------------------------
/EXAMPLE.md:
--------------------------------------------------------------------------------
1 | ## 常见场景
2 |
3 | ### 分页加载
4 | 1. miniprogram-composition-api
5 | ```html
6 |
7 |
8 | {{item}}
9 |
10 |
11 |
12 |
50 | ```
51 | 2. mixins方案
52 | ```html
53 |
54 |
55 | {{item}}
56 |
57 |
58 |
59 |
96 |
97 | ```
98 |
99 |
100 | ### 分页加载:一个页面有两个列表,通过列表切换显示不同的列表
101 | 1. miniprogram-composition-api
102 | ```html
103 |
104 |
105 |
106 | {{item}}
107 |
108 |
109 |
110 |
111 |
112 | 成功的列表
113 |
114 |
115 |
116 |
117 | 失败的列表
118 |
119 |
120 |
121 |
122 |
123 |
184 | ```
185 | 2. mixins方案比较麻烦,要么拆组件维护各自的列表,要么公用一个列表,每次切换刷新
186 |
187 |
188 | ### 更新列表数据
189 | 以收件人为例, 进入收件人地址列表, 会有个`常用收件人列表`,以及下面分页加载的`正常的收件人列表`, 我还会再进入下一个页面,打开搜索页面,搜索到某个收件人后,对该`收件人地址`进行`更改收件人姓名`的操作,
190 | 我们需要实现的是 同步更新 `搜索页面的收件人列表`,`常用收件人列表`,`正常的收件人列表` 中那个地址
191 | 可能还希望,我有选择收件人的功能,如果他也是被更新的地址,也一起更新,例如Q版选择收件人
192 | 除了常用,我还有最近添加的收件人地址
193 |
194 | 
195 |
196 |
197 | > 那么用 miniprogram-composition-api怎么写
198 | 1. 我们只需要一个维护特殊的数组对象即可
199 |
200 | 我们可以建立一个service
201 | `consignee.service.js`
202 | ```js
203 |
204 | /** 用这个取代message */
205 | const event = useRef({type: '',query: {}})
206 | function useConsigneeList (params: {
207 | watchCreate: boolean
208 | }) {
209 | const list = useRef([])
210 | // 这段代码意思是监听event的变化, 相当于watch, 然后检测操作, 遍历list里面的内容,然后进行增删改查
211 | useEffect(() => {
212 | const {type, query} = event.value
213 | switch(type) {
214 | /** 更新收件人地址 */
215 | case 'update':
216 | list.set(value => {
217 | return value.map(v => {
218 | if (v.id === query.id) {
219 | return query
220 | }
221 | })
222 | })
223 | break:
224 | case 'delete':
225 | // 同样对象这个list对象进行操作
226 | list.set(value => value.filter(() => {
227 |
228 | }))
229 | break
230 | case 'add':
231 | // 这样就可以选择性的我这个列表是否要添加打印机
232 | if (params.watchCreate) {
233 |
234 | }
235 | break;
236 | }
237 | }, [event])
238 |
239 | return list
240 | }
241 |
242 | export default {
243 | useConsigneeList,
244 | /** 更新收件人信息要求调用这个 */
245 | async update(data) {
246 | await Api.Printer.update(data)
247 | event.set({
248 | type:'update',
249 | query: data
250 | })
251 | },
252 | // 移除
253 | async delte() {
254 | await Api.Printer.delete(data)
255 | event.set({
256 | type:'add'
257 | })
258 | }
259 | }
260 | ```
261 |
262 | 让我们看看页面
263 |
264 | 1. 编辑页面需要通过service更新地址
265 | ```js
266 | import { update } from './consignee.service.js'
267 |
268 | Component({
269 | methods: {
270 | async update() {
271 | const address = this.props.address
272 | await update(address)
273 | }
274 | }
275 | })
276 | ```
277 |
278 | 2. 列表页面
279 | ```js
280 | import { useConsigneeList } from './consignee.service.js'
281 |
282 | definePage(() => {
283 | const list = useConsigneeList()
284 | const common_list = useConsigneeList()
285 | const add_list = useConsigneeList({watchCreate: true})
286 |
287 | onLoad(() => {
288 | common_list.set(Api.Printer.Common().data)
289 | list.set(Api.Printer.getList().data)
290 | })
291 |
292 | return {
293 | list,
294 | common_list,
295 | add_list
296 | }
297 | })
298 |
299 | ```
300 |
301 | 现在列表名字你随便定了, 只需要使用useConsigneeList()返回给你的对象(容器就可以了),你往这容器里面塞值,更新的时候,会自动更新你容器里面的值,而且还会同步更新视图呢
302 |
303 |
304 | >传统options api怎么实现
305 | 具体点说,就是列表页面和搜索页面都监听更新,删除,添加方法,然后循环自己页面的this.data[x]数据,进行更新,删除,每个页面都需要显式的引入监听,更新,删除的时候发出通知,带来的缺点就是,我每多一个列表, 就得再弄一个监听这个列表,没多一个页面,就得在这个页面上也对我某个list,进行增删改查
306 |
307 |
308 | `收件人页面`
309 | ```js
310 |
311 | import mixinsSearchPanel from '../mixins/searchPanel';
312 | import mixinsSearchPanelList from '../mixins/searchPanelList';
313 |
314 | // 更新收件人地址的混入
315 | import mixinsUpdateConsignee from '.mixinsUpdateConsignee';
316 |
317 | Componet({
318 | mixins: [mixinsSearchPanel, mixinsSearchPanelList, mixinsUpdateConsignee]
319 | data: {
320 | commonList: [],
321 | list: [],
322 | addList: []
323 | },
324 | onLoad () {
325 | /** 获取常用的收件人地址,并赋值到 commonList 上 */
326 | Api.Printer.Common().then(({data}) => {
327 | this.setData({
328 | commonList: data
329 | })
330 | })
331 |
332 | this.onReset()
333 | },
334 |
335 | methods: {
336 | /** 下面应该是分页加载列表,为了好理解,直接这样看 */
337 | renderList() {
338 | const {data} = await this.searchList(Api.Printer.getList)
339 | if (data.page === 1) {
340 | return this.setData({
341 | list: data.list
342 | })
343 | }
344 |
345 | this.setData({
346 | list: this.data.list.concat(data.list)
347 | })
348 | }
349 | },
350 |
351 | onReachBottom() {
352 | this.Reset();
353 | },
354 |
355 | onPullDownRefresh() {
356 | this.Refresh(true)
357 | }
358 | })
359 | ```
360 |
361 | 写完了基本的收件人列表,就需要实现更新列表item的混入了
362 | 下面这个js也是用于监听然后对固定的几个列表进行增删改查了
363 | ```js
364 | import { Message } from '@clevok/message'
365 | export default class Mixins extends wepy.mixins {
366 | onLoad () {
367 | /** 更新 */
368 | this.handle = Message.on('update:consignee', (detail) => {
369 | // 遍历页面上的list列表,commonList列表,找到对应的id,进行更新
370 | ['list','commonList', 'addList'].forEach(key => {
371 | this.data[key].forEach(item => {
372 | if (item.id === detail.id) {
373 | // 更新收件人地址
374 | this.setData(/* **/)
375 | }
376 | })
377 | })
378 | })
379 | /** 添加 */
380 | this.handle2 = Message.on('update:create', (detail) => {
381 | //往addList添加我刚加上去的
382 | ['addList'].forEach(key => {
383 |
384 | })
385 | })
386 |
387 | /* 还有删除呢**/
388 | }
389 |
390 | onUnload () {
391 | // 移除监听
392 | this.handle && this.handle()
393 | }
394 | }
395 |
396 | ```
397 | 上面的混入将会被注入到搜索页面和列表页面,地址编辑后需要发出我的事件,才会更新列表中的数据
398 |
399 | ```js
400 | 编辑页面
401 | Component({
402 | methods: {
403 | async update() {
404 | const address = this.props.address
405 | await Api.Printer.update(address)
406 | Message.emit('update:consignee',)
407 | }
408 | }
409 | })
410 |
411 | ```
412 | 上面的能实现功能,但是带来以下几个问题
413 | 1. 你的页面将会有很多的事件监听这是其次, 当然其实还有一个选择功能,缓存当前选择的收件人,也需要同步更新删除,修改两个时间等等
414 | 2. 目前混入只会更新页面上的list,commonList,addList, 但是Q版创建包裹页面选择收件人地址页面,是叫 consigneeList 保存这个列表, 当然也可以加没问题,混入里面再加个事件,但是比较危险,因为你不一定看到这个混入内容,也限制了你的命名
415 | 3. 除了更新,还有新增,还有删除,事件多了起来,其实蛮难受的,毕竟都直接作用在你的页面上,如果其他地方也有更新收件人地址这个功能,我也是需要发出事件的,就上面代码看起似乎不是特别复杂
416 | 4. 还需要防止message命名冲突,还得注意移除事件监听
417 |
418 |
419 | ### 状态管理待更新
--------------------------------------------------------------------------------
/packages/reactivity/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "miniprogram-reactivity",
3 | "version": "0.3.2",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@babel/helper-module-imports": {
8 | "version": "7.10.4",
9 | "resolved": "http://192.168.0.233:4873/@babel%2fhelper-module-imports/-/helper-module-imports-7.10.4.tgz",
10 | "integrity": "sha1-TFxUvgS9MWcKc4J5fXW5+i5bViA=",
11 | "dev": true,
12 | "requires": {
13 | "@babel/types": "^7.10.4"
14 | }
15 | },
16 | "@babel/helper-validator-identifier": {
17 | "version": "7.10.4",
18 | "resolved": "http://192.168.0.233:4873/@babel%2fhelper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
19 | "integrity": "sha1-p4x6clHgH2FlEtMbEK3PUq2l4NI=",
20 | "dev": true
21 | },
22 | "@babel/runtime": {
23 | "version": "7.11.2",
24 | "resolved": "http://192.168.0.233:4873/@babel%2fruntime/-/runtime-7.11.2.tgz",
25 | "integrity": "sha1-9UnBPHVMxAuHZEufqfCaapX+BzY=",
26 | "requires": {
27 | "regenerator-runtime": "^0.13.4"
28 | }
29 | },
30 | "@babel/types": {
31 | "version": "7.11.5",
32 | "resolved": "http://192.168.0.233:4873/@babel%2ftypes/-/types-7.11.5.tgz",
33 | "integrity": "sha1-2d5XfQElLXfGgAzuA57mT691Zi0=",
34 | "dev": true,
35 | "requires": {
36 | "@babel/helper-validator-identifier": "^7.10.4",
37 | "lodash": "^4.17.19",
38 | "to-fast-properties": "^2.0.0"
39 | }
40 | },
41 | "@jsmini/clone": {
42 | "version": "0.4.2",
43 | "resolved": "http://192.168.0.233:4873/@jsmini%2fclone/-/clone-0.4.2.tgz",
44 | "integrity": "sha1-Wt0KYWi4FUVSNJ74IIbH+VYZX+E=",
45 | "requires": {
46 | "@babel/runtime": "^7.1.2",
47 | "@jsmini/type": "^0.9.1"
48 | }
49 | },
50 | "@jsmini/functional": {
51 | "version": "0.2.3",
52 | "resolved": "http://192.168.0.233:4873/@jsmini%2ffunctional/-/functional-0.2.3.tgz",
53 | "integrity": "sha1-Pgcud7wC1UQ2jg/lJJRFBomMq1U=",
54 | "requires": {
55 | "@babel/runtime": "^7.1.2",
56 | "@jsmini/type": "^0.9.0"
57 | }
58 | },
59 | "@jsmini/isequal": {
60 | "version": "0.4.2",
61 | "resolved": "http://192.168.0.233:4873/@jsmini%2fisequal/-/isequal-0.4.2.tgz",
62 | "integrity": "sha1-GPGetMuv2DKaK/Dk7wI0w/me/IQ=",
63 | "requires": {
64 | "@jsmini/functional": "^0.2.2",
65 | "@jsmini/type": "^0.9.0"
66 | }
67 | },
68 | "@jsmini/type": {
69 | "version": "0.9.2",
70 | "resolved": "http://192.168.0.233:4873/@jsmini%2ftype/-/type-0.9.2.tgz",
71 | "integrity": "sha1-01M5V7791KJL9ep2E//0U7WOL/k=",
72 | "requires": {
73 | "@babel/runtime": "^7.1.2"
74 | }
75 | },
76 | "@rollup/pluginutils": {
77 | "version": "3.1.0",
78 | "resolved": "http://192.168.0.233:4873/@rollup%2fpluginutils/-/pluginutils-3.1.0.tgz",
79 | "integrity": "sha1-cGtFJO5tyLEDs8mVUz5a1oDAK5s=",
80 | "dev": true,
81 | "requires": {
82 | "@types/estree": "0.0.39",
83 | "estree-walker": "^1.0.1",
84 | "picomatch": "^2.2.2"
85 | }
86 | },
87 | "@types/estree": {
88 | "version": "0.0.39",
89 | "resolved": "http://192.168.0.233:4873/@types%2festree/-/estree-0.0.39.tgz",
90 | "integrity": "sha1-4Xfmme4bjCLSMXTKqnQiZEOJUJ8=",
91 | "dev": true
92 | },
93 | "@types/node": {
94 | "version": "14.11.1",
95 | "resolved": "http://192.168.0.233:4873/@types%2fnode/-/node-14.11.1.tgz",
96 | "integrity": "sha1-Vq+QKtFX52P5umPWccOc2jGTyDU=",
97 | "dev": true
98 | },
99 | "@types/resolve": {
100 | "version": "0.0.8",
101 | "resolved": "http://192.168.0.233:4873/@types%2fresolve/-/resolve-0.0.8.tgz",
102 | "integrity": "sha1-8mB00jjgJlnjI84aE9BB7uKA4ZQ=",
103 | "dev": true,
104 | "requires": {
105 | "@types/node": "*"
106 | }
107 | },
108 | "builtin-modules": {
109 | "version": "3.1.0",
110 | "resolved": "http://192.168.0.233:4873/builtin-modules/-/builtin-modules-3.1.0.tgz",
111 | "integrity": "sha1-qtl8FRMet2tltQ7yCOdYTNdqdIQ=",
112 | "dev": true
113 | },
114 | "commondir": {
115 | "version": "1.0.1",
116 | "resolved": "http://192.168.0.233:4873/commondir/-/commondir-1.0.1.tgz",
117 | "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
118 | "dev": true
119 | },
120 | "estree-walker": {
121 | "version": "1.0.1",
122 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-1.0.1.tgz",
123 | "integrity": "sha1-MbxdYSyWtwQQa0d+bdXYqhOMtwA=",
124 | "dev": true
125 | },
126 | "find-cache-dir": {
127 | "version": "3.3.1",
128 | "resolved": "http://192.168.0.233:4873/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
129 | "integrity": "sha1-ibM/rUpGcNqpT4Vff74x1thP6IA=",
130 | "dev": true,
131 | "requires": {
132 | "commondir": "^1.0.1",
133 | "make-dir": "^3.0.2",
134 | "pkg-dir": "^4.1.0"
135 | }
136 | },
137 | "find-up": {
138 | "version": "4.1.0",
139 | "resolved": "http://192.168.0.233:4873/find-up/-/find-up-4.1.0.tgz",
140 | "integrity": "sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=",
141 | "dev": true,
142 | "requires": {
143 | "locate-path": "^5.0.0",
144 | "path-exists": "^4.0.0"
145 | }
146 | },
147 | "fs-extra": {
148 | "version": "8.1.0",
149 | "resolved": "http://192.168.0.233:4873/fs-extra/-/fs-extra-8.1.0.tgz",
150 | "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=",
151 | "dev": true,
152 | "requires": {
153 | "graceful-fs": "^4.2.0",
154 | "jsonfile": "^4.0.0",
155 | "universalify": "^0.1.0"
156 | }
157 | },
158 | "graceful-fs": {
159 | "version": "4.2.4",
160 | "resolved": "http://192.168.0.233:4873/graceful-fs/-/graceful-fs-4.2.4.tgz",
161 | "integrity": "sha1-Ila94U02MpWMRl68ltxGfKB6Kfs=",
162 | "dev": true
163 | },
164 | "is-module": {
165 | "version": "1.0.0",
166 | "resolved": "http://192.168.0.233:4873/is-module/-/is-module-1.0.0.tgz",
167 | "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=",
168 | "dev": true
169 | },
170 | "is-reference": {
171 | "version": "1.2.1",
172 | "resolved": "http://192.168.0.233:4873/is-reference/-/is-reference-1.2.1.tgz",
173 | "integrity": "sha1-iy2sCzcfS8mU/eq6nrVC0DAC0Lc=",
174 | "dev": true,
175 | "requires": {
176 | "@types/estree": "*"
177 | }
178 | },
179 | "jsonfile": {
180 | "version": "4.0.0",
181 | "resolved": "http://192.168.0.233:4873/jsonfile/-/jsonfile-4.0.0.tgz",
182 | "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
183 | "dev": true,
184 | "requires": {
185 | "graceful-fs": "^4.1.6"
186 | }
187 | },
188 | "locate-path": {
189 | "version": "5.0.0",
190 | "resolved": "http://192.168.0.233:4873/locate-path/-/locate-path-5.0.0.tgz",
191 | "integrity": "sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=",
192 | "dev": true,
193 | "requires": {
194 | "p-locate": "^4.1.0"
195 | }
196 | },
197 | "lodash": {
198 | "version": "4.17.20",
199 | "resolved": "http://192.168.0.233:4873/lodash/-/lodash-4.17.20.tgz",
200 | "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=",
201 | "dev": true
202 | },
203 | "lodash.clonedeep": {
204 | "version": "4.5.0",
205 | "resolved": "http://192.168.0.233:4873/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
206 | "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
207 | },
208 | "lodash.isequal": {
209 | "version": "4.5.0",
210 | "resolved": "http://192.168.0.233:4873/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
211 | "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
212 | },
213 | "magic-string": {
214 | "version": "0.25.7",
215 | "resolved": "http://192.168.0.233:4873/magic-string/-/magic-string-0.25.7.tgz",
216 | "integrity": "sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE=",
217 | "dev": true,
218 | "requires": {
219 | "sourcemap-codec": "^1.4.4"
220 | }
221 | },
222 | "make-dir": {
223 | "version": "3.1.0",
224 | "resolved": "http://192.168.0.233:4873/make-dir/-/make-dir-3.1.0.tgz",
225 | "integrity": "sha1-QV6WcEazp/HRhSd9hKpYIDcmoT8=",
226 | "dev": true,
227 | "requires": {
228 | "semver": "^6.0.0"
229 | }
230 | },
231 | "p-limit": {
232 | "version": "2.3.0",
233 | "resolved": "http://192.168.0.233:4873/p-limit/-/p-limit-2.3.0.tgz",
234 | "integrity": "sha1-PdM8ZHohT9//2DWTPrCG2g3CHbE=",
235 | "dev": true,
236 | "requires": {
237 | "p-try": "^2.0.0"
238 | }
239 | },
240 | "p-locate": {
241 | "version": "4.1.0",
242 | "resolved": "http://192.168.0.233:4873/p-locate/-/p-locate-4.1.0.tgz",
243 | "integrity": "sha1-o0KLtwiLOmApL2aRkni3wpetTwc=",
244 | "dev": true,
245 | "requires": {
246 | "p-limit": "^2.2.0"
247 | }
248 | },
249 | "p-try": {
250 | "version": "2.2.0",
251 | "resolved": "http://192.168.0.233:4873/p-try/-/p-try-2.2.0.tgz",
252 | "integrity": "sha1-yyhoVA4xPWHeWPr741zpAE1VQOY=",
253 | "dev": true
254 | },
255 | "path-exists": {
256 | "version": "4.0.0",
257 | "resolved": "http://192.168.0.233:4873/path-exists/-/path-exists-4.0.0.tgz",
258 | "integrity": "sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=",
259 | "dev": true
260 | },
261 | "path-parse": {
262 | "version": "1.0.6",
263 | "resolved": "http://192.168.0.233:4873/path-parse/-/path-parse-1.0.6.tgz",
264 | "integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=",
265 | "dev": true
266 | },
267 | "picomatch": {
268 | "version": "2.2.2",
269 | "resolved": "http://192.168.0.233:4873/picomatch/-/picomatch-2.2.2.tgz",
270 | "integrity": "sha1-IfMz6ba46v8CRo9RRupAbTRfTa0=",
271 | "dev": true
272 | },
273 | "pkg-dir": {
274 | "version": "4.2.0",
275 | "resolved": "http://192.168.0.233:4873/pkg-dir/-/pkg-dir-4.2.0.tgz",
276 | "integrity": "sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM=",
277 | "dev": true,
278 | "requires": {
279 | "find-up": "^4.0.0"
280 | }
281 | },
282 | "regenerator-runtime": {
283 | "version": "0.13.7",
284 | "resolved": "http://192.168.0.233:4873/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
285 | "integrity": "sha1-ysLazIoepnX+qrrriugziYrkb1U="
286 | },
287 | "resolve": {
288 | "version": "1.17.0",
289 | "resolved": "http://192.168.0.233:4873/resolve/-/resolve-1.17.0.tgz",
290 | "integrity": "sha1-sllBtUloIxzC0bt2p5y38sC/hEQ=",
291 | "dev": true,
292 | "requires": {
293 | "path-parse": "^1.0.6"
294 | }
295 | },
296 | "rollup-plugin-babel": {
297 | "version": "4.4.0",
298 | "resolved": "http://192.168.0.233:4873/rollup-plugin-babel/-/rollup-plugin-babel-4.4.0.tgz",
299 | "integrity": "sha1-0VvSWUZqnRrMvbL+L/8XxS0DCss=",
300 | "dev": true,
301 | "requires": {
302 | "@babel/helper-module-imports": "^7.0.0",
303 | "rollup-pluginutils": "^2.8.1"
304 | }
305 | },
306 | "rollup-plugin-commonjs": {
307 | "version": "10.1.0",
308 | "resolved": "http://192.168.0.233:4873/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz",
309 | "integrity": "sha1-QXrztUUDh44ITRJ6300cr4vrhvs=",
310 | "dev": true,
311 | "requires": {
312 | "estree-walker": "^0.6.1",
313 | "is-reference": "^1.1.2",
314 | "magic-string": "^0.25.2",
315 | "resolve": "^1.11.0",
316 | "rollup-pluginutils": "^2.8.1"
317 | },
318 | "dependencies": {
319 | "estree-walker": {
320 | "version": "0.6.1",
321 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-0.6.1.tgz",
322 | "integrity": "sha1-UwSRQ/QMbrkYsjZx0f4yGfOhs2I=",
323 | "dev": true
324 | }
325 | }
326 | },
327 | "rollup-plugin-node-resolve": {
328 | "version": "5.2.0",
329 | "resolved": "http://192.168.0.233:4873/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz",
330 | "integrity": "sha1-cw+T0Q7SAkc7H7VKWZen24xthSM=",
331 | "dev": true,
332 | "requires": {
333 | "@types/resolve": "0.0.8",
334 | "builtin-modules": "^3.1.0",
335 | "is-module": "^1.0.0",
336 | "resolve": "^1.11.1",
337 | "rollup-pluginutils": "^2.8.1"
338 | }
339 | },
340 | "rollup-plugin-typescript2": {
341 | "version": "0.27.2",
342 | "resolved": "http://192.168.0.233:4873/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.27.2.tgz",
343 | "integrity": "sha1-hxp/XSp3T5zvUNJdqGjuxyrMLtg=",
344 | "dev": true,
345 | "requires": {
346 | "@rollup/pluginutils": "^3.1.0",
347 | "find-cache-dir": "^3.3.1",
348 | "fs-extra": "8.1.0",
349 | "resolve": "1.17.0",
350 | "tslib": "2.0.1"
351 | }
352 | },
353 | "rollup-pluginutils": {
354 | "version": "2.8.2",
355 | "resolved": "http://192.168.0.233:4873/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
356 | "integrity": "sha1-cvKvB0i1kjZNvTOJ5gDlqURKNR4=",
357 | "dev": true,
358 | "requires": {
359 | "estree-walker": "^0.6.1"
360 | },
361 | "dependencies": {
362 | "estree-walker": {
363 | "version": "0.6.1",
364 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-0.6.1.tgz",
365 | "integrity": "sha1-UwSRQ/QMbrkYsjZx0f4yGfOhs2I=",
366 | "dev": true
367 | }
368 | }
369 | },
370 | "semver": {
371 | "version": "6.3.0",
372 | "resolved": "http://192.168.0.233:4873/semver/-/semver-6.3.0.tgz",
373 | "integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=",
374 | "dev": true
375 | },
376 | "sourcemap-codec": {
377 | "version": "1.4.8",
378 | "resolved": "http://192.168.0.233:4873/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
379 | "integrity": "sha1-6oBL2UhXQC5pktBaOO8a41qatMQ=",
380 | "dev": true
381 | },
382 | "to-fast-properties": {
383 | "version": "2.0.0",
384 | "resolved": "http://192.168.0.233:4873/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
385 | "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
386 | "dev": true
387 | },
388 | "tslib": {
389 | "version": "2.0.1",
390 | "resolved": "http://192.168.0.233:4873/tslib/-/tslib-2.0.1.tgz",
391 | "integrity": "sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4=",
392 | "dev": true
393 | },
394 | "typescript": {
395 | "version": "4.0.2",
396 | "resolved": "http://192.168.0.233:4873/typescript/-/typescript-4.0.2.tgz",
397 | "integrity": "sha1-fqfIh3fHI8aB4zv3mIvl0AjQWsI=",
398 | "dev": true
399 | },
400 | "universalify": {
401 | "version": "0.1.2",
402 | "resolved": "http://192.168.0.233:4873/universalify/-/universalify-0.1.2.tgz",
403 | "integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY=",
404 | "dev": true
405 | }
406 | }
407 | }
408 |
--------------------------------------------------------------------------------
/packages/miniprogram-composition-api/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "miniprogram-composition-api",
3 | "version": "0.3.5",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@babel/helper-module-imports": {
8 | "version": "7.10.4",
9 | "resolved": "http://192.168.0.233:4873/@babel%2fhelper-module-imports/-/helper-module-imports-7.10.4.tgz",
10 | "integrity": "sha1-TFxUvgS9MWcKc4J5fXW5+i5bViA=",
11 | "dev": true,
12 | "requires": {
13 | "@babel/types": "^7.10.4"
14 | }
15 | },
16 | "@babel/helper-validator-identifier": {
17 | "version": "7.10.4",
18 | "resolved": "http://192.168.0.233:4873/@babel%2fhelper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
19 | "integrity": "sha1-p4x6clHgH2FlEtMbEK3PUq2l4NI=",
20 | "dev": true
21 | },
22 | "@babel/runtime": {
23 | "version": "7.11.2",
24 | "resolved": "http://192.168.0.233:4873/@babel%2fruntime/-/runtime-7.11.2.tgz",
25 | "integrity": "sha1-9UnBPHVMxAuHZEufqfCaapX+BzY=",
26 | "requires": {
27 | "regenerator-runtime": "^0.13.4"
28 | }
29 | },
30 | "@babel/types": {
31 | "version": "7.11.5",
32 | "resolved": "http://192.168.0.233:4873/@babel%2ftypes/-/types-7.11.5.tgz",
33 | "integrity": "sha1-2d5XfQElLXfGgAzuA57mT691Zi0=",
34 | "dev": true,
35 | "requires": {
36 | "@babel/helper-validator-identifier": "^7.10.4",
37 | "lodash": "^4.17.19",
38 | "to-fast-properties": "^2.0.0"
39 | }
40 | },
41 | "@jsmini/clone": {
42 | "version": "0.4.2",
43 | "resolved": "http://192.168.0.233:4873/@jsmini%2fclone/-/clone-0.4.2.tgz",
44 | "integrity": "sha1-Wt0KYWi4FUVSNJ74IIbH+VYZX+E=",
45 | "requires": {
46 | "@babel/runtime": "^7.1.2",
47 | "@jsmini/type": "^0.9.1"
48 | }
49 | },
50 | "@jsmini/functional": {
51 | "version": "0.2.3",
52 | "resolved": "http://192.168.0.233:4873/@jsmini%2ffunctional/-/functional-0.2.3.tgz",
53 | "integrity": "sha1-Pgcud7wC1UQ2jg/lJJRFBomMq1U=",
54 | "requires": {
55 | "@babel/runtime": "^7.1.2",
56 | "@jsmini/type": "^0.9.0"
57 | }
58 | },
59 | "@jsmini/isequal": {
60 | "version": "0.4.2",
61 | "resolved": "http://192.168.0.233:4873/@jsmini%2fisequal/-/isequal-0.4.2.tgz",
62 | "integrity": "sha1-GPGetMuv2DKaK/Dk7wI0w/me/IQ=",
63 | "requires": {
64 | "@jsmini/functional": "^0.2.2",
65 | "@jsmini/type": "^0.9.0"
66 | }
67 | },
68 | "@jsmini/type": {
69 | "version": "0.9.2",
70 | "resolved": "http://192.168.0.233:4873/@jsmini%2ftype/-/type-0.9.2.tgz",
71 | "integrity": "sha1-01M5V7791KJL9ep2E//0U7WOL/k=",
72 | "requires": {
73 | "@babel/runtime": "^7.1.2"
74 | }
75 | },
76 | "@rollup/pluginutils": {
77 | "version": "3.1.0",
78 | "resolved": "http://192.168.0.233:4873/@rollup%2fpluginutils/-/pluginutils-3.1.0.tgz",
79 | "integrity": "sha1-cGtFJO5tyLEDs8mVUz5a1oDAK5s=",
80 | "dev": true,
81 | "requires": {
82 | "@types/estree": "0.0.39",
83 | "estree-walker": "^1.0.1",
84 | "picomatch": "^2.2.2"
85 | }
86 | },
87 | "@types/estree": {
88 | "version": "0.0.39",
89 | "resolved": "http://192.168.0.233:4873/@types%2festree/-/estree-0.0.39.tgz",
90 | "integrity": "sha1-4Xfmme4bjCLSMXTKqnQiZEOJUJ8=",
91 | "dev": true
92 | },
93 | "@types/node": {
94 | "version": "14.11.1",
95 | "resolved": "http://192.168.0.233:4873/@types%2fnode/-/node-14.11.1.tgz",
96 | "integrity": "sha1-Vq+QKtFX52P5umPWccOc2jGTyDU=",
97 | "dev": true
98 | },
99 | "@types/resolve": {
100 | "version": "0.0.8",
101 | "resolved": "http://192.168.0.233:4873/@types%2fresolve/-/resolve-0.0.8.tgz",
102 | "integrity": "sha1-8mB00jjgJlnjI84aE9BB7uKA4ZQ=",
103 | "dev": true,
104 | "requires": {
105 | "@types/node": "*"
106 | }
107 | },
108 | "builtin-modules": {
109 | "version": "3.1.0",
110 | "resolved": "http://192.168.0.233:4873/builtin-modules/-/builtin-modules-3.1.0.tgz",
111 | "integrity": "sha1-qtl8FRMet2tltQ7yCOdYTNdqdIQ=",
112 | "dev": true
113 | },
114 | "commondir": {
115 | "version": "1.0.1",
116 | "resolved": "http://192.168.0.233:4873/commondir/-/commondir-1.0.1.tgz",
117 | "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
118 | "dev": true
119 | },
120 | "estree-walker": {
121 | "version": "1.0.1",
122 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-1.0.1.tgz",
123 | "integrity": "sha1-MbxdYSyWtwQQa0d+bdXYqhOMtwA=",
124 | "dev": true
125 | },
126 | "find-cache-dir": {
127 | "version": "3.3.1",
128 | "resolved": "http://192.168.0.233:4873/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
129 | "integrity": "sha1-ibM/rUpGcNqpT4Vff74x1thP6IA=",
130 | "dev": true,
131 | "requires": {
132 | "commondir": "^1.0.1",
133 | "make-dir": "^3.0.2",
134 | "pkg-dir": "^4.1.0"
135 | }
136 | },
137 | "find-up": {
138 | "version": "4.1.0",
139 | "resolved": "http://192.168.0.233:4873/find-up/-/find-up-4.1.0.tgz",
140 | "integrity": "sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=",
141 | "dev": true,
142 | "requires": {
143 | "locate-path": "^5.0.0",
144 | "path-exists": "^4.0.0"
145 | }
146 | },
147 | "fs-extra": {
148 | "version": "8.1.0",
149 | "resolved": "http://192.168.0.233:4873/fs-extra/-/fs-extra-8.1.0.tgz",
150 | "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=",
151 | "dev": true,
152 | "requires": {
153 | "graceful-fs": "^4.2.0",
154 | "jsonfile": "^4.0.0",
155 | "universalify": "^0.1.0"
156 | }
157 | },
158 | "graceful-fs": {
159 | "version": "4.2.4",
160 | "resolved": "http://192.168.0.233:4873/graceful-fs/-/graceful-fs-4.2.4.tgz",
161 | "integrity": "sha1-Ila94U02MpWMRl68ltxGfKB6Kfs=",
162 | "dev": true
163 | },
164 | "is-module": {
165 | "version": "1.0.0",
166 | "resolved": "http://192.168.0.233:4873/is-module/-/is-module-1.0.0.tgz",
167 | "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=",
168 | "dev": true
169 | },
170 | "is-reference": {
171 | "version": "1.2.1",
172 | "resolved": "http://192.168.0.233:4873/is-reference/-/is-reference-1.2.1.tgz",
173 | "integrity": "sha1-iy2sCzcfS8mU/eq6nrVC0DAC0Lc=",
174 | "dev": true,
175 | "requires": {
176 | "@types/estree": "*"
177 | }
178 | },
179 | "jsonfile": {
180 | "version": "4.0.0",
181 | "resolved": "http://192.168.0.233:4873/jsonfile/-/jsonfile-4.0.0.tgz",
182 | "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
183 | "dev": true,
184 | "requires": {
185 | "graceful-fs": "^4.1.6"
186 | }
187 | },
188 | "locate-path": {
189 | "version": "5.0.0",
190 | "resolved": "http://192.168.0.233:4873/locate-path/-/locate-path-5.0.0.tgz",
191 | "integrity": "sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=",
192 | "dev": true,
193 | "requires": {
194 | "p-locate": "^4.1.0"
195 | }
196 | },
197 | "lodash": {
198 | "version": "4.17.20",
199 | "resolved": "http://192.168.0.233:4873/lodash/-/lodash-4.17.20.tgz",
200 | "integrity": "sha1-tEqbYpe8tpjxxRo1RaKzs2jVnFI=",
201 | "dev": true
202 | },
203 | "lodash.clonedeep": {
204 | "version": "4.5.0",
205 | "resolved": "http://192.168.0.233:4873/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
206 | "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
207 | },
208 | "lodash.isequal": {
209 | "version": "4.5.0",
210 | "resolved": "http://192.168.0.233:4873/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
211 | "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
212 | },
213 | "magic-string": {
214 | "version": "0.25.7",
215 | "resolved": "http://192.168.0.233:4873/magic-string/-/magic-string-0.25.7.tgz",
216 | "integrity": "sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE=",
217 | "dev": true,
218 | "requires": {
219 | "sourcemap-codec": "^1.4.4"
220 | }
221 | },
222 | "make-dir": {
223 | "version": "3.1.0",
224 | "resolved": "http://192.168.0.233:4873/make-dir/-/make-dir-3.1.0.tgz",
225 | "integrity": "sha1-QV6WcEazp/HRhSd9hKpYIDcmoT8=",
226 | "dev": true,
227 | "requires": {
228 | "semver": "^6.0.0"
229 | }
230 | },
231 | "miniprogram-api-typings": {
232 | "version": "3.0.2",
233 | "resolved": "http://192.168.0.233:4873/miniprogram-api-typings/-/miniprogram-api-typings-3.0.2.tgz",
234 | "integrity": "sha1-xyhJQodEz4hGJWnFcpGzMrr0wxk=",
235 | "dev": true
236 | },
237 | "p-limit": {
238 | "version": "2.3.0",
239 | "resolved": "http://192.168.0.233:4873/p-limit/-/p-limit-2.3.0.tgz",
240 | "integrity": "sha1-PdM8ZHohT9//2DWTPrCG2g3CHbE=",
241 | "dev": true,
242 | "requires": {
243 | "p-try": "^2.0.0"
244 | }
245 | },
246 | "p-locate": {
247 | "version": "4.1.0",
248 | "resolved": "http://192.168.0.233:4873/p-locate/-/p-locate-4.1.0.tgz",
249 | "integrity": "sha1-o0KLtwiLOmApL2aRkni3wpetTwc=",
250 | "dev": true,
251 | "requires": {
252 | "p-limit": "^2.2.0"
253 | }
254 | },
255 | "p-try": {
256 | "version": "2.2.0",
257 | "resolved": "http://192.168.0.233:4873/p-try/-/p-try-2.2.0.tgz",
258 | "integrity": "sha1-yyhoVA4xPWHeWPr741zpAE1VQOY=",
259 | "dev": true
260 | },
261 | "path-exists": {
262 | "version": "4.0.0",
263 | "resolved": "http://192.168.0.233:4873/path-exists/-/path-exists-4.0.0.tgz",
264 | "integrity": "sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=",
265 | "dev": true
266 | },
267 | "path-parse": {
268 | "version": "1.0.6",
269 | "resolved": "http://192.168.0.233:4873/path-parse/-/path-parse-1.0.6.tgz",
270 | "integrity": "sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=",
271 | "dev": true
272 | },
273 | "picomatch": {
274 | "version": "2.2.2",
275 | "resolved": "http://192.168.0.233:4873/picomatch/-/picomatch-2.2.2.tgz",
276 | "integrity": "sha1-IfMz6ba46v8CRo9RRupAbTRfTa0=",
277 | "dev": true
278 | },
279 | "pkg-dir": {
280 | "version": "4.2.0",
281 | "resolved": "http://192.168.0.233:4873/pkg-dir/-/pkg-dir-4.2.0.tgz",
282 | "integrity": "sha1-8JkTPfft5CLoHR2ESCcO6z5CYfM=",
283 | "dev": true,
284 | "requires": {
285 | "find-up": "^4.0.0"
286 | }
287 | },
288 | "regenerator-runtime": {
289 | "version": "0.13.7",
290 | "resolved": "http://192.168.0.233:4873/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
291 | "integrity": "sha1-ysLazIoepnX+qrrriugziYrkb1U="
292 | },
293 | "resolve": {
294 | "version": "1.17.0",
295 | "resolved": "http://192.168.0.233:4873/resolve/-/resolve-1.17.0.tgz",
296 | "integrity": "sha1-sllBtUloIxzC0bt2p5y38sC/hEQ=",
297 | "dev": true,
298 | "requires": {
299 | "path-parse": "^1.0.6"
300 | }
301 | },
302 | "rollup-plugin-babel": {
303 | "version": "4.4.0",
304 | "resolved": "http://192.168.0.233:4873/rollup-plugin-babel/-/rollup-plugin-babel-4.4.0.tgz",
305 | "integrity": "sha1-0VvSWUZqnRrMvbL+L/8XxS0DCss=",
306 | "dev": true,
307 | "requires": {
308 | "@babel/helper-module-imports": "^7.0.0",
309 | "rollup-pluginutils": "^2.8.1"
310 | }
311 | },
312 | "rollup-plugin-commonjs": {
313 | "version": "10.1.0",
314 | "resolved": "http://192.168.0.233:4873/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz",
315 | "integrity": "sha1-QXrztUUDh44ITRJ6300cr4vrhvs=",
316 | "dev": true,
317 | "requires": {
318 | "estree-walker": "^0.6.1",
319 | "is-reference": "^1.1.2",
320 | "magic-string": "^0.25.2",
321 | "resolve": "^1.11.0",
322 | "rollup-pluginutils": "^2.8.1"
323 | },
324 | "dependencies": {
325 | "estree-walker": {
326 | "version": "0.6.1",
327 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-0.6.1.tgz",
328 | "integrity": "sha1-UwSRQ/QMbrkYsjZx0f4yGfOhs2I=",
329 | "dev": true
330 | }
331 | }
332 | },
333 | "rollup-plugin-node-resolve": {
334 | "version": "5.2.0",
335 | "resolved": "http://192.168.0.233:4873/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz",
336 | "integrity": "sha1-cw+T0Q7SAkc7H7VKWZen24xthSM=",
337 | "dev": true,
338 | "requires": {
339 | "@types/resolve": "0.0.8",
340 | "builtin-modules": "^3.1.0",
341 | "is-module": "^1.0.0",
342 | "resolve": "^1.11.1",
343 | "rollup-pluginutils": "^2.8.1"
344 | }
345 | },
346 | "rollup-plugin-typescript2": {
347 | "version": "0.27.2",
348 | "resolved": "http://192.168.0.233:4873/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.27.2.tgz",
349 | "integrity": "sha1-hxp/XSp3T5zvUNJdqGjuxyrMLtg=",
350 | "dev": true,
351 | "requires": {
352 | "@rollup/pluginutils": "^3.1.0",
353 | "find-cache-dir": "^3.3.1",
354 | "fs-extra": "8.1.0",
355 | "resolve": "1.17.0",
356 | "tslib": "2.0.1"
357 | }
358 | },
359 | "rollup-pluginutils": {
360 | "version": "2.8.2",
361 | "resolved": "http://192.168.0.233:4873/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
362 | "integrity": "sha1-cvKvB0i1kjZNvTOJ5gDlqURKNR4=",
363 | "dev": true,
364 | "requires": {
365 | "estree-walker": "^0.6.1"
366 | },
367 | "dependencies": {
368 | "estree-walker": {
369 | "version": "0.6.1",
370 | "resolved": "http://192.168.0.233:4873/estree-walker/-/estree-walker-0.6.1.tgz",
371 | "integrity": "sha1-UwSRQ/QMbrkYsjZx0f4yGfOhs2I=",
372 | "dev": true
373 | }
374 | }
375 | },
376 | "semver": {
377 | "version": "6.3.0",
378 | "resolved": "http://192.168.0.233:4873/semver/-/semver-6.3.0.tgz",
379 | "integrity": "sha1-7gpkyK9ejO6mdoexM3YeG+y9HT0=",
380 | "dev": true
381 | },
382 | "sourcemap-codec": {
383 | "version": "1.4.8",
384 | "resolved": "http://192.168.0.233:4873/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
385 | "integrity": "sha1-6oBL2UhXQC5pktBaOO8a41qatMQ=",
386 | "dev": true
387 | },
388 | "to-fast-properties": {
389 | "version": "2.0.0",
390 | "resolved": "http://192.168.0.233:4873/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
391 | "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
392 | "dev": true
393 | },
394 | "tslib": {
395 | "version": "2.0.1",
396 | "resolved": "http://192.168.0.233:4873/tslib/-/tslib-2.0.1.tgz",
397 | "integrity": "sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4=",
398 | "dev": true
399 | },
400 | "typescript": {
401 | "version": "4.0.2",
402 | "resolved": "http://192.168.0.233:4873/typescript/-/typescript-4.0.2.tgz",
403 | "integrity": "sha1-fqfIh3fHI8aB4zv3mIvl0AjQWsI=",
404 | "dev": true
405 | },
406 | "universalify": {
407 | "version": "0.1.2",
408 | "resolved": "http://192.168.0.233:4873/universalify/-/universalify-0.1.2.tgz",
409 | "integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY=",
410 | "dev": true
411 | }
412 | }
413 | }
414 |
--------------------------------------------------------------------------------