@rimelight/ui 0.0.17 → 0.0.19
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
CHANGED
|
@@ -39,26 +39,28 @@ export const security = defineMiddleware(async (context, next) => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (typeof HTMLRewriter !== "undefined") {
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
return addSecurityHeaders(
|
|
43
|
+
new HTMLRewriter()
|
|
44
|
+
.on("script[src]", {
|
|
45
|
+
element(el: any) {
|
|
46
|
+
const src = el.getAttribute("src")
|
|
47
|
+
if (src && manifest[src]) {
|
|
48
|
+
el.setAttribute("integrity", manifest[src])
|
|
49
|
+
el.setAttribute("crossorigin", "anonymous")
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
})
|
|
53
|
+
.on('link[rel="stylesheet"][href]', {
|
|
54
|
+
element(el: any) {
|
|
55
|
+
const href = el.getAttribute("href")
|
|
56
|
+
if (href && manifest[href]) {
|
|
57
|
+
el.setAttribute("integrity", manifest[href])
|
|
58
|
+
el.setAttribute("crossorigin", "anonymous")
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
})
|
|
62
|
+
.transform(response)
|
|
63
|
+
)
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
let modifiedHtml = await response.text()
|
|
@@ -3,37 +3,71 @@ import { Tabs, TabItem } from "@astrojs/starlight/components"
|
|
|
3
3
|
import { Code } from "astro:components"
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
|
-
pkg
|
|
7
|
-
type?: "add" | "create" | "install" | "remove" | "run"
|
|
6
|
+
pkg?: string
|
|
7
|
+
type?: "add" | "create" | "dlx" | "exec" | "install" | "remove" | "run"
|
|
8
8
|
dev?: boolean
|
|
9
|
+
args?: string
|
|
10
|
+
comment?: string
|
|
11
|
+
prefix?: string
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
pkg,
|
|
16
|
+
type = "add",
|
|
17
|
+
dev = false,
|
|
18
|
+
args,
|
|
19
|
+
comment,
|
|
20
|
+
prefix,
|
|
21
|
+
} = Astro.props
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
type Manager = "npm" | "yarn" | "pnpm" | "bun"
|
|
24
|
+
type CommandType = NonNullable<Props["type"]>
|
|
25
|
+
|
|
26
|
+
const commands: Record<Manager, Partial<Record<CommandType, string>> & { dev: string }> = {
|
|
27
|
+
npm: { add: "npm i", create: "npm create", dlx: "npx", exec: "npx", install: "npm install", run: "npm run", remove: "npm uninstall", dev: "-D" },
|
|
28
|
+
yarn: { add: "yarn add", create: "yarn create", dlx: "yarn dlx", exec: "yarn", install: "yarn install", run: "yarn run", remove: "yarn remove", dev: "-D" },
|
|
29
|
+
pnpm: { add: "pnpm add", create: "pnpm create", dlx: "pnpx", exec: "pnpm", install: "pnpm install", run: "pnpm run", remove: "pnpm remove", dev: "-D" },
|
|
30
|
+
bun: { add: "bun add", create: "bun create", install: "bun install", run: "bun run", remove: "bun remove", dev: "-d" },
|
|
18
31
|
}
|
|
19
32
|
|
|
20
|
-
const managers = ["npm", "pnpm", "yarn", "bun"]
|
|
33
|
+
const managers: Manager[] = ["npm", "pnpm", "yarn", "bun"]
|
|
34
|
+
|
|
35
|
+
function getCommand(mgr: Manager, cmdType: CommandType): string | undefined {
|
|
36
|
+
let cmd = commands[mgr][cmdType]
|
|
37
|
+
if (cmd === undefined) return undefined
|
|
38
|
+
|
|
39
|
+
if (prefix) cmd = `${prefix} ${cmd}`
|
|
40
|
+
if (comment) cmd = `# ${comment.replaceAll("{PKG}", mgr)}\n${cmd}`
|
|
41
|
+
if (dev && cmdType === "add") cmd += ` ${commands[mgr].dev}`
|
|
42
|
+
|
|
43
|
+
if (pkg) {
|
|
44
|
+
// Logic to strip version tags for yarn create
|
|
45
|
+
const processedPkg = (cmdType === "create" && mgr === "yarn")
|
|
46
|
+
? pkg.replace(/@(?![^@]*\/)[^\s]*$/, "")
|
|
47
|
+
: pkg
|
|
48
|
+
cmd += ` ${processedPkg}`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (args) {
|
|
52
|
+
const needsDoubleDash = mgr === "npm" && !["dlx", "exec", "run"].includes(cmdType)
|
|
53
|
+
cmd += `${needsDoubleDash ? " --" : ""} ${args}`
|
|
54
|
+
}
|
|
21
55
|
|
|
22
|
-
function getCommand(manager: string, cmdType: string, pkgName: string, devFlag: boolean): string {
|
|
23
|
-
const mgrCmds = commands[manager]
|
|
24
|
-
if (!mgrCmds) return ""
|
|
25
|
-
let cmd = mgrCmds[cmdType]
|
|
26
|
-
if (!cmd) return ""
|
|
27
|
-
if (cmdType === "add" && devFlag && mgrCmds.devOption) cmd += " " + mgrCmds.devOption
|
|
28
|
-
if (pkgName && cmdType !== "install") cmd += " " + pkgName
|
|
29
56
|
return cmd
|
|
30
57
|
}
|
|
58
|
+
|
|
59
|
+
const tabs = managers
|
|
60
|
+
.map((mgr) => ({
|
|
61
|
+
mgr,
|
|
62
|
+
cmd: getCommand(mgr, type),
|
|
63
|
+
}))
|
|
64
|
+
.filter((tab) => tab.cmd !== undefined)
|
|
31
65
|
---
|
|
32
66
|
|
|
33
67
|
<Tabs syncKey="package-managers">
|
|
34
|
-
{
|
|
35
|
-
<TabItem label={
|
|
36
|
-
<Code code={
|
|
68
|
+
{tabs.map((tab) => (
|
|
69
|
+
<TabItem label={tab.mgr}>
|
|
70
|
+
<Code code={tab.cmd!} lang="sh" />
|
|
37
71
|
</TabItem>
|
|
38
72
|
))}
|
|
39
73
|
</Tabs>
|
|
@@ -26,7 +26,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
26
26
|
export interface StarlightAddonsConfig {
|
|
27
27
|
copy?: boolean
|
|
28
28
|
share?: boolean
|
|
29
|
-
packageManagers?: string[]
|
|
30
29
|
// Merged config for Topics
|
|
31
30
|
topics?: StarlightSidebarTopicsUserConfig
|
|
32
31
|
topicOptions?: StarlightSidebarTopicsUserOptions
|
|
@@ -36,8 +35,7 @@ export default function starlightAddons(userConfig?: StarlightAddonsConfig): Sta
|
|
|
36
35
|
// 1. Setup default and merged config for Addons
|
|
37
36
|
const defaultAddonConfig: StarlightAddonsConfig = {
|
|
38
37
|
copy: true,
|
|
39
|
-
share: true
|
|
40
|
-
packageManagers: ["npm"]
|
|
38
|
+
share: true
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
const addonConfig = { ...defaultAddonConfig, ...userConfig }
|
|
@@ -92,11 +90,7 @@ export default function starlightAddons(userConfig?: StarlightAddonsConfig): Sta
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
// --- Addons Logic ---
|
|
95
|
-
if (
|
|
96
|
-
!addonConfig.copy &&
|
|
97
|
-
!addonConfig.share &&
|
|
98
|
-
(!addonConfig.packageManagers || addonConfig.packageManagers.length === 0)
|
|
99
|
-
) {
|
|
93
|
+
if (!addonConfig.copy && !addonConfig.share) {
|
|
100
94
|
logger.warn("StarlightAddons: No features enabled.")
|
|
101
95
|
}
|
|
102
96
|
|