qalita 2.5.4__py3-none-any.whl → 2.6.1__py3-none-any.whl
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.
- qalita/_frontend/.next/static/_0oyfpC7N2IGDMa04TT9R/_clientMiddlewareManifest.json +6 -0
- qalita/_frontend/.next/static/chunks/236f7e5abd6f09ff.js +4 -0
- qalita/_frontend/.next/static/chunks/30ea11065999f7ac.js +1 -0
- qalita/_frontend/.next/static/chunks/4dd28bc3f722184a.js +2 -0
- qalita/_frontend/.next/static/chunks/711d597b816a80c1.js +1 -0
- qalita/_frontend/.next/static/chunks/7340adf74ff47ec0.js +1 -0
- qalita/_frontend/.next/static/chunks/a6dad97d9634a72d.js.map +1 -0
- qalita/_frontend/.next/static/chunks/{e393fec0d8ba175d.js → ecf559101be0ae12.js} +3 -3
- qalita/_frontend/.next/static/chunks/turbopack-25186fc8e1264445.js +4 -0
- qalita/_frontend/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
- qalita/_frontend/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
- qalita/_frontend/node_modules/@next/env/package.json +4 -4
- qalita/_frontend/node_modules/next/dist/build/analyze/index.js +242 -0
- qalita/_frontend/node_modules/next/dist/build/define-env.js +22 -13
- qalita/_frontend/node_modules/next/dist/build/entries.js +5 -5
- qalita/_frontend/node_modules/next/dist/build/generate-routes-manifest.js +91 -0
- qalita/_frontend/node_modules/next/dist/build/index.js +172 -223
- qalita/_frontend/node_modules/next/dist/build/output/log.js +4 -7
- qalita/_frontend/node_modules/next/dist/build/segment-config/app/app-segments.js +23 -99
- qalita/_frontend/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js +3 -3
- qalita/_frontend/node_modules/next/dist/build/spinner.js +3 -3
- qalita/_frontend/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js +137 -0
- qalita/_frontend/node_modules/next/dist/build/static-paths/app.js +69 -210
- qalita/_frontend/node_modules/next/dist/build/static-paths/utils.js +83 -11
- qalita/_frontend/node_modules/next/dist/build/swc/index.js +10 -6
- qalita/_frontend/node_modules/next/dist/build/templates/app-page.js +21 -14
- qalita/_frontend/node_modules/next/dist/build/templates/app-route.js +8 -10
- qalita/_frontend/node_modules/next/dist/build/templates/edge-app-route.js +7 -10
- qalita/_frontend/node_modules/next/dist/build/templates/edge-ssr-app.js +16 -20
- qalita/_frontend/node_modules/next/dist/build/templates/edge-ssr.js +20 -14
- qalita/_frontend/node_modules/next/dist/build/templates/edge-wrapper.js +24 -0
- qalita/_frontend/node_modules/next/dist/build/templates/middleware.js +7 -6
- qalita/_frontend/node_modules/next/dist/build/templates/pages-edge-api.js +3 -2
- qalita/_frontend/node_modules/next/dist/build/turbopack-analyze/index.js +116 -0
- qalita/_frontend/node_modules/next/dist/build/turbopack-build/impl.js +2 -1
- qalita/_frontend/node_modules/next/dist/build/type-check.js +7 -8
- qalita/_frontend/node_modules/next/dist/build/utils.js +45 -4
- qalita/_frontend/node_modules/next/dist/build/validate-app-paths.js +242 -0
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js +20 -2
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js +2 -5
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js +4 -11
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-root-params-loader.js +1 -1
- qalita/_frontend/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js +1 -1
- qalita/_frontend/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js +3 -0
- qalita/_frontend/node_modules/next/dist/build/webpack-build/impl.js +1 -0
- qalita/_frontend/node_modules/next/dist/build/webpack-config.js +35 -3
- qalita/_frontend/node_modules/next/dist/cli/next-test.js +3 -5
- qalita/_frontend/node_modules/next/dist/client/components/app-router-headers.js +5 -0
- qalita/_frontend/node_modules/next/dist/client/components/app-router-instance.js +3 -11
- qalita/_frontend/node_modules/next/dist/client/components/app-router.js +8 -28
- qalita/_frontend/node_modules/next/dist/client/components/navigation-devtools.js +5 -7
- qalita/_frontend/node_modules/next/dist/client/components/navigation.js +4 -3
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js +3 -22
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +6 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/ppr-navigations.js +844 -590
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/hmr-refresh-reducer.js +4 -76
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/navigate-reducer.js +21 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/refresh-reducer.js +48 -85
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/restore-reducer.js +25 -10
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js +126 -113
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/server-patch-reducer.js +30 -39
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/router-reducer-types.js +0 -1
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/router-reducer.js +2 -2
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/cache-map.js +13 -18
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/cache.js +27 -14
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/lru.js +3 -1
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/navigation.js +176 -133
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +12 -12
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +12 -12
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +3 -3
- qalita/_frontend/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +10 -10
- qalita/_frontend/node_modules/next/dist/compiled/react-is/package.json +1 -1
- qalita/_frontend/node_modules/next/dist/lib/build-custom-route.js +4 -4
- qalita/_frontend/node_modules/next/dist/lib/constants.js +0 -5
- qalita/_frontend/node_modules/next/dist/lib/default-transpiled-packages.json +1 -0
- qalita/_frontend/node_modules/next/dist/lib/generate-interception-routes-rewrites.js +0 -1
- qalita/_frontend/node_modules/next/dist/lib/helpers/get-npx-command.js +3 -3
- qalita/_frontend/node_modules/next/dist/lib/inline-static-env.js +1 -1
- qalita/_frontend/node_modules/next/dist/lib/known-edge-safe-packages.json +1 -0
- qalita/_frontend/node_modules/next/dist/lib/metadata/metadata.js +17 -11
- qalita/_frontend/node_modules/next/dist/lib/needs-experimental-react.js +2 -2
- qalita/_frontend/node_modules/next/dist/lib/resolve-build-paths.js +44 -76
- qalita/_frontend/node_modules/next/dist/lib/server-external-packages.jsonc +103 -0
- qalita/_frontend/node_modules/next/dist/lib/static-env.js +6 -6
- qalita/_frontend/node_modules/next/dist/lib/turbopack-warning.js +3 -5
- qalita/_frontend/node_modules/next/dist/lib/typescript/runTypeCheck.js +61 -5
- qalita/_frontend/node_modules/next/dist/lib/typescript/type-paths.js +56 -0
- qalita/_frontend/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js +6 -17
- qalita/_frontend/node_modules/next/dist/lib/verify-typescript-setup.js +10 -2
- qalita/_frontend/node_modules/next/dist/lib/worker.js +17 -9
- qalita/_frontend/node_modules/next/dist/server/app-render/action-handler.js +113 -77
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-prerender-utils.js +36 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-render-utils.js +36 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-scheduling.js +188 -0
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render.js +804 -748
- qalita/_frontend/node_modules/next/dist/server/app-render/collect-segment-data.js +8 -2
- qalita/_frontend/node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/app-render/create-error-handler.js +42 -75
- qalita/_frontend/node_modules/next/dist/server/app-render/dynamic-rendering.js +127 -14
- qalita/_frontend/node_modules/next/dist/server/app-render/encryption-utils.js +3 -108
- qalita/_frontend/node_modules/next/dist/server/app-render/encryption.js +4 -3
- qalita/_frontend/node_modules/next/dist/server/app-render/flight-render-result.js +3 -2
- qalita/_frontend/node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js +9 -8
- qalita/_frontend/node_modules/next/dist/server/app-render/get-layer-assets.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/app-render/manifests-singleton.js +257 -0
- qalita/_frontend/node_modules/next/dist/server/app-render/prospective-render-utils.js +25 -8
- qalita/_frontend/node_modules/next/dist/server/app-render/staged-rendering.js +161 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/use-flight-response.js +67 -20
- qalita/_frontend/node_modules/next/dist/server/app-render/walk-tree-with-flight-router-state.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/async-storage/work-store.js +2 -1
- qalita/_frontend/node_modules/next/dist/server/base-server.js +32 -23
- qalita/_frontend/node_modules/next/dist/server/capsize-font-metrics.json +181516 -0
- qalita/_frontend/node_modules/next/dist/server/config-schema.js +8 -1
- qalita/_frontend/node_modules/next/dist/server/config-shared.js +83 -2
- qalita/_frontend/node_modules/next/dist/server/config.js +24 -17
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-rspack.js +171 -0
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +37 -25
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-types.js +1 -0
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-webpack.js +62 -57
- qalita/_frontend/node_modules/next/dist/server/dev/log-requests.js +11 -3
- qalita/_frontend/node_modules/next/dist/server/dev/messages.js +10 -0
- qalita/_frontend/node_modules/next/dist/server/dev/serialized-errors.js +67 -0
- qalita/_frontend/node_modules/next/dist/server/dev/static-paths-worker.js +10 -0
- qalita/_frontend/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/lib/chrome-devtools-workspace.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/lib/dev-bundler-service.js +6 -10
- qalita/_frontend/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +4 -4
- qalita/_frontend/node_modules/next/dist/server/lib/lazy-result.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/lib/patch-fetch.js +9 -9
- qalita/_frontend/node_modules/next/dist/server/lib/router-server.js +43 -29
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/build-prefetch-segment-data-route.js +0 -21
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/filesystem.js +2 -7
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +8 -4
- qalita/_frontend/node_modules/next/dist/server/lib/start-server.js +3 -3
- qalita/_frontend/node_modules/next/dist/server/lib/trace/tracer.js +4 -0
- qalita/_frontend/node_modules/next/dist/server/load-components.js +3 -9
- qalita/_frontend/node_modules/next/dist/server/next-server.js +19 -18
- qalita/_frontend/node_modules/next/dist/server/next.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/node-environment-extensions/fast-set-immediate.external.js +570 -0
- qalita/_frontend/node_modules/next/dist/server/node-environment-extensions/utils.js +60 -3
- qalita/_frontend/node_modules/next/dist/server/node-environment.js +1 -0
- qalita/_frontend/node_modules/next/dist/server/patch-error-inspect.js +7 -4
- qalita/_frontend/node_modules/next/dist/server/request/fallback-params.js +23 -66
- qalita/_frontend/node_modules/next/dist/server/route-modules/app-route/module.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/route-modules/pages/pages-handler.js +6 -3
- qalita/_frontend/node_modules/next/dist/server/route-modules/route-module.js +79 -18
- qalita/_frontend/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +28 -4
- qalita/_frontend/node_modules/next/dist/server/typescript/rules/config.js +50 -6
- qalita/_frontend/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +68 -23
- qalita/_frontend/node_modules/next/dist/server/web/edge-route-module-wrapper.js +7 -5
- qalita/_frontend/node_modules/next/dist/server/web/sandbox/context.js +8 -9
- qalita/_frontend/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js +2 -1
- qalita/_frontend/node_modules/next/dist/server/web/spec-extension/revalidate.js +7 -3
- qalita/_frontend/node_modules/next/dist/shared/lib/action-revalidation-kind.js +31 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/constants.js +6 -1
- qalita/_frontend/node_modules/next/dist/shared/lib/deployment-id.js +36 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- qalita/_frontend/node_modules/next/dist/shared/lib/hooks-client-context.shared-runtime.js +5 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/routes/app.js +122 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +20 -49
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/get-segment-param.js +6 -6
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/interception-prefix-from-param-type.js +33 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/resolve-param-value.js +116 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/segment-cache/output-export-prefetch-encoding.js +3 -24
- qalita/_frontend/node_modules/next/dist/shared/lib/segment.js +5 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/turbopack/utils.js +6 -5
- qalita/_frontend/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- qalita/_frontend/node_modules/next/dist/telemetry/events/build.js +11 -0
- qalita/_frontend/node_modules/next/dist/telemetry/events/version.js +2 -2
- qalita/_frontend/node_modules/next/package.json +20 -18
- qalita/_frontend/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/typesMap.json +497 -0
- qalita/_frontend/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/package.json +3 -3
- qalita/_frontend/server.js +1 -1
- qalita/commands/pack.py +3 -3
- qalita/commands/source.py +1 -1
- qalita/internal/utils.py +11 -7
- qalita/web/app.py +20 -4
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/METADATA +1 -1
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/RECORD +197 -168
- qalita/_frontend/.next/static/chunks/023d923a37d494fc.js +0 -1
- qalita/_frontend/.next/static/chunks/247eb132b7f7b574.js +0 -1
- qalita/_frontend/.next/static/chunks/bba035711c7e37a2.js +0 -4
- qalita/_frontend/.next/static/chunks/c903f9580a4b6572.js +0 -2
- qalita/_frontend/.next/static/chunks/cbd55ab9639e1e66.js +0 -1
- qalita/_frontend/.next/static/chunks/turbopack-1ad58da399056f41.js +0 -3
- qalita/_frontend/node_modules/next/dist/build/deployment-id.js +0 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/apply-flight-data.js +0 -53
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/apply-router-state-patch-to-tree.js +0 -105
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fill-cache-with-new-subtree-data.js +0 -110
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.js +0 -131
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/handle-segment-mismatch.js +0 -25
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/invalidate-cache-by-router-state.js +0 -32
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/refetch-inactive-parallel-segments.js +0 -104
- qalita/_frontend/node_modules/next/dist/server/app-render/action-utils.js +0 -90
- qalita/_frontend/node_modules/next/dist/server/normalizers/request/prefetch-rsc.js +0 -31
- /qalita/_frontend/.next/static/{X4_AlYMbCyee-ZVLjCYMg → _0oyfpC7N2IGDMa04TT9R}/_buildManifest.js +0 -0
- /qalita/_frontend/.next/static/{X4_AlYMbCyee-ZVLjCYMg → _0oyfpC7N2IGDMa04TT9R}/_ssgManifest.js +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/WHEEL +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/entry_points.txt +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
DANGEROUSLY_runPendingImmediatesAfterCurrentTask: null,
|
|
7
|
+
expectNoPendingImmediates: null,
|
|
8
|
+
unpatchedSetImmediate: null
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: all[name]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
DANGEROUSLY_runPendingImmediatesAfterCurrentTask: function() {
|
|
18
|
+
return DANGEROUSLY_runPendingImmediatesAfterCurrentTask;
|
|
19
|
+
},
|
|
20
|
+
expectNoPendingImmediates: function() {
|
|
21
|
+
return expectNoPendingImmediates;
|
|
22
|
+
},
|
|
23
|
+
unpatchedSetImmediate: function() {
|
|
24
|
+
return originalSetImmediate;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const _nodeutil = require("node:util");
|
|
28
|
+
const _invarianterror = require("../../shared/lib/invariant-error");
|
|
29
|
+
const _asynclocalstorage = require("../app-render/async-local-storage");
|
|
30
|
+
var ExecutionState = /*#__PURE__*/ function(ExecutionState) {
|
|
31
|
+
ExecutionState[ExecutionState["Waiting"] = 1] = "Waiting";
|
|
32
|
+
ExecutionState[ExecutionState["Working"] = 2] = "Working";
|
|
33
|
+
ExecutionState[ExecutionState["Finished"] = 3] = "Finished";
|
|
34
|
+
ExecutionState[ExecutionState["Abandoned"] = 4] = "Abandoned";
|
|
35
|
+
return ExecutionState;
|
|
36
|
+
}(ExecutionState || {});
|
|
37
|
+
let wasEnabledAtLeastOnce = false;
|
|
38
|
+
let pendingNextTicks = 0;
|
|
39
|
+
let currentExecution = null;
|
|
40
|
+
const originalSetImmediate = globalThis.setImmediate;
|
|
41
|
+
const originalClearImmediate = globalThis.clearImmediate;
|
|
42
|
+
const originalNextTick = process.nextTick;
|
|
43
|
+
function install() {
|
|
44
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
45
|
+
// Nothing to patch. The exported functions all error if used in the edge runtime,
|
|
46
|
+
// so we're not going to violate any assumptions by not patching.
|
|
47
|
+
return;
|
|
48
|
+
} else {
|
|
49
|
+
debug == null ? void 0 : debug('installing fast setImmediate patch');
|
|
50
|
+
const nodeTimers = require('node:timers');
|
|
51
|
+
globalThis.setImmediate = nodeTimers.setImmediate = // Workaround for missing __promisify__ which is not a real property
|
|
52
|
+
patchedSetImmediate;
|
|
53
|
+
globalThis.clearImmediate = nodeTimers.clearImmediate = patchedClearImmediate;
|
|
54
|
+
const nodeTimersPromises = require('node:timers/promises');
|
|
55
|
+
nodeTimersPromises.setImmediate = patchedSetImmediatePromise;
|
|
56
|
+
process.nextTick = patchedNextTick;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function DANGEROUSLY_runPendingImmediatesAfterCurrentTask() {
|
|
60
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
61
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('DANGEROUSLY_runPendingImmediatesAfterCurrentTask cannot be called in the edge runtime'), "__NEXT_ERROR_CODE", {
|
|
62
|
+
value: "E960",
|
|
63
|
+
enumerable: false,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
const execution = startCapturingImmediates();
|
|
68
|
+
try {
|
|
69
|
+
scheduleWorkAfterNextTicksAndMicrotasks(execution);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
// If this error comes from a bail() call, rethrow it.
|
|
72
|
+
if (execution.state === 4) {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
// Otherwise, bail out here.
|
|
76
|
+
bail(execution, Object.defineProperty(new _invarianterror.InvariantError('An unexpected error occurred while starting to capture immediates', {
|
|
77
|
+
cause: err
|
|
78
|
+
}), "__NEXT_ERROR_CODE", {
|
|
79
|
+
value: "E964",
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function expectNoPendingImmediates() {
|
|
87
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
88
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('expectNoPendingImmediates cannot be called in the edge runtime'), "__NEXT_ERROR_CODE", {
|
|
89
|
+
value: "E962",
|
|
90
|
+
enumerable: false,
|
|
91
|
+
configurable: true
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
if (currentExecution !== null) {
|
|
95
|
+
bail(currentExecution, Object.defineProperty(new _invarianterror.InvariantError(`Expected all captured immediates to have been executed (state: ${ExecutionState[currentExecution.state]})`), "__NEXT_ERROR_CODE", {
|
|
96
|
+
value: "E958",
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Wait until all nextTicks and microtasks spawned from the current task are done,
|
|
105
|
+
* then execute any immediates that they queued.
|
|
106
|
+
* */ function scheduleWorkAfterNextTicksAndMicrotasks(execution) {
|
|
107
|
+
if (execution.state !== 1) {
|
|
108
|
+
throw Object.defineProperty(new _invarianterror.InvariantError(`scheduleWorkAfterTicksAndMicrotasks can only be called while waiting (state: ${ExecutionState[execution.state]})`), "__NEXT_ERROR_CODE", {
|
|
109
|
+
value: "E959",
|
|
110
|
+
enumerable: false,
|
|
111
|
+
configurable: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// We want to execute "fast immediates" after all the nextTicks and microtasks
|
|
115
|
+
// spawned from the current task are done.
|
|
116
|
+
// The ordering here is:
|
|
117
|
+
//
|
|
118
|
+
// 1. sync code
|
|
119
|
+
// 2. process.nextTick (scheduled from sync code, or from one of these nextTicks)
|
|
120
|
+
// 3. microtasks
|
|
121
|
+
// 4. process.nextTick (scheduled from microtasks, e.g. `queueMicrotask(() => process.nextTick(callback))`)
|
|
122
|
+
//
|
|
123
|
+
// We want to run to run in step 4, because that's the latest point before the next tick.
|
|
124
|
+
// However, there might also be other callbacks scheduled to run in that step.
|
|
125
|
+
// But importantly, they had to be scheduled using a `process.nextTick`,
|
|
126
|
+
// so we can detect them by checking if `pendingNextTicks > 0`.
|
|
127
|
+
// In that case, we'll just reschedule ourselves in the same way again to let them run first.
|
|
128
|
+
// (this process can theoretically repeat multiple times, hence the recursion).
|
|
129
|
+
queueMicrotask(()=>{
|
|
130
|
+
// (note that this call won't increment `pendingNextTicks`,
|
|
131
|
+
// only the patched `process.nextTick` does that, so this won't loop infinitely)
|
|
132
|
+
originalNextTick(()=>{
|
|
133
|
+
// We're now in a nextTick, which means that we're executing inside `processTicksAndRejections`:
|
|
134
|
+
// https://github.com/nodejs/node/blob/d546e7fd0bc3cbb4bcc2baae6f3aa44d2e81a413/lib/internal/process/task_queues.js#L84
|
|
135
|
+
// All the work scheduled here will happen within that `processTicksAndRejections` loop.
|
|
136
|
+
// Reading the source of `processTicksAndRejections` can help understand the timing here --
|
|
137
|
+
// All we're really doing is strategically pushing callbacks into the two queues
|
|
138
|
+
// (nextTicks and microtasks) that that function is currently looping over.
|
|
139
|
+
try {
|
|
140
|
+
if (execution.state === 4 || currentExecution !== execution) {
|
|
141
|
+
debug == null ? void 0 : debug(`scheduler :: the execution was abandoned`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (pendingNextTicks > 0) {
|
|
145
|
+
// Other nextTicks have been scheduled. Let those run first, then try again --
|
|
146
|
+
// we're simulating a event loop task, so all nextTicks should be exhausted before we execute.
|
|
147
|
+
debug == null ? void 0 : debug(`scheduler :: yielding to ${pendingNextTicks} nextTicks`);
|
|
148
|
+
return scheduleWorkAfterNextTicksAndMicrotasks(execution);
|
|
149
|
+
}
|
|
150
|
+
// There's no other nextTicks, we're the last one, so we're about to move on to the next task (likely a timer).
|
|
151
|
+
// Now, we can try and execute any queued immediates.
|
|
152
|
+
return performWork(execution);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
// If this error comes from a bail() call, rethrow it.
|
|
155
|
+
// typescript can't tell that the state might've been mutated
|
|
156
|
+
// and the narrowing from above is no longer valid
|
|
157
|
+
const executionAfterWork = execution;
|
|
158
|
+
if (executionAfterWork.state === 4) {
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
// Otherwise, bail out here (which will trigger an uncaught exception)
|
|
162
|
+
// Note that we're using the same microtask trick as `safelyRunNextTickCallback`.
|
|
163
|
+
queueMicrotask(()=>{
|
|
164
|
+
bail(execution, Object.defineProperty(new _invarianterror.InvariantError('An unexpected error occurred while executing immediates', {
|
|
165
|
+
cause: err
|
|
166
|
+
}), "__NEXT_ERROR_CODE", {
|
|
167
|
+
value: "E955",
|
|
168
|
+
enumerable: false,
|
|
169
|
+
configurable: true
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** Execute one immediate, and schedule a check for more (in case there's others in the queue) */ function performWork(execution) {
|
|
177
|
+
if (execution.state === 4) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
debug == null ? void 0 : debug(`scheduler :: performing work`);
|
|
181
|
+
if (execution.state !== 1) {
|
|
182
|
+
throw Object.defineProperty(new _invarianterror.InvariantError(`performWork can only be called while waiting (state: ${ExecutionState[execution.state]})`), "__NEXT_ERROR_CODE", {
|
|
183
|
+
value: "E956",
|
|
184
|
+
enumerable: false,
|
|
185
|
+
configurable: true
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
execution.state = 2;
|
|
189
|
+
const queueItem = takeNextActiveQueueItem(execution);
|
|
190
|
+
if (queueItem === null) {
|
|
191
|
+
debug == null ? void 0 : debug(`scheduler :: no immediates queued, exiting`);
|
|
192
|
+
stopCapturingImmediates(execution);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
debug == null ? void 0 : debug(`scheduler :: executing queued immediate`);
|
|
196
|
+
const { immediateObject, callback, args } = queueItem;
|
|
197
|
+
immediateObject[INTERNALS].queueItem = null;
|
|
198
|
+
clearQueueItem(queueItem);
|
|
199
|
+
// Execute the immediate.
|
|
200
|
+
// If a sync error was thrown in the immediate, we want to trigger a `uncaughtException`.
|
|
201
|
+
// However, we're executing in a nextTick, and if a nextTick callback errors,
|
|
202
|
+
// It'll break out of `processTicksAndRejections` (note the lack of a `catch` block):
|
|
203
|
+
// https://github.com/nodejs/node/blob/d546e7fd0bc3cbb4bcc2baae6f3aa44d2e81a413/lib/internal/process/task_queues.js#L81-L97
|
|
204
|
+
// Meaning that the event loop will stop executing nextTicks and move on to the next timer
|
|
205
|
+
// (or other phase of the event loop, but we expect to be running in a sequence of timers here).
|
|
206
|
+
// Then, the remaining ticks will run after that timer, since they're still in the queue.
|
|
207
|
+
//
|
|
208
|
+
// This would completely break the timing we're trying to achieve here --
|
|
209
|
+
// The point of this patch is to execute immediates before the next timer!
|
|
210
|
+
// So, we need to work around this behavior. (both here and in our `process.nextTick` patch).
|
|
211
|
+
//
|
|
212
|
+
// We can sidestep this by catching the synchronous error and rethrowing it in a microtask.
|
|
213
|
+
// (NOTE: if we use `queueMicrotask`, it'll trigger `uncaughtException`, not `unhandledRejection`,
|
|
214
|
+
// because there's no promise being rejected.)
|
|
215
|
+
//
|
|
216
|
+
// This will make `uncaughtException` happen:
|
|
217
|
+
// - Before the next fast immediate (`scheduleWorkAfterNextTicksAndMicrotasks` also uses `queueMicrotask`).
|
|
218
|
+
// This is good, and matches usual observable behavior of immediates.
|
|
219
|
+
// - AFTER nextTicks scheduled from the immediate itself.
|
|
220
|
+
// This deviates from native setImmediate, which would call `uncaughtException` first,
|
|
221
|
+
// and skip ahead to the next task as explained above.
|
|
222
|
+
//
|
|
223
|
+
// This is technically an observable difference in behavior, but it seems niche enough that
|
|
224
|
+
// it shouldn't cause problems -- we don't expect user code to use `uncaughtException` for control flow,
|
|
225
|
+
// only error reporting, so subtly changing the timing shouldn't matter.
|
|
226
|
+
let didThrow = false;
|
|
227
|
+
let thrownValue = undefined;
|
|
228
|
+
queueMicrotask(()=>{
|
|
229
|
+
if (didThrow) {
|
|
230
|
+
debug == null ? void 0 : debug('scheduler :: rethrowing sync error from immediate in microtask');
|
|
231
|
+
throw thrownValue;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
try {
|
|
235
|
+
if (args !== null) {
|
|
236
|
+
callback.apply(null, args);
|
|
237
|
+
} else {
|
|
238
|
+
callback();
|
|
239
|
+
}
|
|
240
|
+
} catch (err) {
|
|
241
|
+
// We'll rethrow the error in the microtask above.
|
|
242
|
+
didThrow = true;
|
|
243
|
+
thrownValue = err;
|
|
244
|
+
}
|
|
245
|
+
// Schedule the loop again in case there's more immediates after this one.
|
|
246
|
+
// Note that we can't just check if the queue is empty now, because new immediates
|
|
247
|
+
// might still be scheduled asynchronously, from an upcoming nextTick or microtask.
|
|
248
|
+
execution.state = 1;
|
|
249
|
+
scheduleWorkAfterNextTicksAndMicrotasks(execution);
|
|
250
|
+
}
|
|
251
|
+
function takeNextActiveQueueItem(execution) {
|
|
252
|
+
// Find the first (if any) queued immediate that wasn't cleared.
|
|
253
|
+
// We don't remove immediates from the array when they're cleared,
|
|
254
|
+
// so this requires some legwork to exclude (and possibly drop) cleared items.
|
|
255
|
+
const { queuedImmediates } = execution;
|
|
256
|
+
let firstActiveItem = null;
|
|
257
|
+
let firstActiveItemIndex = -1;
|
|
258
|
+
for(let i = 0; i < queuedImmediates.length; i++){
|
|
259
|
+
const item = queuedImmediates[i];
|
|
260
|
+
if (!item.isCleared) {
|
|
261
|
+
firstActiveItem = item;
|
|
262
|
+
firstActiveItemIndex = i;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (firstActiveItem === null) {
|
|
267
|
+
// We didn't find an active item.
|
|
268
|
+
// If the queue isn't empty, then it must only contain cleared items. Empty it.
|
|
269
|
+
if (queuedImmediates.length > 0) {
|
|
270
|
+
queuedImmediates.length = 0;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
// Remove all items up to and including `nextActiveItemIndex` from the queue.
|
|
275
|
+
// (if it's not the first item, then it must be preceded by cleared items, which we want to drop anyway)
|
|
276
|
+
if (firstActiveItemIndex === 0) {
|
|
277
|
+
// Fast path - drop the first item
|
|
278
|
+
// (`splice` creates a result array for the removed items, so this is more efficient)
|
|
279
|
+
queuedImmediates.shift();
|
|
280
|
+
} else {
|
|
281
|
+
queuedImmediates.splice(0, firstActiveItemIndex + 1);
|
|
282
|
+
}
|
|
283
|
+
return firstActiveItem;
|
|
284
|
+
}
|
|
285
|
+
function startCapturingImmediates() {
|
|
286
|
+
if (currentExecution !== null) {
|
|
287
|
+
bail(currentExecution, Object.defineProperty(new _invarianterror.InvariantError(`Cannot start capturing immediates again without finishing the previous task (state: ${ExecutionState[currentExecution.state]})`), "__NEXT_ERROR_CODE", {
|
|
288
|
+
value: "E954",
|
|
289
|
+
enumerable: false,
|
|
290
|
+
configurable: true
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
wasEnabledAtLeastOnce = true;
|
|
294
|
+
const execution = {
|
|
295
|
+
state: 1,
|
|
296
|
+
queuedImmediates: []
|
|
297
|
+
};
|
|
298
|
+
currentExecution = execution;
|
|
299
|
+
return execution;
|
|
300
|
+
}
|
|
301
|
+
function stopCapturingImmediates(execution) {
|
|
302
|
+
if (execution.state === 4) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
// This check enforces that we run performWork at least once before stopping
|
|
306
|
+
// to make sure that we've waited for all the nextTicks and microtasks
|
|
307
|
+
// that might've scheduled some immediates after sync code.
|
|
308
|
+
if (execution.state !== 2) {
|
|
309
|
+
throw Object.defineProperty(new _invarianterror.InvariantError(`Cannot stop capturing immediates before execution is finished (state: ${ExecutionState[execution.state]})`), "__NEXT_ERROR_CODE", {
|
|
310
|
+
value: "E957",
|
|
311
|
+
enumerable: false,
|
|
312
|
+
configurable: true
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
execution.state = 3;
|
|
316
|
+
if (currentExecution === execution) {
|
|
317
|
+
currentExecution = null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function bail(execution, error) {
|
|
321
|
+
// Reset the state as best we can to prevent further crashes.
|
|
322
|
+
// Otherwise, any subsequent call to `DANGEROUSLY_runPendingImmediatesAfterCurrentTask`
|
|
323
|
+
// would error, requiring a server restart to fix.
|
|
324
|
+
if (currentExecution === execution) {
|
|
325
|
+
currentExecution = null;
|
|
326
|
+
}
|
|
327
|
+
execution.state = 4;
|
|
328
|
+
// If we have any queued immediates, schedule them with native `setImmediate` and clear the queue.
|
|
329
|
+
// We don't want to skip running them altogether, because that could lead to
|
|
330
|
+
// e.g. hanging promises (for `new Promise((resolve) => setImmediate(resolve))`),
|
|
331
|
+
// but we're in an inconsistent state and can't run them as fast immediates,
|
|
332
|
+
// so this is the next best thing.
|
|
333
|
+
for (const queueItem of execution.queuedImmediates){
|
|
334
|
+
if (queueItem.isCleared) {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
scheduleQueuedImmediateAsNativeImmediate(queueItem);
|
|
338
|
+
}
|
|
339
|
+
execution.queuedImmediates.length = 0;
|
|
340
|
+
// Don't reset `pendingNextTicks` -- it will reset to 0 on its own as the nextTicks execute.
|
|
341
|
+
// If we set it to 0 here while we still have pending ticks, they'd decrement it below 0.
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
function scheduleQueuedImmediateAsNativeImmediate(queueItem) {
|
|
345
|
+
const { callback, args, immediateObject } = queueItem;
|
|
346
|
+
const hasRef = immediateObject[INTERNALS].hasRef;
|
|
347
|
+
clearQueueItem(queueItem);
|
|
348
|
+
const nativeImmediate = args !== null ? originalSetImmediate(callback, ...args) : originalSetImmediate(callback);
|
|
349
|
+
if (!hasRef) {
|
|
350
|
+
nativeImmediate.unref();
|
|
351
|
+
}
|
|
352
|
+
// Make our fake immediate object proxy all relevant operations
|
|
353
|
+
// (clearing, ref(), unref(), hasRef()) to the actual native immediate.
|
|
354
|
+
proxyQueuedImmediateToNativeImmediate(immediateObject, nativeImmediate);
|
|
355
|
+
}
|
|
356
|
+
function clearQueueItem(originalQueueItem) {
|
|
357
|
+
const queueItem = originalQueueItem;
|
|
358
|
+
queueItem.isCleared = true;
|
|
359
|
+
queueItem.callback = null;
|
|
360
|
+
queueItem.args = null;
|
|
361
|
+
queueItem.immediateObject = null;
|
|
362
|
+
}
|
|
363
|
+
function patchedNextTick() {
|
|
364
|
+
if (currentExecution === null) {
|
|
365
|
+
return originalNextTick.apply(null, // @ts-expect-error: this is valid, but typescript doesn't get it
|
|
366
|
+
arguments);
|
|
367
|
+
}
|
|
368
|
+
if (arguments.length === 0 || typeof arguments[0] !== 'function') {
|
|
369
|
+
// Let the original nextTick error for invalid arguments
|
|
370
|
+
// so that we don't have to mirror the error message.
|
|
371
|
+
originalNextTick.apply(null, // @ts-expect-error: explicitly passing arguments that we know are invalid
|
|
372
|
+
arguments);
|
|
373
|
+
// We expect the above call to throw. If it didn't, something's broken.
|
|
374
|
+
bail(currentExecution, Object.defineProperty(new _invarianterror.InvariantError('Expected process.nextTick to reject invalid arguments'), "__NEXT_ERROR_CODE", {
|
|
375
|
+
value: "E966",
|
|
376
|
+
enumerable: false,
|
|
377
|
+
configurable: true
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
debug == null ? void 0 : debug(`scheduler :: process.nextTick called (previous pending: ${pendingNextTicks})`);
|
|
381
|
+
const callback = arguments[0];
|
|
382
|
+
const args = arguments.length > 1 ? Array.prototype.slice.call(arguments, 1) : null;
|
|
383
|
+
pendingNextTicks += 1;
|
|
384
|
+
return originalNextTick(safelyRunNextTickCallback, callback, args);
|
|
385
|
+
}
|
|
386
|
+
function safelyRunNextTickCallback(callback, args) {
|
|
387
|
+
pendingNextTicks -= 1;
|
|
388
|
+
debug == null ? void 0 : debug(`scheduler :: process.nextTick executing (still pending: ${pendingNextTicks})`);
|
|
389
|
+
// Synchronous errors in nextTick break out of `processTicksAndRejections` and cause us
|
|
390
|
+
// to move on to the next timer without having executed the whole nextTick queue,
|
|
391
|
+
// which breaks our entire scheduling mechanism. See `performWork` for more details.
|
|
392
|
+
try {
|
|
393
|
+
if (args !== null) {
|
|
394
|
+
callback.apply(null, args);
|
|
395
|
+
} else {
|
|
396
|
+
callback();
|
|
397
|
+
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
// We want to make sure `nextTick` is cheap, so unlike `performWork`,
|
|
400
|
+
// we only queue the microtask if an error actually occurs.
|
|
401
|
+
// This (observably) changes the timing of `uncaughtException` even more,
|
|
402
|
+
// because it'll run after microtasks queued from the nextTick,
|
|
403
|
+
// but hopefully this is niche enough to not affect any real world code.
|
|
404
|
+
queueMicrotask(()=>{
|
|
405
|
+
debug == null ? void 0 : debug(`scheduler :: rethrowing sync error from nextTick in a microtask`);
|
|
406
|
+
throw err;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function patchedSetImmediate() {
|
|
411
|
+
if (currentExecution === null) {
|
|
412
|
+
return originalSetImmediate.apply(null, // @ts-expect-error: this is valid, but typescript doesn't get it
|
|
413
|
+
arguments);
|
|
414
|
+
}
|
|
415
|
+
if (arguments.length === 0 || typeof arguments[0] !== 'function') {
|
|
416
|
+
// Let the original setImmediate error for invalid arguments
|
|
417
|
+
// so that we don't have to mirror the error message.
|
|
418
|
+
originalSetImmediate.apply(null, // @ts-expect-error: explicitly passing arguments that we know are invalid
|
|
419
|
+
arguments);
|
|
420
|
+
// We expect the above call to throw. If it didn't, something's broken.
|
|
421
|
+
bail(currentExecution, Object.defineProperty(new _invarianterror.InvariantError('Expected setImmediate to reject invalid arguments'), "__NEXT_ERROR_CODE", {
|
|
422
|
+
value: "E965",
|
|
423
|
+
enumerable: false,
|
|
424
|
+
configurable: true
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
const callback = arguments[0];
|
|
428
|
+
const args = arguments.length > 1 ? Array.prototype.slice.call(arguments, 1) : null;
|
|
429
|
+
// Normally, Node would capture and propagate the async context to the immediate.
|
|
430
|
+
// We'll be running it on our own queue, so we need to propagate it ourselves.
|
|
431
|
+
const callbackWithAsyncContext = (0, _asynclocalstorage.bindSnapshot)(callback);
|
|
432
|
+
const immediateObject = new NextImmediate();
|
|
433
|
+
const queueItem = {
|
|
434
|
+
isCleared: false,
|
|
435
|
+
callback: callbackWithAsyncContext,
|
|
436
|
+
args,
|
|
437
|
+
immediateObject
|
|
438
|
+
};
|
|
439
|
+
currentExecution.queuedImmediates.push(queueItem);
|
|
440
|
+
immediateObject[INTERNALS].queueItem = queueItem;
|
|
441
|
+
return immediateObject;
|
|
442
|
+
}
|
|
443
|
+
function patchedSetImmediatePromise(value, options) {
|
|
444
|
+
if (currentExecution === null) {
|
|
445
|
+
const originalPromisify = // @ts-expect-error: the types for `promisify.custom` are strange
|
|
446
|
+
originalSetImmediate[_nodeutil.promisify.custom];
|
|
447
|
+
return originalPromisify(value, options);
|
|
448
|
+
}
|
|
449
|
+
return new Promise((resolve, reject)=>{
|
|
450
|
+
// The abort signal makes the promise reject.
|
|
451
|
+
// If it is already aborted, we reject immediately.
|
|
452
|
+
const signal = options == null ? void 0 : options.signal;
|
|
453
|
+
if (signal && signal.aborted) {
|
|
454
|
+
return reject(signal.reason);
|
|
455
|
+
}
|
|
456
|
+
const immediate = patchedSetImmediate(resolve, value);
|
|
457
|
+
// Unref-ing only really has an observable effect if we bail out to a native immediate,
|
|
458
|
+
// but we do it for completeness
|
|
459
|
+
if ((options == null ? void 0 : options.ref) === false) {
|
|
460
|
+
immediate.unref();
|
|
461
|
+
}
|
|
462
|
+
if (signal) {
|
|
463
|
+
signal.addEventListener('abort', ()=>{
|
|
464
|
+
patchedClearImmediate(immediate);
|
|
465
|
+
reject(signal.reason);
|
|
466
|
+
}, {
|
|
467
|
+
once: true
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
patchedSetImmediate[_nodeutil.promisify.custom] = patchedSetImmediatePromise;
|
|
473
|
+
const patchedClearImmediate = (immediateObject)=>{
|
|
474
|
+
// NOTE: we defensively check for patched immediates even if we're not
|
|
475
|
+
// currently capturing immediates, because the objects returned from
|
|
476
|
+
// the patched setImmediate can be kept around for arbitrarily long.
|
|
477
|
+
// As an optimization, we only do this if the patch was enabled at least once --
|
|
478
|
+
// otherwise, no patched objects could've been created.
|
|
479
|
+
if (wasEnabledAtLeastOnce && immediateObject && typeof immediateObject === 'object' && INTERNALS in immediateObject) {
|
|
480
|
+
;
|
|
481
|
+
immediateObject[Symbol.dispose]();
|
|
482
|
+
} else {
|
|
483
|
+
originalClearImmediate(immediateObject);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
//========================================================
|
|
487
|
+
const INTERNALS = Symbol.for('next.Immediate.internals');
|
|
488
|
+
function proxyQueuedImmediateToNativeImmediate(immediateObject, nativeImmediate) {
|
|
489
|
+
immediateObject[INTERNALS].hasRef = null;
|
|
490
|
+
immediateObject[INTERNALS].queueItem = null;
|
|
491
|
+
immediateObject[INTERNALS].nativeImmediate = nativeImmediate;
|
|
492
|
+
}
|
|
493
|
+
/** Implements a shim for the native `Immediate` class returned by `setImmediate` */ class NextImmediate {
|
|
494
|
+
hasRef() {
|
|
495
|
+
const internals = this[INTERNALS];
|
|
496
|
+
if (internals.queueItem) {
|
|
497
|
+
return internals.hasRef;
|
|
498
|
+
} else if (internals.nativeImmediate) {
|
|
499
|
+
return internals.nativeImmediate.hasRef();
|
|
500
|
+
} else {
|
|
501
|
+
// if we're no longer queued (cleared or executed), hasRef is always false
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
ref() {
|
|
506
|
+
const internals = this[INTERNALS];
|
|
507
|
+
if (internals.queueItem) {
|
|
508
|
+
internals.hasRef = true;
|
|
509
|
+
} else if (internals.nativeImmediate) {
|
|
510
|
+
internals.nativeImmediate.ref();
|
|
511
|
+
}
|
|
512
|
+
return this;
|
|
513
|
+
}
|
|
514
|
+
unref() {
|
|
515
|
+
const internals = this[INTERNALS];
|
|
516
|
+
if (internals.queueItem) {
|
|
517
|
+
internals.hasRef = false;
|
|
518
|
+
} else if (internals.nativeImmediate) {
|
|
519
|
+
internals.nativeImmediate.unref();
|
|
520
|
+
}
|
|
521
|
+
return this;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Node invokes `_onImmediate` when an immediate is executed:
|
|
525
|
+
* https://github.com/nodejs/node/blob/42d363205715ffa5a4a6d90f4be1311487053d65/lib/internal/timers.js#L504
|
|
526
|
+
* It's visible on the public types, so we want to have it here for parity, but it's a noop.
|
|
527
|
+
* */ _onImmediate() {}
|
|
528
|
+
[Symbol.dispose]() {
|
|
529
|
+
// This is equivalent to `clearImmediate`.
|
|
530
|
+
const internals = this[INTERNALS];
|
|
531
|
+
if (internals.queueItem) {
|
|
532
|
+
// this is still queued. drop it.
|
|
533
|
+
const queueItem = internals.queueItem;
|
|
534
|
+
internals.queueItem = null;
|
|
535
|
+
clearQueueItem(queueItem);
|
|
536
|
+
} else if (internals.nativeImmediate) {
|
|
537
|
+
internals.nativeImmediate[Symbol.dispose]();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
constructor(){
|
|
541
|
+
this[INTERNALS] = {
|
|
542
|
+
queueItem: null,
|
|
543
|
+
hasRef: true,
|
|
544
|
+
nativeImmediate: null
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// ==========================================
|
|
549
|
+
const debug = process.env.NEXT_DEBUG_IMMEDIATES !== '1' ? undefined : (...args)=>{
|
|
550
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
551
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('Fast setImmediate is not available in the edge runtime.'), "__NEXT_ERROR_CODE", {
|
|
552
|
+
value: "E963",
|
|
553
|
+
enumerable: false,
|
|
554
|
+
configurable: true
|
|
555
|
+
});
|
|
556
|
+
} else {
|
|
557
|
+
const { inspect } = require('node:util');
|
|
558
|
+
const { writeFileSync } = require('node:fs');
|
|
559
|
+
let logLine = args.map((arg)=>typeof arg === 'string' ? arg : inspect(arg, {
|
|
560
|
+
colors: true
|
|
561
|
+
})).join(' ') + '\n';
|
|
562
|
+
logLine = '\x1B[2m' + logLine + '\x1B[22m' // styleText('dim', logLine)
|
|
563
|
+
;
|
|
564
|
+
writeFileSync(process.stdout.fd, logLine);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
// ==========================================
|
|
568
|
+
install();
|
|
569
|
+
|
|
570
|
+
//# sourceMappingURL=fast-set-immediate.external.js.map
|
|
@@ -12,6 +12,7 @@ const _workasyncstorageexternal = require("../app-render/work-async-storage.exte
|
|
|
12
12
|
const _workunitasyncstorageexternal = require("../app-render/work-unit-async-storage.external");
|
|
13
13
|
const _dynamicrendering = require("../app-render/dynamic-rendering");
|
|
14
14
|
const _invarianterror = require("../../shared/lib/invariant-error");
|
|
15
|
+
const _stagedrendering = require("../app-render/staged-rendering");
|
|
15
16
|
const _runtimereactsexternal = require("../runtime-reacts.external");
|
|
16
17
|
function io(expression, type) {
|
|
17
18
|
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
|
|
@@ -87,7 +88,63 @@ function io(expression, type) {
|
|
|
87
88
|
}
|
|
88
89
|
case 'request':
|
|
89
90
|
if (process.env.NODE_ENV === 'development') {
|
|
90
|
-
|
|
91
|
+
const stageController = workUnitStore.stagedRendering;
|
|
92
|
+
if (stageController && stageController.canSyncInterrupt()) {
|
|
93
|
+
let message;
|
|
94
|
+
if (stageController.currentStage === _stagedrendering.RenderStage.Static) {
|
|
95
|
+
switch(type){
|
|
96
|
+
case 'time':
|
|
97
|
+
message = `Route "${workStore.route}" used ${expression} before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time`;
|
|
98
|
+
break;
|
|
99
|
+
case 'random':
|
|
100
|
+
message = `Route "${workStore.route}" used ${expression} before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random`;
|
|
101
|
+
break;
|
|
102
|
+
case 'crypto':
|
|
103
|
+
message = `Route "${workStore.route}" used ${expression} before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto`;
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('Unknown expression type in abortOnSynchronousPlatformIOAccess.'), "__NEXT_ERROR_CODE", {
|
|
107
|
+
value: "E526",
|
|
108
|
+
enumerable: false,
|
|
109
|
+
configurable: true
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// We're in the Runtime stage.
|
|
114
|
+
// We only error for Sync IO in the Runtime stage if the route has a runtime prefetch config.
|
|
115
|
+
// This check is implemented in `stageController.canSyncInterrupt()` --
|
|
116
|
+
// if runtime prefetching isn't enabled, then we won't get here.
|
|
117
|
+
let accessStatement;
|
|
118
|
+
let additionalInfoLink;
|
|
119
|
+
switch(type){
|
|
120
|
+
case 'time':
|
|
121
|
+
accessStatement = 'the current time';
|
|
122
|
+
additionalInfoLink = 'https://nextjs.org/docs/messages/next-prerender-runtime-current-time';
|
|
123
|
+
break;
|
|
124
|
+
case 'random':
|
|
125
|
+
accessStatement = 'random values synchronously';
|
|
126
|
+
additionalInfoLink = 'https://nextjs.org/docs/messages/next-prerender-runtime-random';
|
|
127
|
+
break;
|
|
128
|
+
case 'crypto':
|
|
129
|
+
accessStatement = 'random cryptographic values synchronously';
|
|
130
|
+
additionalInfoLink = 'https://nextjs.org/docs/messages/next-prerender-runtime-crypto';
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('Unknown expression type in abortOnSynchronousPlatformIOAccess.'), "__NEXT_ERROR_CODE", {
|
|
134
|
+
value: "E526",
|
|
135
|
+
enumerable: false,
|
|
136
|
+
configurable: true
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
message = `Route "${workStore.route}" used ${expression} before accessing either uncached data (e.g. \`fetch()\`) or awaiting \`connection()\`. When configured for Runtime prefetching, accessing ${accessStatement} in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: ${additionalInfoLink}`;
|
|
140
|
+
}
|
|
141
|
+
const syncIOError = applyOwnerStack(Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
|
|
142
|
+
value: "E394",
|
|
143
|
+
enumerable: false,
|
|
144
|
+
configurable: true
|
|
145
|
+
}));
|
|
146
|
+
stageController.syncInterruptCurrentStageWithReason(syncIOError);
|
|
147
|
+
}
|
|
91
148
|
}
|
|
92
149
|
break;
|
|
93
150
|
case 'prerender-ppr':
|
|
@@ -106,8 +163,8 @@ function applyOwnerStack(error) {
|
|
|
106
163
|
// owner stack, instead of logging it deferred in the `LogSafely` component
|
|
107
164
|
// via `throwIfDisallowedDynamic`.
|
|
108
165
|
if (process.env.NODE_ENV !== 'production') {
|
|
109
|
-
var _getClientReact, _getServerReact;
|
|
110
|
-
const ownerStack = ((_getClientReact = (0, _runtimereactsexternal.getClientReact)()) == null ? void 0 : _getClientReact.captureOwnerStack()) ?? ((_getServerReact = (0, _runtimereactsexternal.getServerReact)()) == null ? void 0 : _getServerReact.captureOwnerStack());
|
|
166
|
+
var _getClientReact_captureOwnerStack, _getClientReact, _getServerReact_captureOwnerStack, _getServerReact;
|
|
167
|
+
const ownerStack = ((_getClientReact = (0, _runtimereactsexternal.getClientReact)()) == null ? void 0 : (_getClientReact_captureOwnerStack = _getClientReact.captureOwnerStack) == null ? void 0 : _getClientReact_captureOwnerStack.call(_getClientReact)) ?? ((_getServerReact = (0, _runtimereactsexternal.getServerReact)()) == null ? void 0 : (_getServerReact_captureOwnerStack = _getServerReact.captureOwnerStack) == null ? void 0 : _getServerReact_captureOwnerStack.call(_getServerReact));
|
|
111
168
|
if (ownerStack) {
|
|
112
169
|
let stack = ownerStack;
|
|
113
170
|
if (error.stack) {
|
|
@@ -14,5 +14,6 @@ require("./node-environment-extensions/random");
|
|
|
14
14
|
require("./node-environment-extensions/date");
|
|
15
15
|
require("./node-environment-extensions/web-crypto");
|
|
16
16
|
require("./node-environment-extensions/node-crypto");
|
|
17
|
+
require("./node-environment-extensions/fast-set-immediate.external");
|
|
17
18
|
|
|
18
19
|
//# sourceMappingURL=node-environment.js.map
|