@next-core/runtime 1.30.0 → 1.30.2

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.
@@ -7,6 +7,7 @@ export function unmountTree(mountPoint) {
7
7
  mountPoint.replaceChildren();
8
8
  }
9
9
  export function mountTree(root, initializedElement) {
10
+ window.DISABLE_REACT_FLUSH_SYNC = false;
10
11
  var current = root.child;
11
12
  var portalElements = [];
12
13
  while (current) {
@@ -85,5 +86,8 @@ export function mountTree(root, initializedElement) {
85
86
  current = (_currentReturn = currentReturn) === null || _currentReturn === void 0 ? void 0 : _currentReturn.sibling;
86
87
  }
87
88
  }
89
+ setTimeout(() => {
90
+ window.DISABLE_REACT_FLUSH_SYNC = true;
91
+ });
88
92
  }
89
93
  //# sourceMappingURL=mount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","names":["bindTemplateProxy","getTplStateStore","bindListeners","setRealProperties","RenderTag","unmountTree","mountPoint","replaceChildren","mountTree","root","initializedElement","current","child","portalElements","tag","BRICK","_current$tplHostMetad","tagName","type","includes","customElements","get","console","error","concat","warn","element","document","createElement","slotId","setAttribute","iid","dataset","tplHostMetadata","tplStateStoreId","properties","events","runtimeContext","$$tplStateStore","tplStateStoreMap","portal","push","return","childElements","sibling","_currentReturn","currentReturn","ROOT","_currentReturn$contai","container","append","undefined","length","createPortal"],"sources":["../../../src/internal/mount.ts"],"sourcesContent":["import { bindTemplateProxy } from \"./CustomTemplates/bindTemplateProxy.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { bindListeners } from \"./bindListeners.js\";\nimport { setRealProperties } from \"./compute/setRealProperties.js\";\nimport { RenderTag } from \"./enums.js\";\nimport type {\n RenderReturnNode,\n RenderRoot,\n RuntimeBrickElement,\n} from \"./interfaces.js\";\n\nexport function unmountTree(mountPoint: HTMLElement | DocumentFragment) {\n mountPoint.replaceChildren();\n}\n\nexport function mountTree(\n root: RenderRoot,\n initializedElement?: RuntimeBrickElement\n): void {\n let current = root.child;\n const portalElements: RuntimeBrickElement[] = [];\n while (current) {\n if (current.tag === RenderTag.BRICK) {\n const tagName = current.type;\n\n if (tagName.includes(\"-\") && !customElements.get(tagName)) {\n // eslint-disable-next-line no-console\n console.error(`Undefined custom element: ${tagName}`);\n }\n\n // istanbul ignore if\n if (tagName === \"basic-bricks.script-brick\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"`basic-bricks.script-brick` is deprecated, please take caution when using it\"\n );\n }\n\n const element: RuntimeBrickElement =\n initializedElement && current === root.child\n ? initializedElement\n : document.createElement(tagName);\n current.element = element;\n\n if (current.slotId) {\n element.setAttribute(\"slot\", current.slotId);\n }\n if (current.iid) {\n element.dataset.iid = current.iid;\n }\n if (current.tplHostMetadata?.tplStateStoreId) {\n element.dataset.tplStateStoreId =\n current.tplHostMetadata.tplStateStoreId;\n }\n setRealProperties(element, current.properties);\n bindListeners(element, current.events, current.runtimeContext);\n if (current.tplHostMetadata) {\n // 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n element.$$tplStateStore = getTplStateStore(\n {\n tplStateStoreId: current.tplHostMetadata.tplStateStoreId,\n tplStateStoreMap: current.runtimeContext.tplStateStoreMap,\n },\n \"mount\"\n );\n }\n bindTemplateProxy(current);\n\n if (current.portal) {\n portalElements.push(element);\n } else if (current.return) {\n if (!current.return.childElements) {\n current.return.childElements = [];\n }\n current.return.childElements.push(element);\n }\n }\n\n if (current.child) {\n current = current.child;\n } else if (current.sibling) {\n current = current.sibling;\n } else {\n let currentReturn: RenderReturnNode | null | undefined = current.return;\n while (currentReturn) {\n // Append elements inside out\n if (currentReturn.childElements) {\n if (currentReturn.tag === RenderTag.ROOT) {\n currentReturn.container?.append(...currentReturn.childElements);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n currentReturn.element!.append(...currentReturn.childElements);\n }\n currentReturn.childElements = undefined;\n }\n\n if (currentReturn.tag === RenderTag.ROOT && portalElements.length > 0) {\n const portal =\n typeof currentReturn.createPortal === \"function\"\n ? currentReturn.createPortal()\n : currentReturn.createPortal;\n portal.append(...portalElements);\n }\n\n if (currentReturn.sibling) {\n break;\n }\n currentReturn = currentReturn.return;\n }\n current = currentReturn?.sibling;\n }\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,SAAS,QAAQ,YAAY;AAOtC,OAAO,SAASC,WAAWA,CAACC,UAA0C,EAAE;EACtEA,UAAU,CAACC,eAAe,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASC,SAASA,CACvBC,IAAgB,EAChBC,kBAAwC,EAClC;EACN,IAAIC,OAAO,GAAGF,IAAI,CAACG,KAAK;EACxB,IAAMC,cAAqC,GAAG,EAAE;EAChD,OAAOF,OAAO,EAAE;IACd,IAAIA,OAAO,CAACG,GAAG,KAAKV,SAAS,CAACW,KAAK,EAAE;MAAA,IAAAC,qBAAA;MACnC,IAAMC,OAAO,GAAGN,OAAO,CAACO,IAAI;MAE5B,IAAID,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAACC,cAAc,CAACC,GAAG,CAACJ,OAAO,CAAC,EAAE;QACzD;QACAK,OAAO,CAACC,KAAK,8BAAAC,MAAA,CAA8BP,OAAO,CAAE,CAAC;MACvD;;MAEA;MACA,IAAIA,OAAO,KAAK,2BAA2B,EAAE;QAC3C;QACAK,OAAO,CAACG,IAAI,CACV,8EACF,CAAC;MACH;MAEA,IAAMC,OAA4B,GAChChB,kBAAkB,IAAIC,OAAO,KAAKF,IAAI,CAACG,KAAK,GACxCF,kBAAkB,GAClBiB,QAAQ,CAACC,aAAa,CAACX,OAAO,CAAC;MACrCN,OAAO,CAACe,OAAO,GAAGA,OAAO;MAEzB,IAAIf,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K;IACzB,CAAC,MAAM,IAAID,OAAO,CAACiC,OAAO,EAAE;MAC1BjC,OAAO,GAAGA,OAAO,CAACiC,OAAO;IAC3B,CAAC,MAAM;MAAA,IAAAC,cAAA;MACL,IAAIC,aAAkD,GAAGnC,OAAO,CAAC+B,MAAM;MACvE,OAAOI,aAAa,EAAE;QACpB;QACA,IAAIA,aAAa,CAACH,aAAa,EAAE;UAC/B,IAAIG,aAAa,CAAChC,GAAG,KAAKV,SAAS,CAAC2C,IAAI,EAAE;YAAA,IAAAC,qBAAA;YACxC,CAAAA,qBAAA,GAAAF,aAAa,CAACG,SAAS,cAAAD,qBAAA,eAAvBA,qBAAA,CAAyBE,MAAM,CAAC,GAAGJ,aAAa,CAACH,aAAa,CAAC;UACjE,CAAC,MAAM;YACL;YACAG,aAAa,CAACpB,OAAO,CAAEwB,MAAM,CAAC,GAAGJ,aAAa,CAACH,aAAa,CAAC;UAC/D;UACAG,aAAa,CAACH,aAAa,GAAGQ,SAAS;QACzC;QAEA,IAAIL,aAAa,CAAChC,GAAG,KAAKV,SAAS,CAAC2C,IAAI,IAAIlC,cAAc,CAACuC,MAAM,GAAG,CAAC,EAAE;UACrE,IAAMZ,MAAM,GACV,OAAOM,aAAa,CAACO,YAAY,KAAK,UAAU,GAC5CP,aAAa,CAACO,YAAY,CAAC,CAAC,GAC5BP,aAAa,CAACO,YAAY;UAChCb,MAAM,CAACU,MAAM,CAAC,GAAGrC,cAAc,CAAC;QAClC;QAEA,IAAIiC,aAAa,CAACF,OAAO,EAAE;UACzB;QACF;QACAE,aAAa,GAAGA,aAAa,CAACJ,MAAM;MACtC;MACA/B,OAAO,IAAAkC,cAAA,GAAGC,aAAa,cAAAD,cAAA,uBAAbA,cAAA,CAAeD,OAAO;IAClC;EACF;AACF"}
