This commit is contained in:
2026-01-16 20:55:57 -06:00
parent b46406f755
commit ce7d83ec91
9 changed files with 48 additions and 246 deletions

View File

@@ -247,13 +247,13 @@ function safe_package_path(pkg)
// For absolute paths, replace / with _ to create a valid directory name
// Also replace @ with _
if (pkg && starts_with(pkg, '/'))
return pkg.replaceAll('/', '_').replaceAll('@', '_')
return pkg.replaceAll('@', '_')
return replace(replace(pkg, '/', '_'), '@', '_')
return replace(pkg, '@', '_')
}
function package_cache_path(pkg)
{
return global_shop_path + '/cache/' + pkg.replaceAll('/', '_').replaceAll('@', '_')
return global_shop_path + '/cache/' + replace(replace(pkg, '/', '_'), '@', '_')
}
function get_shared_lib_path()
@@ -519,15 +519,15 @@ function resolve_locator(path, ctx)
// Uses the same format as Shop.c_symbol_for_file
// Symbol names are based on canonical package names, not link targets
function make_c_symbol(pkg, file) {
var pkg_safe = pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_')
var file_safe = file.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_')
var pkg_safe = replace(replace(replace(pkg, '/', '_'), '.', '_'), '-', '_')
var file_safe = replace(replace(replace(file, '/', '_'), '.', '_'), '-', '_')
return 'js_' + pkg_safe + '_' + file_safe + '_use'
}
// Get the library path for a package in .cell/lib
// Library names are based on canonical package names, not link targets
function get_lib_path(pkg) {
var lib_name = pkg.replace(/\//g, '_').replace(/\./g, '_').replace(/-/g, '_')
var lib_name = replace(replace(replace(pkg, '/', '_'), '.', '_'), '-', '_')
return global_shop_path + '/lib/' + lib_name + dylib_ext
}
@@ -615,7 +615,7 @@ function resolve_c_symbol(path, package_context) {
// If no package context, only check core internal symbols
if (!package_context || package_context == 'core') {
path = path.replaceAll('/', '_')
path = replace(path, '/', '_')
var core_sym = `js_${path}_use`
if (os.internal_exists(core_sym)) {
return {
@@ -684,7 +684,7 @@ function resolve_c_symbol(path, package_context) {
}
// 3. Check core internal symbols (core is never a dynamic library)
var core_sym = `js_${path.replaceAll('/', '_')}_use`
var core_sym = `js_${replace(path, '/', '_')}_use`
if (os.internal_exists(core_sym)) {
return {
symbol: function() { return os.load_internal(core_sym) },
@@ -846,7 +846,7 @@ Shop.resolve_locator = resolve_locator
// Get cache path for a package and commit
function get_cache_path(pkg, commit) {
return global_shop_path + '/cache/' + pkg.replaceAll('@','_').replaceAll('/','_') + '_' + commit + '.zip'
return global_shop_path + '/cache/' + replace(replace(pkg, '@','_'), '/','_') + '_' + commit + '.zip'
}
function get_package_abs_dir(package)
@@ -1250,22 +1250,22 @@ Shop.get_package_dir = function(pkg) {
// e.g., c_symbol_for_file('gitea.pockle.world/john/prosperon', 'sprite.c')
// -> 'js_gitea_pockle_world_john_prosperon_sprite_use'
Shop.c_symbol_for_file = function(pkg, file) {
var pkg_safe = pkg.replaceAll(/\//g, '_').replaceAll(/\./g, '_').replaceAll(/-/g, '_')
var file_safe = text(file, 0, file.lastIndexOf('.')).replaceAll(/\//g, '_').replaceAll(/\./g, '_').replaceAll(/-/g, '_')
var pkg_safe = replace(replace(replace(pkg, '/', '_'), '.', '_'), '-', '_')
var file_safe = replace(replace(text(file, 0, file.lastIndexOf('.')), '/', '_'), '.', '_')
return 'js_' + pkg_safe + '_' + file_safe + '_use'
}
// Generate C symbol prefix for a package
// e.g., c_symbol_prefix('gitea.pockle.world/john/prosperon') -> 'js_gitea_pockle_world_john_prosperon_'
Shop.c_symbol_prefix = function(pkg) {
var pkg_safe = pkg.replaceAll(/\//g, '_').replaceAll(/\./g, '_').replaceAll(/-/g, '_')
var pkg_safe = replace(replace(replace(pkg, '/', '_'), '.', '_'), '-', '_')
return 'js_' + pkg_safe + '_'
}
// Get the library name for a package (without extension)
// e.g., 'gitea.pockle.world/john/prosperon' -> 'gitea_pockle_world_john_prosperon'
Shop.lib_name_for_package = function(pkg) {
return pkg.replaceAll(/\//g, '_').replaceAll(/\./g, '_').replaceAll(/-/g, '_')
return replace(replace(replace(pkg, '/', '_'), '.', '_'), '-', '_')
}
// Returns { ok: bool, results: [{pkg, ok, error}] }