@melt-js/libs-core 2026.11.14 → 2026.11.15

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/src/remote.mjs CHANGED
@@ -104,9 +104,46 @@ export function assertHelExports(moduleName, host, lib, requiredExports = []) {
104
104
  }
105
105
  }
106
106
 
107
+ /** Relative builds must resolve against the remote package, including file:// hosts. */
108
+ function resolveMetaAssets(meta, host) {
109
+ const srcMap = meta && meta.version && meta.version.src_map
110
+ if (!srcMap || !isHelMetaHost(host)) return
111
+ const base = new URL('.', host).href
112
+ const webDir = String(srcMap.webDirPath || '').replace(/\/+$/, '')
113
+ const absolute = value => {
114
+ if (typeof value !== 'string' || !value || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(value)) return value
115
+ const resolved = webDir && value.startsWith(webDir + '/')
116
+ ? new URL(value.slice(webDir.length + 1), base).href
117
+ : new URL(!webDir ? value.replace(/^\/+/, '') : value, base).href
118
+ // Webpack chunks retain their original publicPath inside the runtime. Use
119
+ // HEL's existing append hook for those dynamic requests as well as metadata.
120
+ if (typeof document !== 'undefined' && document.baseURI) {
121
+ const core = helMicro.core
122
+ const browserUrl = new URL(value, document.baseURI).href
123
+ core.setCommonData(core.helConsts.KEY_ASSET_CTX, browserUrl, {
124
+ marked: true,
125
+ beforeAppend: ({ setAssetUrl }) => { setAssetUrl(resolved) },
126
+ })
127
+ }
128
+ return resolved
129
+ }
130
+ for (const [key, value] of Object.entries(srcMap)) {
131
+ if (key === 'headAssetList' || key === 'bodyAssetList') {
132
+ for (const asset of value || []) {
133
+ for (const attr of ['src', 'href']) {
134
+ if (asset.attrs && asset.attrs[attr]) asset.attrs[attr] = absolute(asset.attrs[attr])
135
+ }
136
+ }
137
+ } else if (key.endsWith('List') && Array.isArray(value)) srcMap[key] = value.map(absolute)
138
+ else if (key !== 'webDirPath' && /(?:Path|Src|Index)$/.test(key)) srcMap[key] = absolute(value)
139
+ }
140
+ if (!/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(webDir)) srcMap.webDirPath = base.replace(/\/$/, '')
141
+ }
142
+
107
143
  function fetchOptions(spec) {
108
144
  return {
109
145
  ...(spec.platform ? { platform: spec.platform } : {}),
146
+ hook: { onFetchMetaSuccess: meta => resolveMetaAssets(meta, spec.host) },
110
147
  custom: {
111
148
  skipFetchHelMeta: !isHelMetaHost(spec.host), enable: true, trust: true,
112
149
  ...(spec.custom || {}),