@melt-js/libs-core 2026.11.15 → 2026.11.16-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.
Files changed (103) hide show
  1. package/README.md +45 -4
  2. package/dist/browser.d.mts +3 -0
  3. package/dist/browser.mjs +1 -50
  4. package/dist/browser.mjs.gz +0 -0
  5. package/dist/cdn/browser.umd.cjs +2 -0
  6. package/dist/cdn/browser.umd.cjs.gz +0 -0
  7. package/dist/cdn/demo-browser.umd.cjs +2 -0
  8. package/dist/cdn/demo-browser.umd.cjs.gz +0 -0
  9. package/dist/cdn/demo.umd.cjs +2 -0
  10. package/dist/cdn/demo.umd.cjs.gz +0 -0
  11. package/dist/cdn/example-esm.html +1 -0
  12. package/dist/cdn/example-umd.html +1 -0
  13. package/dist/cdn/index.umd.cjs +2 -0
  14. package/dist/cdn/index.umd.cjs.gz +0 -0
  15. package/dist/cdn/manifest.json +129 -0
  16. package/dist/cdn/vendor.umd.cjs +50 -0
  17. package/dist/cdn/vendor.umd.cjs.gz +0 -0
  18. package/dist/cdn.d.mts +3 -0
  19. package/dist/cdn.mjs +1 -0
  20. package/dist/demo/browser.mjs +1 -0
  21. package/dist/demo/browser.mjs.gz +0 -0
  22. package/dist/demo/clipboard.d.mts +6 -0
  23. package/dist/demo/clipboard.mjs +1 -0
  24. package/{src → dist}/demo/docs.d.mts +28 -25
  25. package/dist/demo/docs.mjs +1 -0
  26. package/dist/demo/docs.mjs.gz +0 -0
  27. package/{src → dist}/demo/download.d.mts +7 -2
  28. package/dist/demo/download.mjs +1 -0
  29. package/dist/demo/download.mjs.gz +0 -0
  30. package/{src → dist}/demo/fullscreen.d.mts +8 -8
  31. package/dist/demo/fullscreen.mjs +1 -0
  32. package/dist/demo/index.d.mts +9 -0
  33. package/dist/demo/index.mjs +1 -0
  34. package/{src → dist}/demo/model.d.mts +12 -12
  35. package/dist/demo/model.mjs +1 -0
  36. package/dist/demo/remote-debug.d.mts +11 -0
  37. package/dist/demo/remote-debug.mjs +1 -0
  38. package/{src → dist}/demo/runtime.mjs +92 -104
  39. package/dist/demo/split-pane.d.mts +8 -0
  40. package/dist/demo/split-pane.mjs +1 -0
  41. package/dist/demo/standalone.d.mts +9 -0
  42. package/dist/demo/standalone.mjs +1 -0
  43. package/dist/demo/tabs.d.mts +15 -0
  44. package/dist/demo/tabs.mjs +1 -0
  45. package/{src/index.ts → dist/index.d.ts} +1 -1
  46. package/dist/loading.mjs +1 -0
  47. package/dist/remote-address.cjs +2 -0
  48. package/{src → dist}/remote.d.mts +110 -96
  49. package/dist/remote.mjs +1 -0
  50. package/dist/remote.mjs.gz +0 -0
  51. package/dist/vendor/hel-runtime.mjs +50 -0
  52. package/dist/vendor/hel-runtime.mjs.gz +0 -0
  53. package/package.json +41 -25
  54. package/scripts/browser-formats.mjs +355 -0
  55. package/scripts/build-browser.mjs +59 -13
  56. package/scripts/build-protected-esm.mjs +51 -0
  57. package/scripts/cdn-runtime.cjs +30 -0
  58. package/scripts/check-tdz.mjs +327 -324
  59. package/scripts/client-build-security.cjs +48 -0
  60. package/scripts/component-events.mjs +57 -57
  61. package/scripts/comps-bundle-obfuscation.cjs +266 -262
  62. package/scripts/hel-build-paths.cjs +49 -48
  63. package/scripts/package-artifacts.mjs +206 -0
  64. package/scripts/package-env.cjs +200 -193
  65. package/scripts/publish-stage.mjs +50 -42
  66. package/{src → scripts}/remote-address.cjs +30 -30
  67. package/scripts/vdoc-parser/NOTICE.md +13 -13
  68. package/scripts/vdoc-parser/constants.mjs +3 -3
  69. package/scripts/vdoc-parser/index.d.mts +34 -34
  70. package/scripts/vdoc-parser/index.mjs +2 -2
  71. package/scripts/vdoc-parser/parsers/index.mjs +14 -14
  72. package/scripts/vdoc-parser/parsers/parseCode.mjs +42 -42
  73. package/scripts/vdoc-parser/parsers/parseCommentBlock.mjs +9 -9
  74. package/scripts/vdoc-parser/parsers/parseComponentOptions.mjs +12 -12
  75. package/scripts/vdoc-parser/parsers/parseDefaultValue.mjs +57 -57
  76. package/scripts/vdoc-parser/parsers/parseDefineProps.mjs +33 -33
  77. package/scripts/vdoc-parser/parsers/parseExport.mjs +93 -93
  78. package/scripts/vdoc-parser/parsers/parseFile.mjs +22 -22
  79. package/scripts/vdoc-parser/parsers/parseFileSync.mjs +22 -22
  80. package/scripts/vdoc-parser/parsers/parsePropType.mjs +32 -32
  81. package/scripts/vdoc-parser/parsers/parseProps.mjs +90 -90
  82. package/scripts/vdoc-parser/parsers/parseSetupScript.mjs +14 -14
  83. package/scripts/vdoc-parser/parsers/parseSfc.mjs +21 -21
  84. package/scripts/vdoc-parser/parsers/parseTSTypeLiteral.mjs +48 -48
  85. package/scripts/vdoc-parser/parsers/parseTypes.mjs +53 -53
  86. package/scripts/vdoc-parser/parsers/parseTypesFile.mjs +22 -22
  87. package/scripts/vdoc-parser/parsers/parseTypesFileSync.mjs +22 -22
  88. package/scripts/vdoc-parser/resolvers/index.mjs +2 -2
  89. package/scripts/vdoc-parser/resolvers/resolveSpreadElements.mjs +51 -51
  90. package/scripts/vdoc-parser/utils.mjs +52 -52
  91. package/scripts/webpack-bundle-obfuscation.cjs +123 -121
  92. package/demo/index.js +0 -1
  93. package/dist/hel-deployment.json +0 -8
  94. package/src/browser.d.mts +0 -2
  95. package/src/browser.mjs +0 -3
  96. package/src/demo/docs.mjs +0 -75
  97. package/src/demo/download.mjs +0 -118
  98. package/src/demo/fullscreen.mjs +0 -80
  99. package/src/demo/index.d.mts +0 -4
  100. package/src/demo/index.mjs +0 -4
  101. package/src/demo/model.mjs +0 -203
  102. package/src/remote.mjs +0 -286
  103. package/tsconfig.json +0 -13
