@aeolus-fleet/console 0.30.0 → 0.30.1
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/.next/standalone/packages/console/.next/BUILD_ID +1 -1
- package/.next/standalone/packages/console/.next/build-manifest.json +3 -3
- package/.next/standalone/packages/console/.next/node_modules/import-in-the-middle-ac114f323ad7e863/index.js +221 -0
- package/.next/standalone/packages/console/.next/node_modules/import-in-the-middle-ac114f323ad7e863/lib/register.js +285 -0
- package/.next/standalone/packages/console/.next/node_modules/import-in-the-middle-ac114f323ad7e863/package.json +66 -0
- package/.next/standalone/packages/console/.next/node_modules/require-in-the-middle-2ca7b9c2766f317e/index.js +333 -0
- package/.next/standalone/packages/console/.next/node_modules/require-in-the-middle-2ca7b9c2766f317e/package.json +57 -0
- package/.next/standalone/packages/console/.next/prerender-manifest.json +3 -3
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/[cause]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/fleet-health/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/inbox/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/labels/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/labels/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/labels/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-attention/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/needs-crew/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/network/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/network/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/network/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/settings/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/settings/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/ships/[shipId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/[squadronId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/blueprints/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/squadrons/templates/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/[shipId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page/server-reference-manifest.json +14 -14
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/(console)/trierarchs/page_client-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/packages/console/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/packages/console/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/packages/console/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/packages/console/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/packages/console/.next/server/app/api/reads/[read]/route.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/app/version/route.js.nft.json +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/[root-of-the-server]__0-b_d8j._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/[root-of-the-server]__0w4s32w._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{0ysl_console_features_trierarchs_ui_organisms_clear-worktree-dialog_tsx_1rm9l2e._.js → 0ysl_console_features_trierarchs_ui_organisms_clear-worktree-dialog_tsx_1cj5i3d._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/_0bdsmu0._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{_0bzwxa5._.js → _0h-jnay._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{_0vw3hp0._.js → _135805g._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{_1eaafw1._.js → _18owi6c._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/_1hsu1v2._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{_1wqk91b._.js → _1ia6sfj._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/_1u0h4gj._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{_0bzikib._.js → _20ltycf._.js} +2 -2
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_00qg_s6._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_02v53na._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_02wkudy._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_04rox65._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_05zitd2._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_065nea1._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_0h_376h._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_0ko_ogs._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_0sr2-oa._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_0ysbad7._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_108sez2._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_1pslvww._.js → packages_console_1e33jj3._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_1jy5-0g._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_1pyirkn._.js → packages_console_1k1crw1._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_1n8w8x0._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_1oz8iu7._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_11tdbkt._.js → packages_console_1qi485p._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_1rdu3gt._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/packages_console_1yfimad._.js +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_components_organisms_crew-line-dialog_tsx_03yc7m2._.js → packages_console_components_organisms_crew-line-dialog_tsx_11y3we6._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/chunks/ssr/{packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_080dycl._.js → packages_console_features_squadrons_organisms_form-squadron-dialog_tsx_04jnwy5._.js} +1 -1
- package/.next/standalone/packages/console/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/packages/console/.next/server/pages/500.html +1 -1
- package/.next/standalone/packages/console/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/packages/console/.next/server/server-reference-manifest.json +15 -15
- package/.next/standalone/packages/console/.next/static/chunks/{3aavctmtw4-fi.js → 046j0y9wgycm0.js} +1 -1
- package/.next/standalone/packages/console/.next/static/chunks/{1dwd950z6uq3v.js → 180jsws8b9eq6.js} +1 -1
- package/.next/standalone/packages/console/.next/static/chunks/{0w5mjb10dj8-h.js → 20zd_xtfl07ru.js} +1 -1
- package/.next/standalone/packages/console/package.json +3 -3
- package/package.json +3 -3
- /package/.next/standalone/packages/console/.next/static/{10-qWFsL7UDAGlmmFXFB- → FhQ486AZAouB_wqS1YEzn}/_buildManifest.js +0 -0
- /package/.next/standalone/packages/console/.next/static/{10-qWFsL7UDAGlmmFXFB- → FhQ486AZAouB_wqS1YEzn}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/packages/console/.next/static/{10-qWFsL7UDAGlmmFXFB- → FhQ486AZAouB_wqS1YEzn}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
FhQ486AZAouB_wqS1YEzn
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"static/chunks/0cz1d0mv5g_q7.js"
|
|
8
8
|
],
|
|
9
9
|
"lowPriorityFiles": [
|
|
10
|
-
"static/
|
|
11
|
-
"static/
|
|
12
|
-
"static/
|
|
10
|
+
"static/FhQ486AZAouB_wqS1YEzn/_buildManifest.js",
|
|
11
|
+
"static/FhQ486AZAouB_wqS1YEzn/_ssgManifest.js",
|
|
12
|
+
"static/FhQ486AZAouB_wqS1YEzn/_clientMiddlewareManifest.js"
|
|
13
13
|
],
|
|
14
14
|
"rootMainFiles": [
|
|
15
15
|
"static/chunks/0wf2rmyoojkx7.js",
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License.
|
|
2
|
+
//
|
|
3
|
+
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const moduleDetailsFromPath = require('module-details-from-path')
|
|
7
|
+
const { fileURLToPath } = require('url')
|
|
8
|
+
const { MessageChannel } = require('worker_threads')
|
|
9
|
+
|
|
10
|
+
let { isBuiltin } = require('module')
|
|
11
|
+
if (!isBuiltin) {
|
|
12
|
+
isBuiltin = () => true
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
importHooks,
|
|
17
|
+
specifiers,
|
|
18
|
+
toHook
|
|
19
|
+
} = require('./lib/register')
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Checks turbopack specifiers separately (for Next.js 16+).
|
|
23
|
+
*
|
|
24
|
+
* If turbopack is used, specifiers will have an additional hash appended to the end.
|
|
25
|
+
* Something like "ai" might become "ai-5e7181a616786b24". This only happens in Next.js 16+.
|
|
26
|
+
* Just checking if the baseDir ends with this new specifier won't match, as the baseDir still has the plain package.
|
|
27
|
+
*
|
|
28
|
+
* This logic isolates a new check for checking the actual name in the case turbopack is being used.
|
|
29
|
+
*
|
|
30
|
+
* @param specifier {string}
|
|
31
|
+
* @param baseDir {string}
|
|
32
|
+
*/
|
|
33
|
+
function isTurbopackSpecifier (specifier, baseDir) {
|
|
34
|
+
const usingTurbopack = process.env.TURBOPACK ?? process.argv.includes('--turbo')
|
|
35
|
+
if (!usingTurbopack) return false
|
|
36
|
+
|
|
37
|
+
const specifierWithoutTurbopackHash = specifier.slice(0, specifier.lastIndexOf('-'))
|
|
38
|
+
return baseDir.endsWith(specifierWithoutTurbopackHash)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function addHook (hook) {
|
|
42
|
+
importHooks.push(hook)
|
|
43
|
+
toHook.forEach(([name, namespace, specifier]) => hook(name, namespace, specifier))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function removeHook (hook) {
|
|
47
|
+
const index = importHooks.indexOf(hook)
|
|
48
|
+
if (index > -1) {
|
|
49
|
+
importHooks.splice(index, 1)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function callHookFn (hookFn, namespace, name, baseDir) {
|
|
54
|
+
const newDefault = hookFn(namespace, name, baseDir)
|
|
55
|
+
if (newDefault && newDefault !== namespace) {
|
|
56
|
+
// Only ESM modules that actually export `default` can have it reassigned.
|
|
57
|
+
// Some hooks return a value unconditionally; avoid crashing when the module
|
|
58
|
+
// has no default export (see issue #188).
|
|
59
|
+
if ('default' in namespace) {
|
|
60
|
+
namespace.default = newDefault
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let sendModulesToLoader
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* EXPERIMENTAL
|
|
69
|
+
* This feature is experimental and may change in minor versions.
|
|
70
|
+
* **NOTE** This feature is incompatible with the {internals: true} Hook option.
|
|
71
|
+
*
|
|
72
|
+
* Creates a message channel with a port that can be used to add hooks to the
|
|
73
|
+
* list of exclusively included modules.
|
|
74
|
+
*
|
|
75
|
+
* This can be used to only wrap modules that are Hook'ed, however modules need
|
|
76
|
+
* to be hooked before they are imported.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { register } from 'module'
|
|
80
|
+
* import { Hook, createAddHookMessageChannel } from 'import-in-the-middle'
|
|
81
|
+
*
|
|
82
|
+
* const { registerOptions, waitForAllMessagesAcknowledged } = createAddHookMessageChannel()
|
|
83
|
+
*
|
|
84
|
+
* register('import-in-the-middle/hook.mjs', import.meta.url, registerOptions)
|
|
85
|
+
*
|
|
86
|
+
* Hook(['fs'], (exported, name, baseDir) => {
|
|
87
|
+
* // Instrument the fs module
|
|
88
|
+
* })
|
|
89
|
+
*
|
|
90
|
+
* // Ensure that the loader has acknowledged all the modules
|
|
91
|
+
* // before we allow execution to continue
|
|
92
|
+
* await waitForAllMessagesAcknowledged()
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
function createAddHookMessageChannel () {
|
|
96
|
+
const { port1, port2 } = new MessageChannel()
|
|
97
|
+
let pendingAckCount = 0
|
|
98
|
+
let resolveFn
|
|
99
|
+
|
|
100
|
+
sendModulesToLoader = (modules) => {
|
|
101
|
+
pendingAckCount++
|
|
102
|
+
port1.postMessage(modules)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
port1.on('message', () => {
|
|
106
|
+
pendingAckCount--
|
|
107
|
+
|
|
108
|
+
if (resolveFn && pendingAckCount <= 0) {
|
|
109
|
+
resolveFn()
|
|
110
|
+
}
|
|
111
|
+
}).unref()
|
|
112
|
+
|
|
113
|
+
function waitForAllMessagesAcknowledged () {
|
|
114
|
+
// This timer is to prevent the process from exiting with code 13:
|
|
115
|
+
// 13: Unsettled Top-Level Await.
|
|
116
|
+
const timer = setInterval(() => { }, 1000)
|
|
117
|
+
const promise = new Promise((resolve) => {
|
|
118
|
+
resolveFn = resolve
|
|
119
|
+
}).then(() => { clearInterval(timer) })
|
|
120
|
+
|
|
121
|
+
if (pendingAckCount === 0) {
|
|
122
|
+
resolveFn()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return promise
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const addHookMessagePort = port2
|
|
129
|
+
const registerOptions = { data: { addHookMessagePort, include: [] }, transferList: [addHookMessagePort] }
|
|
130
|
+
|
|
131
|
+
return { registerOptions, addHookMessagePort, waitForAllMessagesAcknowledged }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function Hook (modules, options, hookFn) {
|
|
135
|
+
if ((this instanceof Hook) === false) return new Hook(modules, options, hookFn)
|
|
136
|
+
if (typeof modules === 'function') {
|
|
137
|
+
hookFn = modules
|
|
138
|
+
modules = null
|
|
139
|
+
options = null
|
|
140
|
+
} else if (typeof options === 'function') {
|
|
141
|
+
hookFn = options
|
|
142
|
+
options = null
|
|
143
|
+
}
|
|
144
|
+
const internals = options ? options.internals === true : false
|
|
145
|
+
|
|
146
|
+
if (sendModulesToLoader && Array.isArray(modules)) {
|
|
147
|
+
sendModulesToLoader(modules)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this._iitmHook = (name, namespace, specifier) => {
|
|
151
|
+
const loadUrl = name
|
|
152
|
+
const isNodeUrl = loadUrl.startsWith('node:')
|
|
153
|
+
let filePath, baseDir
|
|
154
|
+
|
|
155
|
+
if (isNodeUrl) {
|
|
156
|
+
// Normalize builtin module name to *not* have 'node:' prefix, unless
|
|
157
|
+
// required, as it is for 'node:test' and some others. `module.isBuiltin`
|
|
158
|
+
// is available in all Node.js versions that have node:-only modules.
|
|
159
|
+
const unprefixed = name.slice(5)
|
|
160
|
+
if (isBuiltin(unprefixed)) {
|
|
161
|
+
name = unprefixed
|
|
162
|
+
}
|
|
163
|
+
} else if (loadUrl.startsWith('file://')) {
|
|
164
|
+
const stackTraceLimit = Error.stackTraceLimit
|
|
165
|
+
Error.stackTraceLimit = 0
|
|
166
|
+
try {
|
|
167
|
+
filePath = fileURLToPath(name)
|
|
168
|
+
name = filePath
|
|
169
|
+
} catch (e) {}
|
|
170
|
+
Error.stackTraceLimit = stackTraceLimit
|
|
171
|
+
|
|
172
|
+
if (filePath) {
|
|
173
|
+
const details = moduleDetailsFromPath(filePath)
|
|
174
|
+
if (details) {
|
|
175
|
+
name = details.name
|
|
176
|
+
baseDir = details.basedir
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (modules) {
|
|
182
|
+
for (const matchArg of modules) {
|
|
183
|
+
if (filePath && matchArg === filePath) {
|
|
184
|
+
// abspath match
|
|
185
|
+
callHookFn(hookFn, namespace, filePath, undefined)
|
|
186
|
+
} else if (matchArg === name) {
|
|
187
|
+
if (!baseDir) {
|
|
188
|
+
// built-in module (or unexpected non file:// name?)
|
|
189
|
+
callHookFn(hookFn, namespace, name, baseDir)
|
|
190
|
+
} else if (baseDir.endsWith(specifiers.get(loadUrl)) || isTurbopackSpecifier(specifiers.get(loadUrl), baseDir)) {
|
|
191
|
+
// An import of the top-level module (e.g. `import 'ioredis'`).
|
|
192
|
+
// Note: Slight behaviour difference from RITM. RITM uses
|
|
193
|
+
// `require.resolve(name)` to see if filename is the module
|
|
194
|
+
// main file, which will catch `require('ioredis/built/index.js')`.
|
|
195
|
+
// The check here will not catch `import 'ioredis/built/index.js'`.
|
|
196
|
+
callHookFn(hookFn, namespace, name, baseDir)
|
|
197
|
+
} else if (internals) {
|
|
198
|
+
const internalPath = name + path.sep + path.relative(baseDir, filePath)
|
|
199
|
+
callHookFn(hookFn, namespace, internalPath, baseDir)
|
|
200
|
+
}
|
|
201
|
+
} else if (matchArg === specifier) {
|
|
202
|
+
callHookFn(hookFn, namespace, specifier, baseDir)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
callHookFn(hookFn, namespace, name, baseDir)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
addHook(this._iitmHook)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
Hook.prototype.unhook = function () {
|
|
214
|
+
removeHook(this._iitmHook)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = Hook
|
|
218
|
+
module.exports.Hook = Hook
|
|
219
|
+
module.exports.addHook = addHook
|
|
220
|
+
module.exports.removeHook = removeHook
|
|
221
|
+
module.exports.createAddHookMessageChannel = createAddHookMessageChannel
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License.
|
|
2
|
+
//
|
|
3
|
+
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.
|
|
4
|
+
|
|
5
|
+
const importHooks = [] // TODO should this be a Set?
|
|
6
|
+
const binders = new WeakMap()
|
|
7
|
+
let legacySetters
|
|
8
|
+
let legacyGetters
|
|
9
|
+
let legacyProxyHandler
|
|
10
|
+
const specifiers = new Map()
|
|
11
|
+
const toHook = []
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {object} source The module namespace.
|
|
15
|
+
* @param {string | symbol} name The export name.
|
|
16
|
+
*/
|
|
17
|
+
function readExport (source, name) {
|
|
18
|
+
if (name === 'module.exports' && !Object.hasOwn(source, name)) {
|
|
19
|
+
return source.default
|
|
20
|
+
}
|
|
21
|
+
return source[name]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {object} target The proxy target.
|
|
26
|
+
* @param {string | symbol} name The export name.
|
|
27
|
+
* @param {unknown} value The replacement value.
|
|
28
|
+
*/
|
|
29
|
+
function setExport (target, name, value) {
|
|
30
|
+
return binders.get(target).write(name, value)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {object} target The proxy target.
|
|
35
|
+
* @param {string | symbol} name The export name.
|
|
36
|
+
* @param {PropertyDescriptor} descriptor The replacement descriptor.
|
|
37
|
+
*/
|
|
38
|
+
function defineExport (target, name, descriptor) {
|
|
39
|
+
if (!('value' in descriptor)) {
|
|
40
|
+
throw new Error('Getters/setters are not supported for exports property descriptors.')
|
|
41
|
+
}
|
|
42
|
+
return setExport(target, name, descriptor.value)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const proxyHandler = { defineProperty: defineExport, set: setExport }
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {object} target The proxy target.
|
|
49
|
+
* @param {string | symbol} name The export name.
|
|
50
|
+
* @param {unknown} value The replacement value.
|
|
51
|
+
*/
|
|
52
|
+
function setLegacyExport (target, name, value) {
|
|
53
|
+
const setter = legacySetters.get(target)?.[name]
|
|
54
|
+
return typeof setter === 'function' ? setter(value) : true
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {object} target The proxy target.
|
|
59
|
+
* @param {string | symbol} name The export name.
|
|
60
|
+
*/
|
|
61
|
+
function getLegacyExport (target, name) {
|
|
62
|
+
if (name === Symbol.toStringTag) return 'Module'
|
|
63
|
+
|
|
64
|
+
const getter = legacyGetters.get(target)[name]
|
|
65
|
+
if (typeof getter === 'function') return getter()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {object} target The proxy target.
|
|
70
|
+
* @param {string | symbol} name The export name.
|
|
71
|
+
* @param {PropertyDescriptor} descriptor The replacement descriptor.
|
|
72
|
+
*/
|
|
73
|
+
function defineLegacyExport (target, name, descriptor) {
|
|
74
|
+
if (!('value' in descriptor)) {
|
|
75
|
+
throw new Error('Getters/setters are not supported for exports property descriptors.')
|
|
76
|
+
}
|
|
77
|
+
return setLegacyExport(target, name, descriptor.value)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} name The wrapped module URL.
|
|
82
|
+
* @param {object} namespace The wrapper's module namespace.
|
|
83
|
+
* @param {object} set The wrapper's export setters.
|
|
84
|
+
* @param {object} get The wrapper's export getters.
|
|
85
|
+
* @param {string} specifier The original import specifier.
|
|
86
|
+
*/
|
|
87
|
+
function registerLegacy (name, namespace, set, get, specifier) {
|
|
88
|
+
legacySetters ??= new WeakMap()
|
|
89
|
+
legacyGetters ??= new WeakMap()
|
|
90
|
+
legacyProxyHandler ??= {
|
|
91
|
+
defineProperty: defineLegacyExport,
|
|
92
|
+
get: getLegacyExport,
|
|
93
|
+
set: setLegacyExport
|
|
94
|
+
}
|
|
95
|
+
specifiers.set(name, specifier)
|
|
96
|
+
legacySetters.set(namespace, set)
|
|
97
|
+
legacyGetters.set(namespace, get)
|
|
98
|
+
const proxy = new Proxy(namespace, legacyProxyHandler)
|
|
99
|
+
importHooks.forEach(hook => hook(name, proxy, specifier))
|
|
100
|
+
toHook.push([name, proxy, specifier])
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} name The wrapped module URL.
|
|
105
|
+
* @param {ModuleBinder | object} binder The wrapper's binding state or legacy namespace.
|
|
106
|
+
* @param {string | object} specifier The original import specifier or legacy setters.
|
|
107
|
+
* @param {object} [get] The legacy export getters.
|
|
108
|
+
* @param {string} [legacySpecifier] The legacy original import specifier.
|
|
109
|
+
*/
|
|
110
|
+
function register (name, binder, specifier, get, legacySpecifier) {
|
|
111
|
+
if (arguments.length === 5) {
|
|
112
|
+
registerLegacy(name, binder, specifier, get, legacySpecifier)
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { namespace } = binder
|
|
117
|
+
specifiers.set(name, specifier)
|
|
118
|
+
binders.set(namespace, binder)
|
|
119
|
+
const proxy = new Proxy(namespace, proxyHandler)
|
|
120
|
+
importHooks.forEach(hook => hook(name, proxy, specifier))
|
|
121
|
+
toHook.push([name, proxy, specifier])
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Delays (ms) for re-reading exports that were still in their temporal dead zone
|
|
125
|
+
// when the wrapper first ran (circular imports). Retried on a microtask first,
|
|
126
|
+
// then at these intervals; unref'd so best-effort retries never hold the process
|
|
127
|
+
// open. Frozen once at module load rather than rebuilt per wrapper.
|
|
128
|
+
const RETRY_DELAYS = [0, 10, 50]
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Per-wrapped-module state a generated wrapper builds once to expose its exports
|
|
132
|
+
* through iitm's proxy. Each wrapper supplies one indexed writer for all local
|
|
133
|
+
* bindings; the constructor seeds them from the real module, and `flush`
|
|
134
|
+
* resolves any export that was undefined (circular import) once it becomes available.
|
|
135
|
+
*
|
|
136
|
+
* This is the boilerplate the wrapper used to inline in full per module. Hoisting
|
|
137
|
+
* it here compiles the retry and proxy bookkeeping once instead of once per
|
|
138
|
+
* wrapped module.
|
|
139
|
+
*/
|
|
140
|
+
class ModuleBinder {
|
|
141
|
+
// Mimics a Module namespace object (https://tc39.es/ecma262/#sec-module-namespace-objects).
|
|
142
|
+
namespace = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } })
|
|
143
|
+
#set = Object.create(null)
|
|
144
|
+
#write
|
|
145
|
+
#overridden
|
|
146
|
+
#pending
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {object} source The wrapped module namespace.
|
|
150
|
+
* @param {string[]} [keys] Export names in wrapper-binding order.
|
|
151
|
+
* @param {(index: number, value: unknown) => void} [write] Assigns a wrapper binding by index.
|
|
152
|
+
* @param {object[]} [sources] Alternate namespaces for star-collision bindings.
|
|
153
|
+
*/
|
|
154
|
+
constructor (source, keys, write, sources) {
|
|
155
|
+
this.#write = write
|
|
156
|
+
if (keys !== undefined) {
|
|
157
|
+
for (let index = 0; index < keys.length; index++) {
|
|
158
|
+
this.#bind(keys[index], index, sources?.[index] ?? source)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Seeds `key` from `source` and installs its proxy accessors. A value that is
|
|
165
|
+
* undefined or throws `ReferenceError` (temporal dead zone during a circular
|
|
166
|
+
* import) is deferred to `flush`; any other throw propagates.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} key The export name.
|
|
169
|
+
* @param {number} index The wrapper binding index.
|
|
170
|
+
* @param {object} source The binding's source namespace.
|
|
171
|
+
* @returns {void}
|
|
172
|
+
*/
|
|
173
|
+
#bind (key, index, source) {
|
|
174
|
+
let value
|
|
175
|
+
try {
|
|
176
|
+
value = readExport(source, key)
|
|
177
|
+
this.#write(index, value)
|
|
178
|
+
this.namespace[key] = value
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (!(error instanceof ReferenceError)) throw error
|
|
181
|
+
}
|
|
182
|
+
if (value === undefined) {
|
|
183
|
+
(this.#pending ??= []).push(this.#makeUpdater(key, index, source))
|
|
184
|
+
}
|
|
185
|
+
this.#set[key] = index
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {string | symbol} key The export name.
|
|
190
|
+
* @param {unknown} value The replacement value.
|
|
191
|
+
* @returns {boolean}
|
|
192
|
+
*/
|
|
193
|
+
write (key, value) {
|
|
194
|
+
const index = this.#set[key]
|
|
195
|
+
if (index !== undefined) {
|
|
196
|
+
this.#write(index, value)
|
|
197
|
+
if (this.#pending !== undefined) {
|
|
198
|
+
this.#overridden ??= Object.create(null)
|
|
199
|
+
this.#overridden[key] = true
|
|
200
|
+
}
|
|
201
|
+
this.namespace[key] = value
|
|
202
|
+
}
|
|
203
|
+
return true
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @param {string} key The export name to update.
|
|
208
|
+
* @param {number} index The wrapper binding index.
|
|
209
|
+
* @param {object} source The real module namespace.
|
|
210
|
+
* @returns {() => boolean} Updater returning whether the value is now settled.
|
|
211
|
+
*/
|
|
212
|
+
#makeUpdater (key, index, source) {
|
|
213
|
+
return () => {
|
|
214
|
+
if (this.#overridden?.[key] === true) return true
|
|
215
|
+
try {
|
|
216
|
+
const value = readExport(source, key)
|
|
217
|
+
if (value !== undefined) {
|
|
218
|
+
this.#write(index, value)
|
|
219
|
+
this.namespace[key] = value
|
|
220
|
+
return true
|
|
221
|
+
}
|
|
222
|
+
return false
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (error instanceof ReferenceError) return false
|
|
225
|
+
// Only reached if a getter starts throwing a non-ReferenceError after the
|
|
226
|
+
// initial bind read already succeeded or deferred; surfaces in flush's
|
|
227
|
+
// microtask. Kept as-is from the inline wrapper.
|
|
228
|
+
/* c8 ignore next */
|
|
229
|
+
throw error
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#flushOnce () {
|
|
235
|
+
const pending = this.#pending
|
|
236
|
+
if (pending === undefined) return
|
|
237
|
+
|
|
238
|
+
let next
|
|
239
|
+
for (const updater of pending) {
|
|
240
|
+
// If it still throws ReferenceError, keep it for the (single) next attempt.
|
|
241
|
+
if (updater() !== true) (next ??= []).push(updater)
|
|
242
|
+
}
|
|
243
|
+
this.#pending = next
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Resolves exports deferred by `bind` (undefined or TDZ at wrapper-eval time).
|
|
248
|
+
* Retries on a microtask, then at `RETRY_DELAYS`, giving up afterwards to avoid
|
|
249
|
+
* unbounded retries. A no-op when nothing was deferred.
|
|
250
|
+
*
|
|
251
|
+
* @returns {void}
|
|
252
|
+
*/
|
|
253
|
+
flush () {
|
|
254
|
+
if (this.#pending === undefined) return
|
|
255
|
+
queueMicrotask(() => {
|
|
256
|
+
this.#flushOnce()
|
|
257
|
+
this.#scheduleRetry(0)
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @param {number} attempt Index into `RETRY_DELAYS` for the next retry.
|
|
263
|
+
* @returns {void}
|
|
264
|
+
*/
|
|
265
|
+
#scheduleRetry (attempt) {
|
|
266
|
+
if (this.#pending === undefined) return
|
|
267
|
+
if (attempt >= RETRY_DELAYS.length) {
|
|
268
|
+
// Give up: leave exports as-is to avoid unbounded retries.
|
|
269
|
+
this.#pending = undefined
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
const timer = setTimeout(() => {
|
|
273
|
+
this.#flushOnce()
|
|
274
|
+
this.#scheduleRetry(attempt + 1)
|
|
275
|
+
}, RETRY_DELAYS[attempt])
|
|
276
|
+
// Don't keep the process alive just for best-effort retries.
|
|
277
|
+
if (timer && typeof timer.unref === 'function') timer.unref()
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
exports.register = register
|
|
282
|
+
exports.ModuleBinder = ModuleBinder
|
|
283
|
+
exports.importHooks = importHooks
|
|
284
|
+
exports.specifiers = specifiers
|
|
285
|
+
exports.toHook = toHook
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "import-in-the-middle",
|
|
3
|
+
"version": "3.5.2",
|
|
4
|
+
"description": "Intercept imports in Node.js",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=18"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "c8 --reporter lcov --check-coverage --lines 45 imhotap --files test/{hook,low-level,other,get-esm-exports,register}/*",
|
|
11
|
+
"test:e2e": "node test/check-exports/test.mjs && node test/integration-tests/turbopack-dev.mjs && node test/integration-tests/turbopack-build-start.mjs",
|
|
12
|
+
"test:ts": "c8 --reporter lcov imhotap --files test/typescript/*.test.mts",
|
|
13
|
+
"coverage": "c8 --reporter html imhotap --files test/{hook,low-level,other,get-esm-exports,register}/* && echo \"\nNow open coverage/index.html\n\"",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"lint:fix": "eslint . --fix"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+ssh://git@github.com/nodejs/import-in-the-middle.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"import",
|
|
23
|
+
"ritm",
|
|
24
|
+
"iitm",
|
|
25
|
+
"loader",
|
|
26
|
+
"hook",
|
|
27
|
+
"hooks"
|
|
28
|
+
],
|
|
29
|
+
"author": "Bryan English <bryan.english@datadoghq.com>",
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/nodejs/import-in-the-middle/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/nodejs/import-in-the-middle#readme",
|
|
35
|
+
"imhotap": {
|
|
36
|
+
"runner": "node",
|
|
37
|
+
"test-env": "NODE_OPTIONS=--no-warnings --require ./test/version-check.js --experimental-loader ./test/generic-loader.mjs"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.28.5",
|
|
41
|
+
"@babel/eslint-parser": "^7.28.5",
|
|
42
|
+
"@babel/plugin-syntax-import-assertions": "^7.27.1",
|
|
43
|
+
"@node-rs/crc32": "^1.10.6",
|
|
44
|
+
"@react-email/components": "^0.0.19",
|
|
45
|
+
"@types/node": "^18.0.6",
|
|
46
|
+
"c8": "^7.14.0",
|
|
47
|
+
"date-fns": "^3.6.0",
|
|
48
|
+
"eslint": "^8.57.1",
|
|
49
|
+
"eslint-config-standard": "^17.1.0",
|
|
50
|
+
"eslint-plugin-import": "^2.32.0",
|
|
51
|
+
"eslint-plugin-n": "^16.6.2",
|
|
52
|
+
"eslint-plugin-node": "^11.1.0",
|
|
53
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
54
|
+
"got": "^14.6.6",
|
|
55
|
+
"imhotap": "^2.2.0",
|
|
56
|
+
"openai": "4.47.2",
|
|
57
|
+
"ts-node": "^10.9.2",
|
|
58
|
+
"typescript": "^4.9.5",
|
|
59
|
+
"vue": "^3.5.26"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"cjs-module-lexer": "^2.2.0",
|
|
63
|
+
"es-module-lexer": "^3.0.2",
|
|
64
|
+
"module-details-from-path": "^1.0.4"
|
|
65
|
+
}
|
|
66
|
+
}
|