1
+ {"version":3,"file":"mount.js","names":["bindTemplateProxy","getTplStateStore","bindListeners","setRealProperties","RenderTag","unmountTree","mountPoint","replaceChildren","mountTree","root","initializedElement","window","DISABLE_REACT_FLUSH_SYNC","current","child","portalElements","tag","BRICK","_current$tplHostMetad","tagName","type","includes","customElements","get","console","error","concat","warn","element","document","createElement","slotId","setAttribute","iid","dataset","tplHostMetadata","tplStateStoreId","properties","events","runtimeContext","$$tplStateStore","tplStateStoreMap","portal","push","return","childElements","sibling","_currentReturn","currentReturn","ROOT","_currentReturn$contai","container","append","undefined","length","createPortal","setTimeout"],"sources":["../../../src/internal/mount.ts"],"sourcesContent":["import { bindTemplateProxy } from \"./CustomTemplates/bindTemplateProxy.js\";\nimport { getTplStateStore } from \"./CustomTemplates/utils.js\";\nimport { bindListeners } from \"./bindListeners.js\";\nimport { setRealProperties } from \"./compute/setRealProperties.js\";\nimport { RenderTag } from \"./enums.js\";\nimport type {\n RenderReturnNode,\n RenderRoot,\n RuntimeBrickElement,\n} from \"./interfaces.js\";\n\nexport function unmountTree(mountPoint: HTMLElement | DocumentFragment) {\n mountPoint.replaceChildren();\n}\n\nexport function mountTree(\n root: RenderRoot,\n initializedElement?: RuntimeBrickElement\n): void {\n window.DISABLE_REACT_FLUSH_SYNC = false;\n let current = root.child;\n const portalElements: RuntimeBrickElement[] = [];\n while (current) {\n if (current.tag === RenderTag.BRICK) {\n const tagName = current.type;\n\n if (tagName.includes(\"-\") && !customElements.get(tagName)) {\n // eslint-disable-next-line no-console\n console.error(`Undefined custom element: ${tagName}`);\n }\n\n // istanbul ignore if\n if (tagName === \"basic-bricks.script-brick\") {\n // eslint-disable-next-line no-console\n console.warn(\n \"`basic-bricks.script-brick` is deprecated, please take caution when using it\"\n );\n }\n\n const element: RuntimeBrickElement =\n initializedElement && current === root.child\n ? initializedElement\n : document.createElement(tagName);\n current.element = element;\n\n if (current.slotId) {\n element.setAttribute(\"slot\", current.slotId);\n }\n if (current.iid) {\n element.dataset.iid = current.iid;\n }\n if (current.tplHostMetadata?.tplStateStoreId) {\n element.dataset.tplStateStoreId =\n current.tplHostMetadata.tplStateStoreId;\n }\n setRealProperties(element, current.properties);\n bindListeners(element, current.events, current.runtimeContext);\n if (current.tplHostMetadata) {\n // 先设置属性,再设置 `$$tplStateStore`,这样,当触发属性设置时,\n // 避免初始化的一次 state update 操作及其 onChange 事件。\n element.$$tplStateStore = getTplStateStore(\n {\n tplStateStoreId: current.tplHostMetadata.tplStateStoreId,\n tplStateStoreMap: current.runtimeContext.tplStateStoreMap,\n },\n \"mount\"\n );\n }\n bindTemplateProxy(current);\n\n if (current.portal) {\n portalElements.push(element);\n } else if (current.return) {\n if (!current.return.childElements) {\n current.return.childElements = [];\n }\n current.return.childElements.push(element);\n }\n }\n\n if (current.child) {\n current = current.child;\n } else if (current.sibling) {\n current = current.sibling;\n } else {\n let currentReturn: RenderReturnNode | null | undefined = current.return;\n while (currentReturn) {\n // Append elements inside out\n if (currentReturn.childElements) {\n if (currentReturn.tag === RenderTag.ROOT) {\n currentReturn.container?.append(...currentReturn.childElements);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n currentReturn.element!.append(...currentReturn.childElements);\n }\n currentReturn.childElements = undefined;\n }\n\n if (currentReturn.tag === RenderTag.ROOT && portalElements.length > 0) {\n const portal =\n typeof currentReturn.createPortal === \"function\"\n ? currentReturn.createPortal()\n : currentReturn.createPortal;\n portal.append(...portalElements);\n }\n\n if (currentReturn.sibling) {\n break;\n }\n currentReturn = currentReturn.return;\n }\n current = currentReturn?.sibling;\n }\n }\n setTimeout(() => {\n window.DISABLE_REACT_FLUSH_SYNC = true;\n });\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wCAAwC;AAC1E,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,SAAS,QAAQ,YAAY;AAOtC,OAAO,SAASC,WAAWA,CAACC,UAA0C,EAAE;EACtEA,UAAU,CAACC,eAAe,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASC,SAASA,CACvBC,IAAgB,EAChBC,kBAAwC,EAClC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;YACAG,aAAa,CAACpB,OAAO,CAAEwB,MAAM,CAAC,GAAGJ,aAAa,CAACH,aAAa,CAAC;UAC/D;UACAG,aAAa,CAACH,aAAa,GAAGQ,SAAS;QACzC;QAEA,IAAIL,aAAa,CAAChC,GAAG,KAAKZ,SAAS,CAAC6C,IAAI,IAAIlC,cAAc,CAACuC,MAAM,GAAG,CAAC,EAAE;UACrE,IAAMZ,MAAM,GACV,OAAOM,aAAa,CAACO,YAAY,KAAK,UAAU,GAC5CP,aAAa,CAACO,YAAY,CAAC,CAAC,GAC5BP,aAAa,CAACO,YAAY;UAChCb,MAAM,CAACU,MAAM,CAAC,GAAGrC,cAAc,CAAC;QAClC;QAEA,IAAIiC,aAAa,CAACF,OAAO,EAAE;UACzB;QACF;QACAE,aAAa,GAAGA,aAAa,CAACJ,MAAM;MACtC;MACA/B,OAAO,IAAAkC,cAAA,GAAGC,aAAa,cAAAD,cAAA,uBAAbA,cAAA,CAAeD,OAAO;IAClC;EACF;EACAU,UAAU,CAAC,MAAM;IACf7C,MAAM,CAACC,wBAAwB,GAAG,IAAI;EACxC,CAAC,CAAC;AACJ"}
@@ -1,21 +1,25 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import { pick } from "lodash";
2
3
  import { _internalApiGetRenderId } from "./Runtime.js";
4
+ import { computeRealValue } from "./compute/computeRealValue.js";
3
5
  var timeoutIdList = new Set();
4
- export function startPoll(task, _ref, _ref2) {
6
+ export function startPoll(task, _ref, pollOptions, runtimeContext) {
5
7
  var {
6
8
  progress,
7
9
  success,
8
10
  error,
9
11
  finally: finallyCallback
10
12
  } = _ref;
13
+ var {
14
+ expectPollStopImmediately,
15
+ expectPollEnd
16
+ } = pollOptions;
11
17
  var {
12
18
  interval,
13
19
  leadingRequestDelay,
14
20
  continueOnError,
15
- delegateLoadingBar,
16
- expectPollEnd,
17
- expectPollStopImmediately
18
- } = _ref2;
21
+ delegateLoadingBar
22
+ } = computeRealValue(pick(pollOptions, ["interval", "leadingRequestDelay", "continueOnError", "delegateLoadingBar"]), runtimeContext);
19
23
  var currentRenderId = _internalApiGetRenderId();
20
24
  var currentTimeoutId;
21
25
  function poll() {
@@ -26,16 +30,19 @@ export function startPoll(task, _ref, _ref2) {
26
30
  timeoutIdList.delete(currentTimeoutId);
27
31
  var shouldStop;
28
32
  try {
29
- shouldStop = expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately();
33
+ var _computeRealValue;
34
+ shouldStop = (_computeRealValue = computeRealValue(expectPollStopImmediately, runtimeContext)) === null || _computeRealValue === void 0 ? void 0 : _computeRealValue();
30
35
  // Stop polling immediately when the expectation is match before task.
31
36
  if (!shouldStop) {
37
+ var _computeRealValue2;
32
38
  var _result = yield task();
33
39
  // Stop polling immediately when the expectation is match or a different router
34
40
  // is rendering after the task processed.
35
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRenderId();
41
+ shouldStop = ((_computeRealValue2 = computeRealValue(expectPollStopImmediately, runtimeContext)) === null || _computeRealValue2 === void 0 ? void 0 : _computeRealValue2()) || currentRenderId !== _internalApiGetRenderId();
36
42
  if (!shouldStop) {
43
+ var _computeRealValue3;
37
44
  progress === null || progress === void 0 || progress(_result);
38
- if (expectPollEnd !== null && expectPollEnd !== void 0 && expectPollEnd(_result)) {
45
+ if ((_computeRealValue3 = computeRealValue(expectPollEnd, runtimeContext)) !== null && _computeRealValue3 !== void 0 && _computeRealValue3(_result)) {
39
46
  if (delegateLoadingBar) {
40
47
  window.dispatchEvent(new Event("request.end"));
41
48
  }
@@ -47,9 +54,10 @@ export function startPoll(task, _ref, _ref2) {
47
54
  }
48
55
  }
49
56
  } catch (e) {
57
+ var _computeRealValue4;
50
58
  // Stop polling immediately when the expectation is match or a different router
51
59
  // is rendering after the task processed.
52
- shouldStop = (expectPollStopImmediately === null || expectPollStopImmediately === void 0 ? void 0 : expectPollStopImmediately()) || currentRenderId !== _internalApiGetRenderId();
60
+ shouldStop = ((_computeRealValue4 = computeRealValue(expectPollStopImmediately, runtimeContext)) === null || _computeRealValue4 === void 0 ? void 0 : _computeRealValue4()) || currentRenderId !== _internalApiGetRenderId();
53
61
  if (!shouldStop) {
54
62
  error === null || error === void 0 || error(e);
55
63
  if (continueOnError) {
@@ -1 +1 @@
1
- {"version":3,"file":"poll.js","names":["_internalApiGetRenderId","timeoutIdList","Set","startPoll","task","_ref","_ref2","progress","success","error","finally","finallyCallback","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","expectPollEnd","expectPollStopImmediately","currentRenderId","currentTimeoutId","poll","_poll","apply","arguments","_asyncToGenerator","delete","shouldStop","result","window","dispatchEvent","Event","delayedPoll","e","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n {\n interval,\n leadingRequestDelay,\n continueOnError,\n delegateLoadingBar,\n expectPollEnd,\n expectPollStopImmediately,\n }: ProviderPollOptions\n): void {\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = expectPollStopImmediately?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (expectPollEnd?.(result)) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n }\n }\n } catch (e) {\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n expectPollStopImmediately?.() ||\n currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";AACA,SAASA,uBAAuB,QAAQ,cAAc;AAWtD,IAAMC,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEvC,OAAO,SAASC,SAASA,CACvBC,IAAmB,EAAAC,IAAA,EAAAC,KAAA,EAUb;EAAA,IATN;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,KAAK;IAAEC,OAAO,EAAEC;EAAkC,CAAC,GAAAN,IAAA;EAAA,IACxE;IACEO,QAAQ;IACRC,mBAAmB;IACnBC,eAAe;IACfC,kBAAkB;IAClBC,aAAa;IACbC;EACmB,CAAC,GAAAX,KAAA;EAEtB,IAAMY,eAAe,GAAGlB,uBAAuB,CAAC,CAAC;EACjD,IAAImB,gBAAwB;EAAC,SACdC,IAAIA,CAAA;IAAA,OAAAC,KAAA,CAAAC,KAAA,OAAAC,S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AW,CAACnB,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,IAAI,CAAC;UAC/B,CAAC,MAAM;YACLD,eAAe,aAAfA,eAAe,eAAfA,eAAe,CAAG,CAAC;UACrB;QACF;MACF,CAAC,SAAS;QACR;QACA,IAAII,kBAAkB,IAAIW,UAAU,EAAE;UACpCE,MAAM,CAACC,aAAa,CAAC,IAAIC,KAAK,CAAC,aAAa,CAAC,CAAC;QAChD;MACF;IACF,CAAC;IAAA,OAAAT,KAAA,CAAAC,KAAA,OAAAC,SAAA;EAAA;EAED,SAASQ,WAAWA,CAACE,KAAa,EAAQ;IACxCd,gBAAgB,GAAGe,UAAU,CAACd,IAAI,EAAEa,KAAK,CAAsB;IAC/DhC,aAAa,CAACkC,GAAG,CAAChB,gBAAgB,CAAC;EACrC;EAEAY,WAAW,CAAClB,mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI,CAAC,CAAC;EAErC,IAAIE,kBAAkB,EAAE;IACtBa,MAAM,CAACC,aAAa,CAAC,IAAIC,KAAK,CAAC,eAAe,CAAC,CAAC;EAClD;AACF;AAEA,OAAO,SAASM,gBAAgBA,CAAA,EAAS;EACvC,KAAK,IAAMC,SAAS,IAAIpC,aAAa,EAAE;IACrCqC,YAAY,CAACD,SAAS,CAAC;EACzB;EACApC,aAAa,CAACsC,KAAK,CAAC,CAAC;AACvB"}
1
+ {"version":3,"file":"poll.js","names":["pick","_internalApiGetRenderId","computeRealValue","timeoutIdList","Set","startPoll","task","_ref","pollOptions","runtimeContext","progress","success","error","finally","finallyCallback","expectPollStopImmediately","expectPollEnd","interval","leadingRequestDelay","continueOnError","delegateLoadingBar","currentRenderId","currentTimeoutId","poll","_poll","apply","arguments","_asyncToGenerator","delete","shouldStop","_computeRealValue","_computeRealValue2","result","_computeRealValue3","window","dispatchEvent","Event","delayedPoll","e","_computeRealValue4","delay","setTimeout","add","clearPollTimeout","timeoutId","clearTimeout","clear"],"sources":["../../../src/internal/poll.ts"],"sourcesContent":["import type { ProviderPollOptions } from \"@next-core/types\";\nimport { pick } from \"lodash\";\nimport { _internalApiGetRenderId } from \"./Runtime.js\";\nimport { computeRealValue } from \"./compute/computeRealValue.js\";\nimport { RuntimeContext } from \"./interfaces.js\";\n\nexport type PollableCallbackFunction = (result?: unknown) => unknown;\n\nexport interface PollableCallback {\n progress?: PollableCallbackFunction;\n success?: PollableCallbackFunction;\n error?: PollableCallbackFunction;\n finally?: PollableCallbackFunction;\n}\n\nconst timeoutIdList = new Set<number>();\n\nexport function startPoll(\n task: () => unknown,\n { progress, success, error, finally: finallyCallback }: PollableCallback,\n pollOptions: ProviderPollOptions,\n runtimeContext: RuntimeContext\n): void {\n const { expectPollStopImmediately, expectPollEnd } = pollOptions;\n const { interval, leadingRequestDelay, continueOnError, delegateLoadingBar } =\n computeRealValue(\n pick(pollOptions, [\n \"interval\",\n \"leadingRequestDelay\",\n \"continueOnError\",\n \"delegateLoadingBar\",\n ]),\n runtimeContext\n ) as ProviderPollOptions;\n const currentRenderId = _internalApiGetRenderId();\n let currentTimeoutId: number;\n async function poll(): Promise<void> {\n timeoutIdList.delete(currentTimeoutId);\n let shouldStop: boolean | undefined;\n try {\n shouldStop = (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.();\n // Stop polling immediately when the expectation is match before task.\n if (!shouldStop) {\n const result = await task();\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.() || currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n progress?.(result);\n if (\n (\n computeRealValue(expectPollEnd, runtimeContext) as\n | ((result: unknown) => boolean)\n | undefined\n )?.(result)\n ) {\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n success?.(result);\n finallyCallback?.();\n } else {\n delayedPoll(interval ?? 3000);\n }\n }\n }\n } catch (e) {\n // Stop polling immediately when the expectation is match or a different router\n // is rendering after the task processed.\n shouldStop =\n (\n computeRealValue(expectPollStopImmediately, runtimeContext) as\n | (() => boolean)\n | undefined\n )?.() || currentRenderId !== _internalApiGetRenderId();\n if (!shouldStop) {\n error?.(e);\n if (continueOnError) {\n delayedPoll(interval ?? 3000);\n } else {\n finallyCallback?.();\n }\n }\n } finally {\n // Manually dispatch an event of `request.end` when the polling is stopped immediately.\n if (delegateLoadingBar && shouldStop) {\n window.dispatchEvent(new Event(\"request.end\"));\n }\n }\n }\n\n function delayedPoll(delay: number): void {\n currentTimeoutId = setTimeout(poll, delay) as unknown as number;\n timeoutIdList.add(currentTimeoutId);\n }\n\n delayedPoll(leadingRequestDelay ?? 0);\n\n if (delegateLoadingBar) {\n window.dispatchEvent(new Event(\"request.start\"));\n }\n}\n\nexport function clearPollTimeout(): void {\n for (const timeoutId of timeoutIdList) {\n clearTimeout(timeoutId);\n }\n timeoutIdList.clear();\n}\n"],"mappings":";AACA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SAASC,uBAAuB,QAAQ,cAAc;AACtD,SAASC,gBAAgB,QAAQ,+BAA+B;AAYhE,IAAMC,aAAa,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEvC,OAAO,SAASC,SAASA,CACvBC,IAAmB,EAAAC,IAAA,EAEnBC,WAAgC,EAChCC,cAA8B,EACxB;EAAA,IAHN;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,KAAK;IAAEC,OAAO,EAAEC;EAAkC,CAAC,GAAAP,IAAA;EAIxE,IAAM;IAAEQ,yBAAyB;IAAEC;EAAc,CAAC,GAAGR,WAAW;EAChE,IAAM;IAAES,QAAQ;IAAEC,mBAAmB;IAAEC,eAAe;IAAEC;EAAmB,CAAC,GAC1ElB,gBAAgB,CACdF,IAAI,CAACQ,WAAW,EAAE,CAChB,UAAU,EACV,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,CACrB,CAAC,EACFC,cACF,CAAwB;EAC1B,IAAMY,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CAAC;AACvB"}
@@ -1,4 +1,5 @@
1
1
  import type { ProviderPollOptions } from "@next-core/types";
2
+ import { RuntimeContext } from "./interfaces.js";
2
3
  export type PollableCallbackFunction = (result?: unknown) => unknown;
3
4
  export interface PollableCallback {
4
5
  progress?: PollableCallbackFunction;
@@ -6,5 +7,5 @@ export interface PollableCallback {
6
7
  error?: PollableCallbackFunction;
7
8
  finally?: PollableCallbackFunction;
8
9
  }
9
- export declare function startPoll(task: () => unknown, { progress, success, error, finally: finallyCallback }: PollableCallback, { interval, leadingRequestDelay, continueOnError, delegateLoadingBar, expectPollEnd, expectPollStopImmediately, }: ProviderPollOptions): void;
10
+ export declare function startPoll(task: () => unknown, { progress, success, error, finally: finallyCallback }: PollableCallback, pollOptions: ProviderPollOptions, runtimeContext: RuntimeContext): void;
10
11
  export declare function clearPollTimeout(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/runtime",
3
- "version": "1.30.0",
3
+ "version": "1.30.2",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -66,5 +66,5 @@
66
66
  "@next-core/build-next-libs": "^1.0.11",
67
67
  "@next-core/test-next": "^1.0.14"
68
68
  },
69
- "gitHead": "e95c6b5b0bffa483cdbb8304afe9535da25da53f"
69
+ "gitHead": "b014d395a47f80d29588bdc8a28fa9ce87b5dd1f"
70
70
  }