@tarojs/runtime 4.0.0-alpha.0 → 4.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +11 -4
- package/dist/bom/URL.d.ts +51 -0
- package/dist/bom/URL.js +221 -0
- package/dist/bom/URL.js.map +1 -0
- package/dist/bom/URLSearchParams.d.ts +1 -0
- package/dist/bom/URLSearchParams.js +123 -0
- package/dist/bom/URLSearchParams.js.map +1 -0
- package/dist/bom/document.d.ts +2 -0
- package/dist/bom/document.js +39 -0
- package/dist/bom/document.js.map +1 -0
- package/dist/bom/getComputedStyle.d.ts +4 -0
- package/dist/bom/getComputedStyle.js +8 -0
- package/dist/bom/getComputedStyle.js.map +1 -0
- package/dist/bom/history.d.ts +30 -0
- package/dist/bom/history.js +121 -0
- package/dist/bom/history.js.map +1 -0
- package/dist/bom/location.d.ts +37 -0
- package/dist/bom/location.js +240 -0
- package/dist/bom/location.js.map +1 -0
- package/dist/bom/navigator.d.ts +1 -0
- package/dist/bom/navigator.js +24 -0
- package/dist/bom/navigator.js.map +1 -0
- package/dist/bom/raf.d.ts +5 -0
- package/dist/bom/raf.js +33 -0
- package/dist/bom/raf.js.map +1 -0
- package/dist/bom/window.d.ts +25 -0
- package/dist/bom/window.js +92 -0
- package/dist/bom/window.js.map +1 -0
- package/dist/constants/index.d.ts +59 -0
- package/dist/constants/index.js +63 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/current.d.ts +19 -0
- package/dist/current.js +9 -0
- package/dist/current.js.map +1 -0
- package/dist/dom/anchor-element.d.ts +13 -0
- package/dist/dom/anchor-element.js +54 -0
- package/dist/dom/anchor-element.js.map +1 -0
- package/dist/dom/class-list.d.ts +16 -0
- package/dist/dom/class-list.js +92 -0
- package/dist/dom/class-list.js.map +1 -0
- package/dist/dom/document.d.ts +21 -0
- package/dist/dom/document.js +80 -0
- package/dist/dom/document.js.map +1 -0
- package/dist/dom/element.d.ts +39 -0
- package/dist/dom/element.js +315 -0
- package/dist/dom/element.js.map +1 -0
- package/dist/dom/event-source.d.ts +7 -0
- package/dist/dom/event-source.js +17 -0
- package/dist/dom/event-source.js.map +1 -0
- package/dist/dom/event-target.d.ts +7 -0
- package/dist/dom/event-target.js +78 -0
- package/dist/dom/event-target.js.map +1 -0
- package/dist/dom/event.d.ts +23 -0
- package/dist/dom/event.js +151 -0
- package/dist/dom/event.js.map +1 -0
- package/dist/dom/form.d.ts +9 -0
- package/dist/dom/form.js +38 -0
- package/dist/dom/form.js.map +1 -0
- package/dist/dom/node.d.ts +76 -0
- package/dist/dom/node.js +292 -0
- package/dist/dom/node.js.map +1 -0
- package/dist/dom/node_types.d.ts +10 -0
- package/dist/dom/root.d.ts +15 -0
- package/dist/dom/root.js +169 -0
- package/dist/dom/root.js.map +1 -0
- package/dist/dom/style.d.ts +14 -0
- package/dist/dom/style.js +168 -0
- package/dist/dom/style.js.map +1 -0
- package/dist/dom/style_properties.d.ts +3 -0
- package/dist/dom/style_properties.js +186 -0
- package/dist/dom/style_properties.js.map +1 -0
- package/dist/dom/svg.d.ts +3 -0
- package/dist/dom/svg.js +8 -0
- package/dist/dom/svg.js.map +1 -0
- package/dist/dom/text.d.ts +14 -0
- package/dist/dom/text.js +41 -0
- package/dist/dom/text.js.map +1 -0
- package/dist/dom/transfer.d.ts +7 -0
- package/dist/dom/transfer.js +15 -0
- package/dist/dom/transfer.js.map +1 -0
- package/dist/dom/tree.d.ts +4 -0
- package/dist/dom/tree.js +38 -0
- package/dist/dom/tree.js.map +1 -0
- package/dist/dom-external/element.d.ts +3 -0
- package/dist/dom-external/element.js +29 -0
- package/dist/dom-external/element.js.map +1 -0
- package/dist/dom-external/index.d.ts +1 -0
- package/dist/dom-external/index.js +40 -0
- package/dist/dom-external/index.js.map +1 -0
- package/dist/dom-external/inner-html/html.d.ts +2 -0
- package/dist/dom-external/inner-html/html.js +28 -0
- package/dist/dom-external/inner-html/html.js.map +1 -0
- package/dist/dom-external/inner-html/parser.d.ts +25 -0
- package/dist/dom-external/inner-html/parser.js +216 -0
- package/dist/dom-external/inner-html/parser.js.map +1 -0
- package/dist/dom-external/inner-html/scaner.d.ts +30 -0
- package/dist/dom-external/inner-html/scaner.js +304 -0
- package/dist/dom-external/inner-html/scaner.js.map +1 -0
- package/dist/dom-external/inner-html/style.d.ts +27 -0
- package/dist/dom-external/inner-html/style.js +235 -0
- package/dist/dom-external/inner-html/style.js.map +1 -0
- package/dist/dom-external/inner-html/tags.d.ts +8 -0
- package/dist/dom-external/inner-html/tags.js +26 -0
- package/dist/dom-external/inner-html/tags.js.map +1 -0
- package/dist/dom-external/inner-html/utils.d.ts +1 -0
- package/dist/dom-external/inner-html/utils.js +12 -0
- package/dist/dom-external/inner-html/utils.js.map +1 -0
- package/dist/dom-external/mutation-observer/implements.d.ts +52 -0
- package/dist/dom-external/mutation-observer/implements.js +108 -0
- package/dist/dom-external/mutation-observer/implements.js.map +1 -0
- package/dist/dom-external/mutation-observer/index.d.ts +13 -0
- package/dist/dom-external/mutation-observer/index.js +35 -0
- package/dist/dom-external/mutation-observer/index.js.map +1 -0
- package/dist/dom-external/mutation-observer/record.d.ts +24 -0
- package/dist/dom-external/node.d.ts +11 -0
- package/dist/dom-external/node.js +75 -0
- package/dist/dom-external/node.js.map +1 -0
- package/dist/dsl/common.d.ts +15 -0
- package/dist/dsl/common.js +337 -0
- package/dist/dsl/common.js.map +1 -0
- package/dist/dsl/instance.d.ts +84 -0
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/emitter/emitter.js +7 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.js +9 -0
- package/dist/env.js.map +1 -0
- package/dist/hydrate.d.ts +10 -0
- package/dist/hydrate.js +91 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/{runtime.h5.js → index.cjs.js} +4286 -2482
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/element.d.ts +4 -0
- package/dist/interface/event-target.d.ts +11 -0
- package/dist/interface/event.d.ts +15 -0
- package/dist/interface/hydrate.d.ts +29 -0
- package/dist/interface/index.d.ts +7 -0
- package/dist/interface/node.d.ts +7 -0
- package/dist/interface/options.d.ts +16 -0
- package/dist/interface/utils.d.ts +2 -0
- package/dist/next-tick.d.ts +2 -0
- package/dist/next-tick.js +47 -0
- package/dist/next-tick.js.map +1 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +7 -0
- package/dist/options.js.map +1 -0
- package/dist/perf.d.ts +9 -0
- package/dist/perf.js +49 -0
- package/dist/perf.js.map +1 -0
- package/dist/polyfill/array.d.ts +2 -0
- package/dist/polyfill/array.js +56 -0
- package/dist/polyfill/array.js.map +1 -0
- package/dist/polyfill/index.d.ts +2 -0
- package/dist/polyfill/index.js +34 -0
- package/dist/polyfill/index.js.map +1 -0
- package/dist/polyfill/intersection-observer.d.ts +1 -0
- package/dist/polyfill/intersection-observer.js +600 -0
- package/dist/polyfill/intersection-observer.js.map +1 -0
- package/dist/polyfill/object.d.ts +3 -0
- package/dist/polyfill/object.js +102 -0
- package/dist/polyfill/object.js.map +1 -0
- package/dist/runtime.esm.js +4119 -3315
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/cache.d.ts +12 -0
- package/dist/utils/cache.js +27 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +25 -0
- package/dist/utils/index.js +99 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/lodash.js +32 -0
- package/dist/utils/lodash.js.map +1 -0
- package/dist/utils/router.d.ts +7 -0
- package/dist/utils/router.js +24 -0
- package/dist/utils/router.js.map +1 -0
- package/package.json +22 -26
- package/dist/runtime.cjs.d.ts +0 -799
- package/dist/runtime.cjs.js +0 -4623
- package/dist/runtime.esm.d.ts +0 -799
- package/dist/runtime.h5.d.ts +0 -799
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { internalComponents } from '@tarojs/shared';
|
|
2
|
+
|
|
3
|
+
function makeMap(str, expectsLowerCase) {
|
|
4
|
+
const map = Object.create(null);
|
|
5
|
+
const list = str.split(',');
|
|
6
|
+
for (let i = 0; i < list.length; i++) {
|
|
7
|
+
map[list[i]] = true;
|
|
8
|
+
}
|
|
9
|
+
return val => !!map[val.toLowerCase()] ;
|
|
10
|
+
}
|
|
11
|
+
const specialMiniElements = {
|
|
12
|
+
img: 'image',
|
|
13
|
+
iframe: 'web-view'
|
|
14
|
+
};
|
|
15
|
+
const internalCompsList = Object.keys(internalComponents)
|
|
16
|
+
.map(i => i.toLowerCase())
|
|
17
|
+
.join(',');
|
|
18
|
+
// https://developers.weixin.qq.com/miniprogram/dev/component
|
|
19
|
+
const isMiniElements = makeMap(internalCompsList);
|
|
20
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
|
|
21
|
+
const isInlineElements = makeMap('a,i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b');
|
|
22
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
|
|
23
|
+
const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt');
|
|
24
|
+
|
|
25
|
+
export { isBlockElements, isInlineElements, isMiniElements, makeMap, specialMiniElements };
|
|
26
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sources":["../../../src/dom-external/inner-html/tags.ts"],"sourcesContent":["import { internalComponents } from '@tarojs/shared'\n\nexport function makeMap (\n str: string,\n expectsLowerCase?: boolean\n): (key: string) => boolean {\n const map: Record<string, boolean> = Object.create(null)\n const list: Array<string> = str.split(',')\n for (let i = 0; i < list.length; i++) {\n map[list[i]] = true\n }\n return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]\n}\n\nexport const specialMiniElements = {\n img: 'image',\n iframe: 'web-view'\n}\n\nconst internalCompsList = Object.keys(internalComponents)\n .map(i => i.toLowerCase())\n .join(',')\n\n// https://developers.weixin.qq.com/miniprogram/dev/component\nexport const isMiniElements = makeMap(internalCompsList, true)\n\n// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements\nexport const isInlineElements = makeMap('a,i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true)\n\n// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements\nexport const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true)\n"],"names":[],"mappings":";;AAEgB,SAAA,OAAO,CACrB,GAAW,EACX,gBAA0B,EAAA;IAE1B,MAAM,GAAG,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxD,MAAM,IAAI,GAAkB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAC1C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;KACpB;AACD,IAAA,OAA0B,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAoB,CAAA;AAC/E,CAAC;AAEY,MAAA,mBAAmB,GAAG;AACjC,IAAA,GAAG,EAAE,OAAO;AACZ,IAAA,MAAM,EAAE,UAAU;EACnB;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;KACtD,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;KACzB,IAAI,CAAC,GAAG,CAAC,CAAA;AAEZ;AACa,MAAA,cAAc,GAAG,OAAO,CAAC,iBAAuB,EAAC;AAE9D;AACa,MAAA,gBAAgB,GAAG,OAAO,CAAC,mNAAyN,EAAC;AAElQ;AACa,MAAA,eAAe,GAAG,OAAO,CAAC,8KAAoL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unquote(str: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function unquote(str) {
|
|
2
|
+
const car = str.charAt(0);
|
|
3
|
+
const end = str.length - 1;
|
|
4
|
+
const isQuoteStart = car === '"' || car === "'";
|
|
5
|
+
if (isQuoteStart && car === str.charAt(end)) {
|
|
6
|
+
return str.slice(1, end);
|
|
7
|
+
}
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { unquote };
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/dom-external/inner-html/utils.ts"],"sourcesContent":["export function unquote (str: string): string {\n const car = str.charAt(0)\n const end = str.length - 1\n const isQuoteStart = car === '\"' || car === \"'\"\n if (isQuoteStart && car === str.charAt(end)) {\n return str.slice(1, end)\n }\n return str\n}\n"],"names":[],"mappings":"AAAM,SAAU,OAAO,CAAE,GAAW,EAAA;IAClC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AACzB,IAAA,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAA;IAC1B,MAAM,YAAY,GAAG,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,CAAA;IAC/C,IAAI,YAAY,IAAI,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QAC3C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;KACzB;AACD,IAAA,OAAO,GAAG,CAAA;AACZ;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { TaroNode } from '../../dom/node';
|
|
2
|
+
import type { MutationRecord } from './record';
|
|
3
|
+
export type MutationCallback = (mutations: MutationRecord[]) => any;
|
|
4
|
+
/**
|
|
5
|
+
* @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit
|
|
6
|
+
*/
|
|
7
|
+
export interface MutationObserverInit {
|
|
8
|
+
attributeFilter?: string[];
|
|
9
|
+
attributeOldValue?: boolean;
|
|
10
|
+
attributes?: boolean;
|
|
11
|
+
characterData?: boolean;
|
|
12
|
+
characterDataOldValue?: boolean;
|
|
13
|
+
childList?: boolean;
|
|
14
|
+
subtree?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The MutationObserver provides the ability
|
|
18
|
+
* to watch for changes being made to the DOM tree.
|
|
19
|
+
* It will invoke a specified callback function
|
|
20
|
+
* when DOM changes occur.
|
|
21
|
+
* @see https://dom.spec.whatwg.org/#mutationobserver
|
|
22
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
23
|
+
*/
|
|
24
|
+
export declare class MutationObserverImpl {
|
|
25
|
+
callback: MutationCallback;
|
|
26
|
+
target: TaroNode | null;
|
|
27
|
+
options: MutationObserverInit;
|
|
28
|
+
records: MutationRecord[];
|
|
29
|
+
constructor(callback: MutationCallback);
|
|
30
|
+
/**
|
|
31
|
+
* Configures the MutationObserver
|
|
32
|
+
* to begin receiving notifications
|
|
33
|
+
* through its callback function
|
|
34
|
+
* when DOM changes matching the given options occur.
|
|
35
|
+
*
|
|
36
|
+
* Options matching is to be implemented.
|
|
37
|
+
*/
|
|
38
|
+
observe(target: TaroNode, options?: MutationObserverInit): void;
|
|
39
|
+
/**
|
|
40
|
+
* Stop the MutationObserver instance
|
|
41
|
+
* from receiving further notifications
|
|
42
|
+
* until and unless observe() is called again.
|
|
43
|
+
*/
|
|
44
|
+
disconnect(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes all pending notifications
|
|
47
|
+
* from the MutationObserver's notification queue
|
|
48
|
+
* and returns them in a new Array of MutationRecord objects.
|
|
49
|
+
*/
|
|
50
|
+
takeRecords(): MutationRecord[];
|
|
51
|
+
}
|
|
52
|
+
export declare function recordMutation(record: MutationRecord): void;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const observers = [];
|
|
2
|
+
/**
|
|
3
|
+
* The MutationObserver provides the ability
|
|
4
|
+
* to watch for changes being made to the DOM tree.
|
|
5
|
+
* It will invoke a specified callback function
|
|
6
|
+
* when DOM changes occur.
|
|
7
|
+
* @see https://dom.spec.whatwg.org/#mutationobserver
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
9
|
+
*/
|
|
10
|
+
class MutationObserverImpl {
|
|
11
|
+
constructor(callback) {
|
|
12
|
+
this.records = [];
|
|
13
|
+
this.callback = callback;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configures the MutationObserver
|
|
17
|
+
* to begin receiving notifications
|
|
18
|
+
* through its callback function
|
|
19
|
+
* when DOM changes matching the given options occur.
|
|
20
|
+
*
|
|
21
|
+
* Options matching is to be implemented.
|
|
22
|
+
*/
|
|
23
|
+
observe(target, options) {
|
|
24
|
+
this.disconnect();
|
|
25
|
+
this.target = target;
|
|
26
|
+
this.options = options || {};
|
|
27
|
+
observers.push(this);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Stop the MutationObserver instance
|
|
31
|
+
* from receiving further notifications
|
|
32
|
+
* until and unless observe() is called again.
|
|
33
|
+
*/
|
|
34
|
+
disconnect() {
|
|
35
|
+
this.target = null;
|
|
36
|
+
const index = observers.indexOf(this);
|
|
37
|
+
if (index >= 0) {
|
|
38
|
+
observers.splice(index, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Removes all pending notifications
|
|
43
|
+
* from the MutationObserver's notification queue
|
|
44
|
+
* and returns them in a new Array of MutationRecord objects.
|
|
45
|
+
*/
|
|
46
|
+
takeRecords() {
|
|
47
|
+
return this.records.splice(0, this.records.length);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Match two TaroNodes by sid. */
|
|
51
|
+
const sidMatches = (observerTarget, target) => {
|
|
52
|
+
return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
|
|
53
|
+
};
|
|
54
|
+
const isConcerned = (record, options) => {
|
|
55
|
+
const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
|
|
56
|
+
switch (record.type) {
|
|
57
|
+
case "characterData" /* MutationRecordType.CHARACTER_DATA */:
|
|
58
|
+
if (characterData) {
|
|
59
|
+
if (!characterDataOldValue)
|
|
60
|
+
record.oldValue = null;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
case "attributes" /* MutationRecordType.ATTRIBUTES */:
|
|
65
|
+
if (attributes) {
|
|
66
|
+
if (!attributeOldValue)
|
|
67
|
+
record.oldValue = null;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
case "childList" /* MutationRecordType.CHILD_LIST */:
|
|
72
|
+
if (childList) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
let pendingMuatations = false;
|
|
79
|
+
function logMutation(observer, record) {
|
|
80
|
+
observer.records.push(record);
|
|
81
|
+
if (!pendingMuatations) {
|
|
82
|
+
pendingMuatations = true;
|
|
83
|
+
Promise
|
|
84
|
+
.resolve()
|
|
85
|
+
.then(() => {
|
|
86
|
+
pendingMuatations = false;
|
|
87
|
+
observers.forEach(observer => {
|
|
88
|
+
return observer.callback(observer.takeRecords());
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function recordMutation(record) {
|
|
94
|
+
observers.forEach(observer => {
|
|
95
|
+
const { options } = observer;
|
|
96
|
+
for (let t = record.target; t; t = t.parentNode) {
|
|
97
|
+
if (sidMatches(observer.target, t) && isConcerned(record, options)) {
|
|
98
|
+
logMutation(observer, record);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (!options.subtree)
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { MutationObserverImpl, recordMutation };
|
|
108
|
+
//# sourceMappingURL=implements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implements.js","sources":["../../../src/dom-external/mutation-observer/implements.ts"],"sourcesContent":["import { MutationRecordType } from './record'\n\nimport type { TaroNode } from '../../dom/node'\nimport type { MutationRecord } from './record'\n\nexport type MutationCallback = (mutations: MutationRecord[]) => any\n\n/**\n * @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit\n */\nexport interface MutationObserverInit {\n attributeFilter?: string[]\n attributeOldValue?: boolean\n attributes?: boolean\n characterData?: boolean\n characterDataOldValue?: boolean\n childList?: boolean\n subtree?: boolean\n}\n\nconst observers: MutationObserverImpl[] = []\n\n/**\n * The MutationObserver provides the ability\n * to watch for changes being made to the DOM tree.\n * It will invoke a specified callback function\n * when DOM changes occur.\n * @see https://dom.spec.whatwg.org/#mutationobserver\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver\n */\nexport class MutationObserverImpl {\n public callback: MutationCallback\n public target: TaroNode | null\n public options: MutationObserverInit\n public records: MutationRecord[] = []\n\n constructor (callback: MutationCallback) {\n this.callback = callback\n }\n\n /**\n * Configures the MutationObserver\n * to begin receiving notifications\n * through its callback function\n * when DOM changes matching the given options occur.\n *\n * Options matching is to be implemented.\n */\n observe (target: TaroNode, options?: MutationObserverInit): void {\n this.disconnect()\n this.target = target\n this.options = options || {}\n\n observers.push(this)\n }\n\n /**\n * Stop the MutationObserver instance\n * from receiving further notifications\n * until and unless observe() is called again.\n */\n disconnect (): void {\n this.target = null\n\n const index = observers.indexOf(this)\n if (index >= 0) {\n observers.splice(index, 1)\n }\n }\n\n /**\n * Removes all pending notifications\n * from the MutationObserver's notification queue\n * and returns them in a new Array of MutationRecord objects.\n */\n takeRecords (): MutationRecord[] {\n return this.records.splice(0, this.records.length)\n }\n}\n\n/** Match two TaroNodes by sid. */\nconst sidMatches = (\n observerTarget: TaroNode | null,\n target: TaroNode | null\n): boolean => {\n return !!observerTarget && observerTarget.sid === target?.sid\n}\n\nconst isConcerned = (record: MutationRecord, options: MutationObserverInit) => {\n const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options\n switch (record.type) {\n case MutationRecordType.CHARACTER_DATA:\n if (characterData) {\n if (!characterDataOldValue) record.oldValue = null\n return true\n }\n return false\n case MutationRecordType.ATTRIBUTES:\n if (attributes) {\n if (!attributeOldValue) record.oldValue = null\n return true\n }\n return false\n case MutationRecordType.CHILD_LIST:\n if (childList) {\n return true\n }\n return false\n }\n}\n\nlet pendingMuatations = false\n\nfunction logMutation (observer: MutationObserverImpl, record: MutationRecord) {\n observer.records.push(record)\n if (!pendingMuatations) {\n pendingMuatations = true\n Promise\n .resolve()\n .then(() => {\n pendingMuatations = false\n observers.forEach(observer => {\n return observer.callback(observer.takeRecords())\n })\n })\n }\n}\n\nexport function recordMutation (record: MutationRecord) {\n observers.forEach(observer => {\n const { options } = observer\n for (let t: TaroNode | null = record.target; t; t = t.parentNode) {\n if (sidMatches(observer.target, t) && isConcerned(record, options)) {\n logMutation(observer, record)\n break\n }\n if (!options.subtree) break\n }\n })\n}\n"],"names":[],"mappings":"AAoBA,MAAM,SAAS,GAA2B,EAAE,CAAA;AAE5C;;;;;;;AAOG;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AAA;AAC5B,QAAA,KAAK,IAAI,CAAC,GAAoB,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE;AAChE,YAAA,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;AAClE,gBAAA,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAC7B,MAAK;aACN;YACD,IAAI,CAAC,OAAO,CAAC,OAAO;gBAAE,MAAK;SAC5B;AACH,KAAC,CAAC,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MutationObserverImpl } from './implements';
|
|
2
|
+
import { MutationRecord, MutationRecordType } from './record';
|
|
3
|
+
import type { TaroNode } from '../../dom/node';
|
|
4
|
+
import type { MutationCallback, MutationObserverInit } from './implements';
|
|
5
|
+
export declare class MutationObserver {
|
|
6
|
+
core: Pick<MutationObserverImpl, 'observe' | 'disconnect' | 'takeRecords'>;
|
|
7
|
+
constructor(callback: MutationCallback);
|
|
8
|
+
observe(...args: [TaroNode, MutationObserverInit?]): void;
|
|
9
|
+
disconnect(): void;
|
|
10
|
+
takeRecords(): MutationRecord[];
|
|
11
|
+
static record(record: MutationRecord): void;
|
|
12
|
+
}
|
|
13
|
+
export { MutationRecordType };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { noop } from '@tarojs/shared';
|
|
2
|
+
import { MutationObserverImpl, recordMutation } from './implements.js';
|
|
3
|
+
|
|
4
|
+
class MutationObserver {
|
|
5
|
+
constructor(callback) {
|
|
6
|
+
if (ENABLE_MUTATION_OBSERVER) {
|
|
7
|
+
this.core = new MutationObserverImpl(callback);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
11
|
+
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
|
|
12
|
+
}
|
|
13
|
+
this.core = {
|
|
14
|
+
observe: noop,
|
|
15
|
+
disconnect: noop,
|
|
16
|
+
takeRecords: noop
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
observe(...args) {
|
|
21
|
+
this.core.observe(...args);
|
|
22
|
+
}
|
|
23
|
+
disconnect() {
|
|
24
|
+
this.core.disconnect();
|
|
25
|
+
}
|
|
26
|
+
takeRecords() {
|
|
27
|
+
return this.core.takeRecords();
|
|
28
|
+
}
|
|
29
|
+
static record(record) {
|
|
30
|
+
recordMutation(record);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { MutationObserver };
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/dom-external/mutation-observer/index.ts"],"sourcesContent":["import { noop } from '@tarojs/shared'\n\nimport { MutationObserverImpl, recordMutation } from './implements'\nimport { MutationRecord, MutationRecordType } from './record'\n\nimport type { TaroNode } from '../../dom/node'\nimport type { MutationCallback, MutationObserverInit } from './implements'\n\ndeclare const ENABLE_MUTATION_OBSERVER: boolean\n\nexport class MutationObserver {\n core: Pick<MutationObserverImpl, 'observe' | 'disconnect' | 'takeRecords'>\n\n constructor (callback: MutationCallback) {\n if (ENABLE_MUTATION_OBSERVER) {\n this.core = new MutationObserverImpl(callback)\n } else {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \\'mini.runtime.enableMutationObserver: true\\'')\n }\n this.core = {\n observe: noop,\n disconnect: noop,\n takeRecords: (noop as () => any)\n }\n }\n }\n\n public observe (...args: [TaroNode, MutationObserverInit?]) {\n this.core.observe(...args)\n }\n\n public disconnect () {\n this.core.disconnect()\n }\n\n public takeRecords () {\n return this.core.takeRecords()\n }\n\n static record (record: MutationRecord) {\n recordMutation(record)\n }\n}\n\nexport {\n MutationRecordType\n}\n"],"names":[],"mappings":";;;MAUa,gBAAgB,CAAA;AAG3B,IAAA,WAAA,CAAa,QAA0B,EAAA;QACrC,IAAI,wBAAwB,EAAE;YAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAA;SAC/C;aAAM;YACL,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;AACzC,gBAAA,OAAO,CAAC,IAAI,CAAC,oGAAoG,CAAC,CAAA;aACnH;YACD,IAAI,CAAC,IAAI,GAAG;AACV,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,WAAW,EAAG,IAAkB;aACjC,CAAA;SACF;KACF;IAEM,OAAO,CAAE,GAAG,IAAuC,EAAA;QACxD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;KAC3B;IAEM,UAAU,GAAA;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAA;KACvB;IAEM,WAAW,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;KAC/B;IAED,OAAO,MAAM,CAAE,MAAsB,EAAA;QACnC,cAAc,CAAC,MAAM,CAAC,CAAA;KACvB;AACF;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TaroNode } from '../../dom/node';
|
|
2
|
+
/**
|
|
3
|
+
* A MutationRecord represents an individual DOM mutation.
|
|
4
|
+
* It is the object that is passed to MutationObserver's callback.
|
|
5
|
+
* @see https://dom.spec.whatwg.org/#interface-mutationrecord
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord
|
|
7
|
+
*/
|
|
8
|
+
export interface MutationRecord {
|
|
9
|
+
readonly target: TaroNode;
|
|
10
|
+
readonly addedNodes?: TaroNode[];
|
|
11
|
+
readonly removedNodes?: TaroNode[];
|
|
12
|
+
readonly previousSibling?: TaroNode | null;
|
|
13
|
+
readonly nextSibling?: TaroNode | null;
|
|
14
|
+
readonly attributeName?: string | null;
|
|
15
|
+
readonly attributeNamespace?: string | null;
|
|
16
|
+
oldValue?: string | null;
|
|
17
|
+
readonly type: MutationRecordType;
|
|
18
|
+
readonly value?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const enum MutationRecordType {
|
|
21
|
+
ATTRIBUTES = "attributes",
|
|
22
|
+
CHARACTER_DATA = "characterData",
|
|
23
|
+
CHILD_LIST = "childList"
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaroNode } from '../dom/node';
|
|
2
|
+
export type IPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';
|
|
3
|
+
/**
|
|
4
|
+
* An implementation of `Element.insertAdjacentHTML()`
|
|
5
|
+
* to support Vue 3 with a version of or greater than `vue@3.1.2`
|
|
6
|
+
*/
|
|
7
|
+
export declare function insertAdjacentHTML(this: TaroNode, position: IPosition, html: string): void;
|
|
8
|
+
export declare function cloneNode(this: TaroNode, isDeep?: boolean): any;
|
|
9
|
+
export declare function contains(this: TaroNode, node: TaroNode & {
|
|
10
|
+
id?: string;
|
|
11
|
+
}): boolean;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PROPS, DATASET, OBJECT, STYLE } from '../constants/index.js';
|
|
2
|
+
import { parser } from './inner-html/parser.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An implementation of `Element.insertAdjacentHTML()`
|
|
6
|
+
* to support Vue 3 with a version of or greater than `vue@3.1.2`
|
|
7
|
+
*/
|
|
8
|
+
function insertAdjacentHTML(position, html) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const parsedNodes = parser(html, this.ownerDocument);
|
|
11
|
+
for (let i = 0; i < parsedNodes.length; i++) {
|
|
12
|
+
const n = parsedNodes[i];
|
|
13
|
+
switch (position) {
|
|
14
|
+
case 'beforebegin':
|
|
15
|
+
(_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(n, this);
|
|
16
|
+
break;
|
|
17
|
+
case 'afterbegin':
|
|
18
|
+
if (this.hasChildNodes()) {
|
|
19
|
+
this.insertBefore(n, this.childNodes[0]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.appendChild(n);
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
case 'beforeend':
|
|
26
|
+
this.appendChild(n);
|
|
27
|
+
break;
|
|
28
|
+
case 'afterend':
|
|
29
|
+
(_b = this.parentNode) === null || _b === void 0 ? void 0 : _b.appendChild(n);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function cloneNode(isDeep = false) {
|
|
35
|
+
const document = this.ownerDocument;
|
|
36
|
+
let newNode;
|
|
37
|
+
if (this.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
38
|
+
newNode = document.createElement(this.nodeName);
|
|
39
|
+
}
|
|
40
|
+
else if (this.nodeType === 3 /* NodeType.TEXT_NODE */) {
|
|
41
|
+
newNode = document.createTextNode('');
|
|
42
|
+
}
|
|
43
|
+
for (const key in this) {
|
|
44
|
+
const value = this[key];
|
|
45
|
+
// eslint-disable-next-line valid-typeof
|
|
46
|
+
if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {
|
|
47
|
+
newNode[key] = Object.assign({}, value);
|
|
48
|
+
}
|
|
49
|
+
else if (key === '_value') {
|
|
50
|
+
newNode[key] = value;
|
|
51
|
+
}
|
|
52
|
+
else if (key === STYLE) {
|
|
53
|
+
newNode.style._value = Object.assign({}, value._value);
|
|
54
|
+
newNode.style._usedStyleProp = new Set(Array.from(value._usedStyleProp));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (isDeep) {
|
|
58
|
+
newNode.childNodes = this.childNodes.map(node => node.cloneNode(true));
|
|
59
|
+
}
|
|
60
|
+
return newNode;
|
|
61
|
+
}
|
|
62
|
+
function contains(node) {
|
|
63
|
+
let isContains = false;
|
|
64
|
+
this.childNodes.some(childNode => {
|
|
65
|
+
const { uid } = childNode;
|
|
66
|
+
if (uid === node.uid || uid === node.id || childNode.contains(node)) {
|
|
67
|
+
isContains = true;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return isContains;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { cloneNode, contains, insertAdjacentHTML };
|
|
75
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../src/dom-external/node.ts"],"sourcesContent":["import { DATASET, OBJECT, PROPS, STYLE } from '../constants'\nimport { NodeType } from '../dom/node_types'\nimport { parser } from '../dom-external/inner-html/parser'\n\nimport type { TaroNode } from '../dom/node'\n\nexport type IPosition = 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend'\n\n/**\n * An implementation of `Element.insertAdjacentHTML()`\n * to support Vue 3 with a version of or greater than `vue@3.1.2`\n */\nexport function insertAdjacentHTML (\n this: TaroNode,\n position: IPosition,\n html: string\n) {\n const parsedNodes = parser(html, this.ownerDocument)\n\n for (let i = 0; i < parsedNodes.length; i++) {\n const n = parsedNodes[i]\n\n switch (position) {\n case 'beforebegin':\n this.parentNode?.insertBefore(n, this)\n break\n case 'afterbegin':\n if (this.hasChildNodes()) {\n this.insertBefore(n, this.childNodes[0])\n } else {\n this.appendChild(n)\n }\n break\n case 'beforeend':\n this.appendChild(n)\n break\n case 'afterend':\n this.parentNode?.appendChild(n)\n break\n }\n }\n}\n\nexport function cloneNode (this: TaroNode, isDeep = false) {\n const document = this.ownerDocument\n let newNode\n\n if (this.nodeType === NodeType.ELEMENT_NODE) {\n newNode = document.createElement(this.nodeName)\n } else if (this.nodeType === NodeType.TEXT_NODE) {\n newNode = document.createTextNode('')\n }\n\n for (const key in this) {\n const value: any = this[key]\n // eslint-disable-next-line valid-typeof\n if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {\n newNode[key] = { ...value }\n } else if (key === '_value') {\n newNode[key] = value\n } else if (key === STYLE) {\n newNode.style._value = { ...value._value }\n newNode.style._usedStyleProp = new Set(Array.from(value._usedStyleProp))\n }\n }\n\n if (isDeep) {\n newNode.childNodes = this.childNodes.map(node => (node as any).cloneNode(true))\n }\n\n return newNode\n}\n\nexport function contains (this: TaroNode, node: TaroNode & { id?: string }): boolean {\n let isContains = false\n this.childNodes.some(childNode => {\n const { uid } = childNode\n if (uid === node.uid || uid === node.id || (childNode as any).contains(node)) {\n isContains = true\n return true\n }\n })\n return isContains\n}\n"],"names":[],"mappings":";;;AAQA;;;AAGG;AACa,SAAA,kBAAkB,CAEhC,QAAmB,EACnB,IAAY,EAAA;;IAEZ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;AAEpD,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,QAAA,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAExB,QAAQ,QAAQ;AACd,YAAA,KAAK,aAAa;gBAChB,CAAA,EAAA,GAAA,IAAI,CAAC,UAAU,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;gBACtC,MAAK;AACP,YAAA,KAAK,YAAY;AACf,gBAAA,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;AACxB,oBAAA,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;iBACzC;qBAAM;AACL,oBAAA,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;iBACpB;gBACD,MAAK;AACP,YAAA,KAAK,WA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,CAAA;AAC1C,YAAA,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;SACzE;KACF;IAED,IAAI,MAAM,EAAE;QACV,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAK,IAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;KAChF;AAED,IAAA,OAAO,OAAO,CAAA;AAChB,CAAC;AAEK,SAAU,QAAQ,CAAkB,IAAgC,EAAA;IACxE,IAAI,UAAU,GAAG,KAAK,CAAA;AACtB,IAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,IAAG;AAC/B,QAAA,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAA;AACzB,QAAA,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,EAAE,IAAK,SAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAC5E,UAAU,GAAG,IAAI,CAAA;AACjB,YAAA,OAAO,IAAI,CAAA;SACZ;AACH,KAAC,CAAC,CAAA;AACF,IAAA,OAAO,UAAU,CAAA;AACnB;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PageConfig } from '../interface';
|
|
3
|
+
import type { Instance, PageInstance, PageProps } from './instance';
|
|
4
|
+
export declare function injectPageInstance(inst: Instance<PageProps>, id: string): void;
|
|
5
|
+
export declare function getPageInstance(id: string): Instance | undefined;
|
|
6
|
+
export declare function removePageInstance(id: string): void;
|
|
7
|
+
export declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
|
|
8
|
+
export declare function stringify(obj?: Record<string, unknown>): string;
|
|
9
|
+
export declare function getPath(id: string, options?: Record<string, unknown>): string;
|
|
10
|
+
export declare function getOnReadyEventKey(path: string): string;
|
|
11
|
+
export declare function getOnShowEventKey(path: string): string;
|
|
12
|
+
export declare function getOnHideEventKey(path: string): string;
|
|
13
|
+
export declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
|
|
14
|
+
export declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
|
|
15
|
+
export declare function createRecursiveComponentConfig(componentName?: string): any;
|