t0n 0.1.15 → 0.1.16
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/package.json +1 -1
- package/src/color.ts +2 -0
- package/src/import.ts +18 -2
package/package.json
CHANGED
package/src/color.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
//
|
|
17
17
|
// https://github.com/alexeyraspopov/picocolors/commit/6f0a4638348ed20633d623ee973f9c9a96f65104
|
|
18
18
|
|
|
19
|
+
// TODO: https://github.com/delucis/piccolore/tree/main/src
|
|
20
|
+
|
|
19
21
|
import { getColorEnabledAsync } from 'hono/utils/color'
|
|
20
22
|
|
|
21
23
|
export const enabled = await getColorEnabledAsync()
|
package/src/import.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
export async function IMPORT(path: string)
|
|
1
|
+
export async function IMPORT(path: string, name: string): Promise<unknown>
|
|
2
|
+
export async function IMPORT(path: string, ...name: string[]): Promise<Record<string, unknown>> {
|
|
2
3
|
if (process.platform === 'win32' && !path.startsWith('file://'))
|
|
3
4
|
path = 'file://' + path
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const source = path +'?v='+ Date.now()
|
|
7
|
+
|
|
8
|
+
if (name.length > 0) {
|
|
9
|
+
const module = await import(source)
|
|
10
|
+
const result: Record<string, any> = {}
|
|
11
|
+
for (const n of name) {
|
|
12
|
+
if (n in module)
|
|
13
|
+
result[n] = module[n]
|
|
14
|
+
else
|
|
15
|
+
throw new Error(`Module ${path} does not export ${n}`)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return name.length === 1 ? result[name[0]] : result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return import(source)
|
|
6
22
|
}
|