@opentui/solid 0.3.4 → 0.4.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/components.js +106 -4
- package/components.js.map +10 -0
- package/index.bun.js +1609 -0
- package/index.bun.js.map +22 -0
- package/index.d.ts +1 -1
- package/index.js +146 -72
- package/index.js.map +22 -0
- package/jsx-dev-runtime.d.ts +1 -0
- package/jsx-dev-runtime.js +2 -0
- package/jsx-dev-runtime.js.map +1 -0
- package/jsx-runtime.d.ts +9 -6
- package/jsx-runtime.js +31 -0
- package/jsx-runtime.js.map +1 -0
- package/package.json +27 -9
- package/scripts/preload.js +3 -0
- package/scripts/preload.js.map +1 -0
- package/scripts/preload.node.js +9 -0
- package/scripts/runtime-plugin-support-configure.js +67 -0
- package/scripts/runtime-plugin-support-configure.js.map +1 -0
- package/scripts/runtime-plugin-support-configure.node.js +11 -0
- package/scripts/runtime-plugin-support.js +4 -0
- package/scripts/runtime-plugin-support.js.map +1 -0
- package/scripts/runtime-plugin-support.node.js +11 -0
- package/scripts/solid-plugin.d.ts +1 -1
- package/scripts/solid-plugin.js +76 -0
- package/scripts/solid-plugin.js.map +1 -0
- package/scripts/solid-plugin.node.js +21 -0
- package/scripts/solid-transform.d.ts +10 -0
- package/scripts/solid-transform.js +66 -0
- package/scripts/solid-transform.js.map +1 -0
- package/src/elements/extras.d.ts +2 -2
- package/src/testing/bun-test-node.d.ts +12 -0
- package/src/types/elements.d.ts +1 -1
- package/chunk-7fkmdv3h.js +0 -110
- package/dist/chunk-7fkmdv3h.d.ts +0 -81
- package/dist/index.d.ts +0 -118
- package/scripts/preload.ts +0 -3
- package/scripts/runtime-plugin-support-configure.ts +0 -109
- package/scripts/runtime-plugin-support.ts +0 -6
- package/scripts/solid-plugin.ts +0 -148
package/scripts/solid-plugin.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { transformAsync } from "@babel/core"
|
|
2
|
-
// @ts-expect-error - Types not important.
|
|
3
|
-
import ts from "@babel/preset-typescript"
|
|
4
|
-
// @ts-expect-error - Types not important.
|
|
5
|
-
import moduleResolver from "babel-plugin-module-resolver"
|
|
6
|
-
// @ts-expect-error - Types not important.
|
|
7
|
-
import solid from "babel-preset-solid"
|
|
8
|
-
import { plugin as registerBunPlugin, type BunPlugin } from "bun"
|
|
9
|
-
|
|
10
|
-
export type ResolveImportPath = (specifier: string) => string | null
|
|
11
|
-
|
|
12
|
-
const solidTransformStateKey = Symbol.for("opentui.solid.transform")
|
|
13
|
-
|
|
14
|
-
type SolidTransformRuntime = {
|
|
15
|
-
moduleName?: string
|
|
16
|
-
resolvePath?: ResolveImportPath
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type SolidTransformState = {
|
|
20
|
-
installed: boolean
|
|
21
|
-
runtime?: SolidTransformRuntime
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type GlobalSolidTransformState = typeof globalThis & {
|
|
25
|
-
[solidTransformStateKey]?: SolidTransformState
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface CreateSolidTransformPluginOptions {
|
|
29
|
-
moduleName?: string
|
|
30
|
-
resolvePath?: ResolveImportPath
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const getSolidTransformState = (): SolidTransformState => {
|
|
34
|
-
const state = globalThis as GlobalSolidTransformState
|
|
35
|
-
state[solidTransformStateKey] ??= { installed: false }
|
|
36
|
-
return state[solidTransformStateKey]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const getSolidTransformRuntime = (): SolidTransformRuntime => {
|
|
40
|
-
return getSolidTransformState().runtime ?? {}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const sourcePath = (path: string): string => {
|
|
44
|
-
const searchIndex = path.indexOf("?")
|
|
45
|
-
const hashIndex = path.indexOf("#")
|
|
46
|
-
const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0]
|
|
47
|
-
return end === undefined ? path : path.slice(0, end)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const hasSolidTransformRuntime = (input: CreateSolidTransformPluginOptions): boolean => {
|
|
51
|
-
return input.moduleName !== undefined || input.resolvePath !== undefined
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function ensureSolidTransformPlugin(input: CreateSolidTransformPluginOptions = {}): boolean {
|
|
55
|
-
const state = getSolidTransformState()
|
|
56
|
-
|
|
57
|
-
if (hasSolidTransformRuntime(input)) {
|
|
58
|
-
state.runtime = {
|
|
59
|
-
moduleName: input.moduleName,
|
|
60
|
-
resolvePath: input.resolvePath,
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (state.installed) {
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
registerBunPlugin(createSolidTransformPlugin())
|
|
69
|
-
state.installed = true
|
|
70
|
-
return true
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function resetSolidTransformPluginState(): void {
|
|
74
|
-
const state = getSolidTransformState()
|
|
75
|
-
state.installed = false
|
|
76
|
-
delete state.runtime
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function createSolidTransformPlugin(input: CreateSolidTransformPluginOptions = {}): BunPlugin {
|
|
80
|
-
return {
|
|
81
|
-
name: "bun-plugin-solid",
|
|
82
|
-
setup: (build) => {
|
|
83
|
-
build.onLoad({ filter: /[/\\]node_modules[/\\]solid-js[/\\]dist[/\\]server\.js(?:[?#].*)?$/ }, async (args) => {
|
|
84
|
-
const path = sourcePath(args.path).replace("server.js", "solid.js")
|
|
85
|
-
const file = Bun.file(path)
|
|
86
|
-
const code = await file.text()
|
|
87
|
-
return { contents: code, loader: "js" }
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
build.onLoad(
|
|
91
|
-
{ filter: /[/\\]node_modules[/\\]solid-js[/\\]store[/\\]dist[/\\]server\.js(?:[?#].*)?$/ },
|
|
92
|
-
async (args) => {
|
|
93
|
-
const path = sourcePath(args.path).replace("server.js", "store.js")
|
|
94
|
-
const file = Bun.file(path)
|
|
95
|
-
const code = await file.text()
|
|
96
|
-
return { contents: code, loader: "js" }
|
|
97
|
-
},
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
build.onLoad({ filter: /\.(js|ts)x(?:[?#].*)?$/ }, async (args) => {
|
|
101
|
-
const path = sourcePath(args.path)
|
|
102
|
-
const file = Bun.file(path)
|
|
103
|
-
const code = await file.text()
|
|
104
|
-
const runtime = getSolidTransformRuntime()
|
|
105
|
-
const moduleName = input.moduleName ?? runtime.moduleName ?? "@opentui/solid"
|
|
106
|
-
const resolvePath = input.resolvePath ?? runtime.resolvePath
|
|
107
|
-
const plugins = resolvePath
|
|
108
|
-
? [
|
|
109
|
-
[
|
|
110
|
-
moduleResolver,
|
|
111
|
-
{
|
|
112
|
-
resolvePath(specifier: string) {
|
|
113
|
-
return resolvePath(specifier) ?? specifier
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
]
|
|
118
|
-
: []
|
|
119
|
-
|
|
120
|
-
const transforms = await transformAsync(code, {
|
|
121
|
-
filename: path,
|
|
122
|
-
configFile: false,
|
|
123
|
-
babelrc: false,
|
|
124
|
-
plugins,
|
|
125
|
-
presets: [
|
|
126
|
-
[
|
|
127
|
-
solid,
|
|
128
|
-
{
|
|
129
|
-
moduleName,
|
|
130
|
-
generate: "universal",
|
|
131
|
-
},
|
|
132
|
-
],
|
|
133
|
-
[ts],
|
|
134
|
-
],
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
contents: transforms?.code ?? "",
|
|
139
|
-
loader: "js",
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const solidTransformPlugin = createSolidTransformPlugin()
|
|
147
|
-
|
|
148
|
-
export default solidTransformPlugin
|