@@ -1,193 +1,200 @@
1
- const fs = require('node:fs')
2
- const path = require('node:path')
3
- const { createRequire } = require('node:module')
4
- const dotenv = require('dotenv')
5
- const { expand } = require('dotenv-expand')
6
- const { packageRef, packageUrl } = require('../src/remote-address.cjs')
7
-
8
- const PUBLIC_ENV_KEYS = ['SFTP_PUBLIC_URL', 'GITHUB_PUBLIC_URL', 'UNPKG_PUBLIC_URL']
9
- const WORKSPACE_ENV_KEYS = [...PUBLIC_ENV_KEYS, 'HEL_RELATIVE_PATH']
10
- const TARGETS = ['local', 'sftp', 'github', 'unpkg']
11
- const trim = value => String(value || '').trim().replace(/\/+$/, '')
12
-
13
- function readEnvFile(file) {
14
- return fs.existsSync(file) ? dotenv.parse(fs.readFileSync(file)) : {}
15
- }
16
-
17
- function readPackageFiles(cwd, mode) {
18
- // The root orchestrator copies only public bases here. Never read a parent directory.
19
- return Object.assign({}, ...[
20
- '.env.defaults', '.env.workspace.local', '.env', '.env.local', `.env.${mode}`, `.env.${mode}.local`,
21
- ].map(name => readEnvFile(path.join(cwd, name))))
22
- }
23
-
24
- function remoteSlots(env) {
25
- return Object.keys(env).filter(key => /^[A-Z][A-Z\d_]*_PACKAGE$/.test(key) && !/^(?:DEPLOY_|VITE_|VUE_APP_|REACT_APP_|HEL_)/.test(key))
26
- .map(key => key.slice(0, -8))
27
- }
28
-
29
- function resolveTarget(value, mode) {
30
- const target = String(value || 'auto').toLowerCase()
31
- if (target === 'auto') return ['development', 'mock'].includes(mode) ? 'local' : 'unpkg'
32
- if (!TARGETS.includes(target)) throw new Error(`[hel-env] Unknown remote target: ${target}`)
33
- return target
34
- }
35
-
36
- // Resolve metadata from an installed dependency, never from a sibling/source checkout.
37
- function installedVersion(cwd, packageName) {
38
- const fromPackage = createRequire(path.join(cwd, 'package.json'))
39
- try {
40
- return JSON.parse(fs.readFileSync(fromPackage.resolve(packageName + '/package.json'), 'utf8')).version
41
- } catch (error) {
42
- if (!['ERR_PACKAGE_PATH_NOT_EXPORTED', 'MODULE_NOT_FOUND'].includes(error.code)) throw error
43
- }
44
- let directory = path.dirname(fromPackage.resolve(packageName))
45
- for (;;) {
46
- const manifest = path.join(directory, 'package.json')
47
- if (fs.existsSync(manifest)) {
48
- const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'))
49
- if (pkg.name === packageName) return pkg.version
50
- }
51
- const parent = path.dirname(directory)
52
- if (parent === directory) throw new Error(`[hel-env] Cannot resolve installed version of ${packageName}; set the dependency's VERSION explicitly`)
53
- directory = parent
54
- }
55
- }
56
-
57
- function resolveRemoteUrl(env, slot, target) {
58
- const packageName = env[`${slot}_PACKAGE`]
59
- if (target === 'local') {
60
- const url = trim(env[`${slot}_LOCAL_URL`])
61
- if (!url) throw new Error(`[hel-env] ${slot}_LOCAL_URL is required for local development`)
62
- return url
63
- }
64
- const base = trim(env[`${target.toUpperCase()}_PUBLIC_URL`])
65
- let version = env[`DEPLOY_${slot}_VERSION`] || env[`${slot}_VERSION`] || 'latest'
66
- if (target === 'unpkg' && version === 'installed') version = installedVersion(env.HEL_ENV_PACKAGE || process.cwd(), packageName)
67
- const output = env[`${slot}_OUTPUT_DIR`] || 'hel_dist'
68
- const entry = env[`${slot}_ENTRY`] || 'hel-meta.json'
69
- try {
70
- const parsed = packageRef(packageName)
71
- parsed.version = version
72
- const url = packageUrl(parsed, {
73
- type: target === 'sftp' ? 'custom' : target, base,
74
- projectName: target === 'unpkg' ? undefined : env[`${slot}_PROJECT`],
75
- // Static deployments update project directories; unpkg versions are npm versions.
76
- versioned: target === 'unpkg',
77
- })
78
- url.pathname += '/' + output + '/' + entry
79
- return url.href
80
- } catch (error) { throw new Error(`[hel-env] ${slot}: ${error.message}`) }
81
- }
82
-
83
- function assertSameOrigin(url, base, slot) {
84
- if (new URL(url).origin !== new URL(base).origin) {
85
- throw new Error(`[hel-env] ${slot} must use the deployment origin ${new URL(base).origin}: ${url}`)
86
- }
87
- }
88
-
89
- // Keep the deployment directory while allowing the same static files on another origin.
90
- function resolveBuildHomePage(env, homePage = env.HEL_APP_HOME_PAGE) {
91
- if (env.HEL_RELATIVE_PATH !== '1') return homePage
92
- if (/^(?:https?:)?\/\//i.test(homePage || '')) return new URL(homePage, 'https://hel.invalid').pathname
93
- return homePage || '/'
94
- }
95
-
96
- function loadPackageEnv({ cwd = process.cwd(), mode = 'development', env = process.env, target, localBuild = false } = {}) {
97
- const inherited = { ...env }
98
- // Recompute our own defaults on reload, but preserve values changed by cross-env.
99
- const generated = JSON.parse(inherited.HEL_ENV_GENERATED || '{}')
100
- for (const [key, value] of Object.entries(generated)) {
101
- if (inherited[key] === value) delete inherited[key]
102
- }
103
- delete inherited.HEL_ENV_GENERATED
104
- delete inherited.HEL_ENV_DERIVED_KEYS
105
- delete inherited.HEL_ENV_PACKAGE
106
- const values = Object.assign({}, readPackageFiles(cwd, mode), inherited)
107
- values.HEL_ENV_PACKAGE = path.resolve(cwd)
108
- expand({ parsed: values, processEnv: { ...values } })
109
- values.UNPKG_PUBLIC_URL ||= 'https://unpkg.com'
110
- const derived = new Set()
111
- const put = (key, value) => {
112
- if (!value) return
113
- if (!values[key]) { values[key] = String(value); derived.add(key) }
114
- }
115
- const deployTarget = values.HEL_DEPLOY_TARGET
116
- const runtimeMode = values.NODE_ENV || mode
117
- const selected = resolveTarget(deployTarget || target || values.REMOTE_TARGET, runtimeMode)
118
- localBuild ||= values.HEL_LOCAL_BUILD === '1'
119
- const port = inherited.PORT || inherited.DEV_PORT || inherited.VITE_PORT || values.PORT || values.DEV_PORT
120
- const previewPort = values.PREVIEW_PORT || port
121
- if (port && (!/^\d+$/.test(String(port)) || +port < 1 || +port > 65535)) throw new Error('[hel-env] DEV_PORT must be between 1 and 65535')
122
- if (port) values.DEV_PORT = String(port)
123
- put('PORT', port)
124
- put('VITE_PORT', port)
125
- put('VUE_APP_PORT', port)
126
- put('REACT_APP_PORT', port)
127
- put('VITE_PREVIEW_PORT', previewPort)
128
- put('VUE_APP_PREVIEW_PORT', previewPort)
129
- put('VITE_DEV_ORIGIN', values.DEV_ORIGIN || (port ? `http://localhost:${port}` : ''))
130
- put('VUE_APP_DEV_ORIGIN', values.VITE_DEV_ORIGIN)
131
- for (const key of PUBLIC_ENV_KEYS) {
132
- // Only these public bases are exposed to browser code, never SFTP credentials.
133
- put(`VITE_${key}`, values[key])
134
- put(`VUE_APP_${key}`, values[key])
135
- }
136
- for (const slot of remoteSlots(values)) {
137
- const slotTarget = resolveTarget(deployTarget || target || values[`${slot}_TARGET`] || selected, runtimeMode)
138
- const keys = [`VITE_${slot}_HOST`, `VUE_APP_${slot}_HOST`, `REACT_APP_${slot}_HOST`, `HEL_${slot}_HOST`]
139
- const overrides = [...keys, `VUE_APP_${slot}_ENTRY`, `VITE_${slot}_ENTRY`, `${slot}_URL`]
140
- .map(key => values[key]).filter(Boolean)
141
- if (new Set(overrides).size > 1) throw new Error(`[hel-env] Conflicting ${slot} address overrides`)
142
- const explicit = overrides[0]
143
- const expected = !explicit || deployTarget
144
- ? localBuild && !deployTarget && values[`${slot}_BUNDLED_PATH`]
145
- ? './' + values[`${slot}_BUNDLED_PATH`]
146
- : resolveRemoteUrl(values, slot, slotTarget)
147
- : explicit
148
- const resolved = explicit || expected
149
- if (deployTarget) {
150
- assertSameOrigin(resolved, values[`${deployTarget.toUpperCase()}_PUBLIC_URL`] || expected, slot)
151
- if (resolved !== expected) throw new Error(`[hel-env] ${slot} must match the deployment package/version URL: ${expected}`)
152
- }
153
- for (const key of keys) put(key, resolved)
154
- if (values[`${slot}_ENTRY`] === 'index.html') {
155
- put(`VUE_APP_${slot}_ENTRY`, resolved)
156
- put(`VITE_${slot}_ENTRY`, resolved)
157
- }
158
- put(`VITE_${slot}_LOCAL_URL`, values[`${slot}_LOCAL_URL`])
159
- put(`VUE_APP_${slot}_LOCAL_URL`, values[`${slot}_LOCAL_URL`])
160
- }
161
- if (localBuild && values.VITE_DEV_ORIGIN) put('HEL_APP_HOME_PAGE', values.VITE_DEV_ORIGIN)
162
- if (runtimeMode === 'production' && !localBuild) {
163
- const homePage = resolveBuildHomePage(values)
164
- if (homePage) values.HEL_APP_HOME_PAGE = homePage
165
- }
166
- if (deployTarget) put('VUE_APP_PUBLISH_MODE', deployTarget)
167
- values.HEL_ENV_PACKAGE = path.resolve(cwd)
168
- const computed = Object.fromEntries(Object.entries(values).filter(([key, value]) =>
169
- !key.startsWith('HEL_ENV_') && inherited[key] !== value && !(key === 'HEL_APP_HOME_PAGE' && inherited[key])))
170
- values.HEL_ENV_DERIVED_KEYS = Object.keys(computed).join(',')
171
- values.HEL_ENV_GENERATED = JSON.stringify(computed)
172
- return values
173
- }
174
-
175
- function inferMode(env = process.env, argv = process.argv) {
176
- const modeIndex = argv.indexOf('--mode')
177
- const inline = argv.find(arg => arg.startsWith('--mode='))
178
- if (modeIndex >= 0 && argv[modeIndex + 1]) return argv[modeIndex + 1]
179
- if (inline) return inline.slice(7)
180
- if (env.HEL_ENV_MODE) return env.HEL_ENV_MODE
181
- if (env.NODE_ENV) return env.NODE_ENV
182
- return /^(?:build|preview|prepublish)/.test(env.npm_lifecycle_event || '') ? 'production' : 'development'
183
- }
184
-
185
- function applyPackageEnv({ cwd = process.cwd(), mode = inferMode() } = {}) {
186
- const values = loadPackageEnv({ cwd, mode })
187
- const preview = /^(?:preview|serve:dist)/.test(process.env.npm_lifecycle_event || '')
188
- if (preview && !process.env.PORT && values.PREVIEW_PORT) values.PORT = values.PREVIEW_PORT
189
- Object.assign(process.env, values)
190
- return values
191
- }
192
-
193
- module.exports = { applyPackageEnv, inferMode, PUBLIC_ENV_KEYS, WORKSPACE_ENV_KEYS, readEnvFile, readPackageFiles, remoteSlots, resolveTarget, resolveRemoteUrl, resolveBuildHomePage, loadPackageEnv }
1
+ const fs = require('node:fs')
2
+ const path = require('node:path')
3
+ const { createRequire } = require('node:module')
4
+ const dotenv = require('dotenv')
5
+ const { expand } = require('dotenv-expand')
6
+ const { packageRef, packageUrl } = require('./remote-address.cjs')
7
+
8
+ const PUBLIC_ENV_KEYS = ['SFTP_PUBLIC_URL', 'GITHUB_PUBLIC_URL', 'UNPKG_PUBLIC_URL']
9
+ const WORKSPACE_ENV_KEYS = [...PUBLIC_ENV_KEYS, 'HEL_RELATIVE_PATH']
10
+ const TARGETS = ['local', 'sftp', 'github', 'unpkg']
11
+ const trim = value => String(value || '').trim().replace(/\/+$/, '')
12
+
13
+ function readEnvFile(file) {
14
+ return fs.existsSync(file) ? dotenv.parse(fs.readFileSync(file)) : {}
15
+ }
16
+
17
+ function readPackageFiles(cwd, mode) {
18
+ // The root orchestrator copies only public bases here. Never read a parent directory.
19
+ return Object.assign({}, ...[
20
+ '.env.defaults', '.env.workspace.local', '.env', '.env.local', `.env.${mode}`, `.env.${mode}.local`,
21
+ ].map(name => readEnvFile(path.join(cwd, name))))
22
+ }
23
+
24
+ function remoteSlots(env) {
25
+ return Object.keys(env).filter(key => /^[A-Z][A-Z\d_]*_PACKAGE$/.test(key) && !/^(?:DEPLOY_|VITE_|VUE_APP_|REACT_APP_|HEL_)/.test(key))
26
+ .map(key => key.slice(0, -8))
27
+ }
28
+
29
+ function resolveTarget(value, mode) {
30
+ const target = String(value || 'auto').toLowerCase()
31
+ if (target === 'auto') return ['development', 'mock'].includes(mode) ? 'local' : 'unpkg'
32
+ if (!TARGETS.includes(target)) throw new Error(`[hel-env] Unknown remote target: ${target}`)
33
+ return target
34
+ }
35
+
36
+ // Resolve metadata from an installed dependency, never from a sibling/source checkout.
37
+ function installedVersion(cwd, packageName) {
38
+ const fromPackage = createRequire(path.join(cwd, 'package.json'))
39
+ try {
40
+ return JSON.parse(fs.readFileSync(fromPackage.resolve(packageName + '/package.json'), 'utf8')).version
41
+ } catch (error) {
42
+ if (!['ERR_PACKAGE_PATH_NOT_EXPORTED', 'MODULE_NOT_FOUND'].includes(error.code)) throw error
43
+ }
44
+ let directory = path.dirname(fromPackage.resolve(packageName))
45
+ for (;;) {
46
+ const manifest = path.join(directory, 'package.json')
47
+ if (fs.existsSync(manifest)) {
48
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'))
49
+ if (pkg.name === packageName) return pkg.version
50
+ }
51
+ const parent = path.dirname(directory)
52
+ if (parent === directory) throw new Error(`[hel-env] Cannot resolve installed version of ${packageName}; set the dependency's VERSION explicitly`)
53
+ directory = parent
54
+ }
55
+ }
56
+
57
+ function resolveRemoteUrl(env, slot, target) {
58
+ const packageName = env[`${slot}_PACKAGE`]
59
+ if (target === 'local') {
60
+ const url = trim(env[`${slot}_LOCAL_URL`])
61
+ if (!url) throw new Error(`[hel-env] ${slot}_LOCAL_URL is required for local development`)
62
+ return url
63
+ }
64
+ const base = trim(env[`${target.toUpperCase()}_PUBLIC_URL`])
65
+ let version = env[`DEPLOY_${slot}_VERSION`] || env[`${slot}_VERSION`] || 'latest'
66
+ if (target === 'unpkg' && version === 'installed') version = installedVersion(env.HEL_ENV_PACKAGE || process.cwd(), packageName)
67
+ const output = env[`${slot}_OUTPUT_DIR`] || 'hel_dist'
68
+ const entry = env[`${slot}_ENTRY`] || 'hel-meta.json'
69
+ try {
70
+ const parsed = packageRef(packageName)
71
+ parsed.version = version
72
+ const url = packageUrl(parsed, {
73
+ type: target === 'sftp' ? 'custom' : target, base,
74
+ projectName: target === 'unpkg' ? undefined : env[`${slot}_PROJECT`],
75
+ // Static deployments update project directories; unpkg versions are npm versions.
76
+ versioned: target === 'unpkg',
77
+ })
78
+ url.pathname += '/' + output + '/' + entry
79
+ return url.href
80
+ } catch (error) { throw new Error(`[hel-env] ${slot}: ${error.message}`) }
81
+ }
82
+
83
+ function assertSameOrigin(url, base, slot) {
84
+ if (new URL(url).origin !== new URL(base).origin) {
85
+ throw new Error(`[hel-env] ${slot} must use the deployment origin ${new URL(base).origin}: ${url}`)
86
+ }
87
+ }
88
+
89
+ // Keep the deployment directory while allowing the same static files on another origin.
90
+ function resolveBuildHomePage(env, homePage = env.HEL_APP_HOME_PAGE) {
91
+ if (env.HEL_RELATIVE_PATH !== '1') return homePage
92
+ if (/^(?:https?:)?\/\//i.test(homePage || '')) return new URL(homePage, 'https://hel.invalid').pathname
93
+ return homePage || '/'
94
+ }
95
+
96
+ function loadPackageEnv({ cwd = process.cwd(), mode = 'development', env = process.env, target, localBuild = false } = {}) {
97
+ const inherited = { ...env }
98
+ // Recompute our own defaults on reload, but preserve values changed by cross-env.
99
+ const generated = JSON.parse(inherited.HEL_ENV_GENERATED || '{}')
100
+ for (const [key, value] of Object.entries(generated)) {
101
+ if (inherited[key] === value) delete inherited[key]
102
+ }
103
+ delete inherited.HEL_ENV_GENERATED
104
+ delete inherited.HEL_ENV_DERIVED_KEYS
105
+ delete inherited.HEL_ENV_PACKAGE
106
+ const values = Object.assign({}, readPackageFiles(cwd, mode), inherited)
107
+ values.HEL_ENV_PACKAGE = path.resolve(cwd)
108
+ expand({ parsed: values, processEnv: { ...values } })
109
+ values.UNPKG_PUBLIC_URL ||= 'https://unpkg.com'
110
+ const derived = new Set()
111
+ const put = (key, value) => {
112
+ if (!value) return
113
+ if (!values[key]) { values[key] = String(value); derived.add(key) }
114
+ }
115
+ const deployTarget = values.HEL_DEPLOY_TARGET
116
+ const runtimeMode = values.NODE_ENV || mode
117
+ const selected = resolveTarget(deployTarget || target || values.REMOTE_TARGET, runtimeMode)
118
+ localBuild ||= values.HEL_LOCAL_BUILD === '1'
119
+ const port = inherited.PORT || inherited.DEV_PORT || inherited.VITE_PORT || values.PORT || values.DEV_PORT
120
+ const previewPort = values.PREVIEW_PORT || port
121
+ if (port && (!/^\d+$/.test(String(port)) || +port < 1 || +port > 65535)) throw new Error('[hel-env] DEV_PORT must be between 1 and 65535')
122
+ if (port) values.DEV_PORT = String(port)
123
+ put('PORT', port)
124
+ put('VITE_PORT', port)
125
+ put('VUE_APP_PORT', port)
126
+ put('REACT_APP_PORT', port)
127
+ put('VITE_PREVIEW_PORT', previewPort)
128
+ put('VUE_APP_PREVIEW_PORT', previewPort)
129
+ put('VITE_DEV_ORIGIN', values.DEV_ORIGIN || (port ? `http://localhost:${port}` : ''))
130
+ put('VUE_APP_DEV_ORIGIN', values.VITE_DEV_ORIGIN)
131
+ // Deployment candidates remain Node-only; expose only the selected remote slot below.
132
+ for (const slot of remoteSlots(values)) {
133
+ const slotTarget = resolveTarget(deployTarget || target || values[`${slot}_TARGET`] || selected, runtimeMode)
134
+ const keys = [`VITE_${slot}_HOST`, `VUE_APP_${slot}_HOST`, `REACT_APP_${slot}_HOST`, `HEL_${slot}_HOST`]
135
+ const overrides = [...keys, `VUE_APP_${slot}_ENTRY`, `VITE_${slot}_ENTRY`, `${slot}_URL`]
136
+ .map(key => values[key]).filter(Boolean)
137
+ if (new Set(overrides).size > 1) throw new Error(`[hel-env] Conflicting ${slot} address overrides`)
138
+ const explicit = overrides[0]
139
+ const expected = !explicit || deployTarget
140
+ ? localBuild && !deployTarget && values[`${slot}_BUNDLED_PATH`]
141
+ ? './' + values[`${slot}_BUNDLED_PATH`]
142
+ : resolveRemoteUrl(values, slot, slotTarget)
143
+ : explicit
144
+ const resolved = explicit || expected
145
+ if (deployTarget) {
146
+ assertSameOrigin(resolved, values[`${deployTarget.toUpperCase()}_PUBLIC_URL`] || expected, slot)
147
+ if (resolved !== expected) throw new Error(`[hel-env] ${slot} must match the deployment package/version URL: ${expected}`)
148
+ }
149
+ for (const key of keys) put(key, resolved)
150
+ if (values[`${slot}_ENTRY`] === 'index.html') {
151
+ put(`VUE_APP_${slot}_ENTRY`, resolved)
152
+ put(`VITE_${slot}_ENTRY`, resolved)
153
+ }
154
+ put(`VITE_${slot}_LOCAL_URL`, values[`${slot}_LOCAL_URL`])
155
+ put(`VUE_APP_${slot}_LOCAL_URL`, values[`${slot}_LOCAL_URL`])
156
+ }
157
+ if (localBuild && values.VITE_DEV_ORIGIN) put('HEL_APP_HOME_PAGE', values.VITE_DEV_ORIGIN)
158
+ if (runtimeMode === 'production' && !localBuild) {
159
+ let defaultHomePage = values.HEL_APP_HOME_PAGE
160
+ // A native build/publish:stage has no deployment orchestrator to supply the
161
+ // output directory. Keep the package/version prefix when dropping the origin.
162
+ if (!defaultHomePage && values.HEL_RELATIVE_PATH === '1' && selected === 'unpkg') {
163
+ const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'))
164
+ if (pkg.unpkg && pkg.version) {
165
+ const url = packageUrl(packageRef(`${pkg.name}@${pkg.version}`), { base: values.UNPKG_PUBLIC_URL })
166
+ url.pathname += '/' + path.posix.dirname(pkg.unpkg.replace(/^\.\//, ''))
167
+ defaultHomePage = url.href
168
+ }
169
+ }
170
+ const homePage = resolveBuildHomePage(values, defaultHomePage)
171
+ if (homePage) values.HEL_APP_HOME_PAGE = homePage
172
+ }
173
+ if (deployTarget) put('VUE_APP_PUBLISH_MODE', deployTarget)
174
+ values.HEL_ENV_PACKAGE = path.resolve(cwd)
175
+ const computed = Object.fromEntries(Object.entries(values).filter(([key, value]) =>
176
+ !key.startsWith('HEL_ENV_') && inherited[key] !== value && !(key === 'HEL_APP_HOME_PAGE' && inherited[key])))
177
+ values.HEL_ENV_DERIVED_KEYS = Object.keys(computed).join(',')
178
+ values.HEL_ENV_GENERATED = JSON.stringify(computed)
179
+ return values
180
+ }
181
+
182
+ function inferMode(env = process.env, argv = process.argv) {
183
+ const modeIndex = argv.indexOf('--mode')
184
+ const inline = argv.find(arg => arg.startsWith('--mode='))
185
+ if (modeIndex >= 0 && argv[modeIndex + 1]) return argv[modeIndex + 1]
186
+ if (inline) return inline.slice(7)
187
+ if (env.HEL_ENV_MODE) return env.HEL_ENV_MODE
188
+ if (env.NODE_ENV) return env.NODE_ENV
189
+ return /^(?:build|preview|prepublish)/.test(env.npm_lifecycle_event || '') ? 'production' : 'development'
190
+ }
191
+
192
+ function applyPackageEnv({ cwd = process.cwd(), mode = inferMode() } = {}) {
193
+ const values = loadPackageEnv({ cwd, mode })
194
+ const preview = /^(?:preview|serve:dist)/.test(process.env.npm_lifecycle_event || '')
195
+ if (preview && !process.env.PORT && values.PREVIEW_PORT) values.PORT = values.PREVIEW_PORT
196
+ Object.assign(process.env, values)
197
+ return values
198
+ }
199
+
200
+ module.exports = { applyPackageEnv, inferMode, PUBLIC_ENV_KEYS, WORKSPACE_ENV_KEYS, readEnvFile, readPackageFiles, remoteSlots, resolveTarget, resolveRemoteUrl, resolveBuildHomePage, loadPackageEnv }
@@ -1,45 +1,53 @@
1
1
  #!/usr/bin/env node
2
- import { execSync } from 'node:child_process'
3
- import fs from 'node:fs'
4
- import os from 'node:os'
5
- import path from 'node:path'
6
-
7
- // 统一的 stage 发布入口:先 pnpm pack 再 npm stage publish。
8
- //
9
- // 为什么不能直接 `npx npm stage publish`:
10
- // npm 不认识 workspace: 协议,会把 `workspace:*` 原样写进 tarball 的 package.json,
11
- // 消费方安装时直接报 EUNSUPPORTEDPROTOCOL(例如 2026.11.8-1 的 ele-pure-full)。
12
- // pnpm pack 会把 workspace:* 改写成实际版本,再由 npm 把 tarball 送上 stage。
13
- //
14
- // prepublishOnly 的守卫(版本号 / hel-meta / localhost 资源地址)不会被 tarball 流程触发,
15
- // 这里显式跑一次,避免绕过 comps-* / libs-* 的发布前检查。
16
-
17
- const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
18
- if (pkg.private) {
19
- throw new Error('[publish:stage] 当前 package.json 是 private,请在要发布的包目录里执行')
20
- }
21
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'hel-stage-'))
22
- const run = (command) => execSync(command, { stdio: 'inherit' })
23
- let npmStage = 'npm'
24
- try {
25
- execSync('npm stage --help', { stdio: 'ignore' })
26
- } catch {
27
- npmStage = 'pnpm --registry=https://registry.npmjs.org --package=npm@11 dlx npm'
2
+ import { execSync } from 'node:child_process'
3
+ import fs from 'node:fs'
4
+ import os from 'node:os'
5
+ import path from 'node:path'
6
+
7
+ // 统一的 stage 发布入口:先 pnpm pack 再 npm stage publish。
8
+ //
9
+ // 为什么不能直接 `npx npm stage publish`:
10
+ // npm 不认识 workspace: 协议,会把 `workspace:*` 原样写进 tarball 的 package.json,
11
+ // 消费方安装时直接报 EUNSUPPORTEDPROTOCOL(例如 2026.11.8-1 的 ele-pure-full)。
12
+ // pnpm pack 会把 workspace:* 改写成实际版本,再由 npm 把 tarball 送上 stage。
13
+ //
14
+ // prepublishOnly 的守卫(版本号 / hel-meta / localhost 资源地址)不会被 tarball 流程触发,
15
+ // 这里显式跑一次,避免绕过 comps-* / libs-* 的发布前检查。
16
+
17
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
18
+ const args = process.argv.slice(2)
19
+ if (args.some(arg => arg !== '--dry-run')) throw new Error('用法:hel-publish-stage [--dry-run]')
20
+ const dryRun = args.includes('--dry-run')
21
+ if (pkg.private) {
22
+ throw new Error('[publish:stage] 当前 package.json 是 private,请在要发布的包目录里执行')
28
23
  }
29
-
30
- try {
31
- if (pkg.scripts && pkg.scripts.prepublishOnly) {
32
- run('pnpm run prepublishOnly')
33
- }
34
-
35
- run(`pnpm pack --pack-destination "${tmp}"`)
36
- const tgz = fs.readdirSync(tmp).find((file) => file.endsWith('.tgz'))
37
- if (!tgz) throw new Error('pnpm pack 没有产出 tarball')
38
-
39
- run(
24
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'hel-stage-'))
25
+ const run = (command) => execSync(command, { stdio: 'inherit' })
26
+ try {
27
+ if (pkg.scripts && pkg.scripts.prepublishOnly) {
28
+ run('pnpm run prepublishOnly')
29
+ }
30
+
31
+ run(`pnpm pack --pack-destination "${tmp}"`)
32
+ const tgz = fs.readdirSync(tmp).find((file) => file.endsWith('.tgz'))
33
+ if (!tgz) throw new Error('pnpm pack 没有产出 tarball')
34
+
35
+ if (dryRun) {
36
+ console.log(`[publish:stage] dry-run: ${pkg.name}@${pkg.version} packed; 未上传或修改版本。保留产物:${path.join(tmp, tgz)}`)
37
+ process.exitCode = 0
38
+ } else {
39
+ let npmStage = 'npm'
40
+ try {
41
+ execSync('npm stage --help', { stdio: 'ignore' })
42
+ } catch {
43
+ npmStage = 'pnpm --registry=https://registry.npmjs.org --package=npm@11 dlx npm'
44
+ }
45
+
46
+ run(
40
47
  `${npmStage} stage publish "${path.join(tmp, tgz)}" --registry=https://registry.npmjs.org --access public`,
41
- )
42
- console.log(`[publish:stage] ${pkg.name}@${pkg.version} staged`)
43
- } finally {
44
- fs.rmSync(tmp, { recursive: true, force: true })
45
- }
48
+ )
49
+ console.log(`[publish:stage] ${pkg.name}@${pkg.version} staged`)
50
+ }
51
+ } finally {
52
+ if (!dryRun) fs.rmSync(tmp, { recursive: true, force: true })
53
+ }
@@ -1,30 +1,30 @@
1
- // Shared by browser loading and Node env generation; no project-specific defaults.
2
- const HEL_BASES = Object.freeze({ unpkg: 'https://unpkg.com' })
3
-
4
- function packageRef(ref) {
5
- const match = /^(?:(@[a-z\d._-]+)\/)?([a-z\d][a-z\d._-]*)(?:@([a-z\d][a-z\d.+_-]*))?$/i.exec(ref)
6
- if (!match) throw new Error('无效的远程包名称或版本:' + ref)
7
- const [, scope, name, version] = match
8
- return { scope: scope || '', name, packageName: (scope ? scope + '/' : '') + name, version: version || '' }
9
- }
10
-
11
- /** Returns the package directory; callers select the output directory and entry. */
12
- function packageUrl(parsed, { type = 'unpkg', base, projectName, versioned = true } = {}) {
13
- const root = base || HEL_BASES[type]
14
- || (type === 'github' && parsed.scope ? 'https://' + parsed.scope.slice(1) + '.github.io' : '')
15
- if (!root) throw new Error(type === 'github' ? 'github 无 scope 的包引用需要 base(无法推导组织)' : 'custom 加载需要 base')
16
- let url
17
- try { url = new URL(root) } catch { throw new Error('需要绝对 HTTP(S) 地址:' + root) }
18
- if (!/^https?:$/.test(url.protocol)) throw new Error('不支持的地址协议:' + root)
19
- if (url.search || url.hash) throw new Error('base 不能包含查询参数或 hash:' + root)
20
- const name = projectName || (type === 'github' ? parsed.name : parsed.packageName)
21
- // An explicit deployment project directory takes precedence over npm namespaces.
22
- if (!projectName && type !== 'github' && parsed.scope) {
23
- url.pathname = url.pathname.replace(/\/@[a-z\d._-]+\/*$/i, '')
24
- }
25
- const version = versioned && parsed.version && parsed.version.toLowerCase() !== 'latest' ? '@' + parsed.version : ''
26
- url.pathname = url.pathname.replace(/\/+$/, '') + '/' + name + version
27
- return url
28
- }
29
-
30
- module.exports = { HEL_BASES, packageRef, packageUrl }
1
+ // Shared by browser loading and Node env generation; no project-specific defaults.
2
+ const HEL_BASES = Object.freeze({ unpkg: 'https://unpkg.com' })
3
+
4
+ function packageRef(ref) {
5
+ const match = /^(?:(@[a-z\d._-]+)\/)?([a-z\d][a-z\d._-]*)(?:@([a-z\d][a-z\d.+_-]*))?$/i.exec(ref)
6
+ if (!match) throw new Error('无效的远程包名称或版本:' + ref)
7
+ const [, scope, name, version] = match
8
+ return { scope: scope || '', name, packageName: (scope ? scope + '/' : '') + name, version: version || '' }
9
+ }
10
+
11
+ /** Returns the package directory; callers select the output directory and entry. */
12
+ function packageUrl(parsed, { type = 'unpkg', base, projectName, versioned = true } = {}) {
13
+ const root = base || HEL_BASES[type]
14
+ || (type === 'github' && parsed.scope ? 'https://' + parsed.scope.slice(1) + '.github.io' : '')
15
+ if (!root) throw new Error(type === 'github' ? 'github 无 scope 的包引用需要 base(无法推导组织)' : 'custom 加载需要 base')
16
+ let url
17
+ try { url = new URL(root) } catch { throw new Error('需要绝对 HTTP(S) 地址:' + root) }
18
+ if (!/^https?:$/.test(url.protocol)) throw new Error('不支持的地址协议:' + root)
19
+ if (url.search || url.hash) throw new Error('base 不能包含查询参数或 hash:' + root)
20
+ const name = projectName || (type === 'github' ? parsed.name : parsed.packageName)
21
+ // An explicit deployment project directory takes precedence over npm namespaces.
22
+ if (!projectName && type !== 'github' && parsed.scope) {
23
+ url.pathname = url.pathname.replace(/\/@[a-z\d._-]+\/*$/i, '')
24
+ }
25
+ const version = versioned && parsed.version && parsed.version.toLowerCase() !== 'latest' ? '@' + parsed.version : ''
26
+ url.pathname = url.pathname.replace(/\/+$/, '') + '/' + name + version
27
+ return url
28
+ }
29
+
30
+ module.exports = { HEL_BASES, packageRef, packageUrl }
@@ -1,14 +1,14 @@
1
- # 内置 Vue 文档解析器
2
-
3
- 此目录从 npm 发布包 `vdoc-parser@1.2.0` 的 `src/` 提取,作者:kennys wang <kennys_wang@163.com>,上游声明许可证为 **ISC**。
4
-
5
- - 下载地址:`https://registry.npmjs.org/vdoc-parser/-/vdoc-parser-1.2.0.tgz`
6
- - 上游 gitHead:`4723d6fc18be046e2546c3f9938bd7cb01487686`
7
- - 发布包 SHA-1:`2bd4f9cdc6d20780220ea0150deb1b713d9a8c33`
8
- - 发布包未包含独立 LICENSE 文件;此处保留其作者、许可证及源码出处信息。
9
-
10
- 本地适配:移除 TypeScript 类型语法,转换为可直接在 Node 中执行的 `.mjs` 源码;为相对导入补全扩展名,将 Node 内置模块改为 `node:` 前缀,并适配 Babel 7 generator 的 CommonJS 默认导出。解析算法不变,不再依赖或下载 `vdoc-parser` 包。
11
-
12
- 公共入口为 `@melt-js/libs-core/vdoc-parser`,保留 `parseCode`、`parseFile`、`parseFileSync`、`parseTypes`、`parseTypesFile`、`parseTypesFileSync`。该入口仅用于 Node 工具,不从 `libs-core` 的浏览器运行时入口导出。底层 Babel、SFC 编译器及 doctrine 由 `libs-core` 直接声明依赖。
13
-
1
+ # 内置 Vue 文档解析器
2
+
3
+ 此目录从 npm 发布包 `vdoc-parser@1.2.0` 的 `src/` 提取,作者:kennys wang <kennys_wang@163.com>,上游声明许可证为 **ISC**。
4
+
5
+ - 下载地址:`https://registry.npmjs.org/vdoc-parser/-/vdoc-parser-1.2.0.tgz`
6
+ - 上游 gitHead:`4723d6fc18be046e2546c3f9938bd7cb01487686`
7
+ - 发布包 SHA-1:`2bd4f9cdc6d20780220ea0150deb1b713d9a8c33`
8
+ - 发布包未包含独立 LICENSE 文件;此处保留其作者、许可证及源码出处信息。
9
+
10
+ 本地适配:移除 TypeScript 类型语法,转换为可直接在 Node 中执行的 `.mjs` 源码;为相对导入补全扩展名,将 Node 内置模块改为 `node:` 前缀,并适配 Babel 7 generator 的 CommonJS 默认导出。解析算法不变,不再依赖或下载 `vdoc-parser` 包。
11
+
12
+ 公共入口为 `@melt-js/libs-core/vdoc-parser`,保留 `parseCode`、`parseFile`、`parseFileSync`、`parseTypes`、`parseTypesFile`、`parseTypesFileSync`。该入口仅用于 Node 工具,不从 `libs-core` 的浏览器运行时入口导出。底层 Babel、SFC 编译器及 doctrine 由 `libs-core` 直接声明依赖。
13
+
14
14
  维护时直接修改本目录源码,并运行 `pnpm test`;调整发布内容后,还需执行 `pnpm pack` 并在仓库外验证安装。已有的上游限制(如部分负数默认值解析不完整)仍由 leva CLI 的 AST 补齐逻辑处理。
@@ -1,3 +1,3 @@
1
- // Derived from vdoc-parser 1.2.0 by kennys wang (ISC); see NOTICE.md.
2
- export const legalExtsReg = /\.(vue|ts|tsx|js|jsx)$/;
3
- export const vueExtReg = /\.vue$/;
1
+ // Derived from vdoc-parser 1.2.0 by kennys wang (ISC); see NOTICE.md.
2
+ export const legalExtsReg = /\.(vue|ts|tsx|js|jsx)$/;
3
+ export const vueExtReg = /\.vue$/;