From df7f62e1c84e139599c499f2b674b183a6dd47ff Mon Sep 17 00:00:00 2001
From: Aviril <48655846+OvileAmriam@users.noreply.github.com>
Date: Mon, 27 Jun 2022 18:56:36 +0300
Subject: [PATCH] Assetify v.4.4.0
---
.../assetify_library/handlers/bundler.lua | 2 +-
[Library]/assetify_library/meta.xml | 2 +-
.../assetify_library/utilities/asset.lua | 18 +++--
.../assetify_library/utilities/shared.lua | 70 ++++++++++++++++---
[Library]/assetify_mapper/meta.xml | 2 +-
5 files changed, 74 insertions(+), 20 deletions(-)
diff --git a/[Library]/assetify_library/handlers/bundler.lua b/[Library]/assetify_library/handlers/bundler.lua
index 300852bcc..1427ab940 100644
--- a/[Library]/assetify_library/handlers/bundler.lua
+++ b/[Library]/assetify_library/handlers/bundler.lua
@@ -40,7 +40,7 @@ local parseModules = {
local function parse(rw)
if not rw or (imports.type(rw) ~= "string") then return false end
for i, j in pairs(parseModules) do
- rw = imports.utf8.gsub(rw, i, j, true, "(", ".:)")
+ rw = imports.utf8.gsub(rw, i, j, _, true, "(", ".:)")
end
return rw
end
diff --git a/[Library]/assetify_library/meta.xml b/[Library]/assetify_library/meta.xml
index d51eda6d5..8b5d709ea 100644
--- a/[Library]/assetify_library/meta.xml
+++ b/[Library]/assetify_library/meta.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/[Library]/assetify_library/utilities/asset.lua b/[Library]/assetify_library/utilities/asset.lua
index 38dc1a4fc..35594ec4b 100644
--- a/[Library]/assetify_library/utilities/asset.lua
+++ b/[Library]/assetify_library/utilities/asset.lua
@@ -235,15 +235,19 @@ if localPlayer then
return true
end
else
- function asset:buildManifest(assetPath, manifestPath)
- local manifestData = imports.file.read(assetPath..manifestPath)
+ function asset:buildManifest(rootPath, localPath, manifestPath)
+ localPath = localPath or rootPath
+ local manifestData = imports.file.read(localPath..manifestPath)
manifestData = (manifestData and imports.json.decode(manifestData)) or false
if manifestData then
for i, j in imports.pairs(manifestData) do
- local url, directory = imports.file.parseURL(j, "json")
- if url and directory then
- url = imports.string.sub(url, #directory + 1)
- manifestData[i] = asset:buildManifest(assetPath..directory, url)
+ local cURL = imports.file.parseURL(j)
+ if cURL and cURL.url and cURL.extension and cURL.pointer and (cURL.extension == "json") then
+ local pointerPath = ((cURL.pointer == "rootDir") and rootPath) or ((cURL.pointer == "localDir") and localPath) or false
+ if pointerPath then
+ local __cURL = imports.file.parseURL(imports.file.resolveURL(pointerPath..(cURL.directory or "")..cURL.file, imports.file.validPointers["localDir"]..rootPath))
+ manifestData[i] = asset:buildManifest(rootPath, __cURL.directory or "", __cURL.file)
+ end
end
end
end
@@ -359,7 +363,7 @@ else
for i = 1, #cAssetPack.manifestData, 1 do
local assetName = cAssetPack.manifestData[i]
local assetPath = (asset.references.root)..imports.string.lower(assetType).."/"..assetName.."/"
- local assetManifestData = asset:buildManifest(assetPath, (asset.references.asset)..".json")
+ local assetManifestData = asset:buildManifest(assetPath, _, (asset.references.asset)..".json")
if assetManifestData then
assetManifestData.streamRange = imports.math.max(imports.tonumber(assetManifestData.streamRange) or 0, asset.ranges.streamRange)
assetManifestData.enableLODs = (assetManifestData.enableLODs and true) or false
diff --git a/[Library]/assetify_library/utilities/shared.lua b/[Library]/assetify_library/utilities/shared.lua
index 0da75c36f..2ab6bd03c 100644
--- a/[Library]/assetify_library/utilities/shared.lua
+++ b/[Library]/assetify_library/utilities/shared.lua
@@ -15,6 +15,7 @@
local imports = {
type = type,
pairs = pairs,
+ split = split,
tonumber = tonumber,
select = select,
unpack = unpack,
@@ -138,21 +139,67 @@ class = {
---------------------
file = {
+ validPointers = {rootDir = "~/", localDir = "@/"},
exists = imports.fileExists,
delete = imports.fileDelete,
- parseURL = function(path, extension)
- if not path or not extension or (imports.type(path) ~= "string") or (imports.type(extension) ~= "string") then return false end
- local _, startN = imports.utf8.find(path, "@/")
- local endN = imports.utf8.find(path, "."..extension)
- startN, endN = (startN and (startN + 1)) or startN, (endN and (endN - 1)) or endN
- if startN and endN then
- local url = imports.utf8.sub(path, startN, endN)
- if imports.string.match(url, "%w") then return url.."."..extension, imports.string.match(url, "(.*[/\\])") or "" end
+ parseURL = function(path)
+ if not path or (imports.type(path) ~= "string") then return false end
+ local extension = imports.utf8.match(path, "^.+%.(.+)$")
+ extension = (extension and imports.utf8.match(extension, "%w") and extension) or false
+ local pointer, pointerEndN = nil, nil
+ for i, j in imports.pairs(file.validPointers) do
+ local startN, endN = imports.utf8.find(path, j)
+ if startN and endN and (startN == 1) then
+ pointer, pointerEndN = i, endN + 1
+ break
+ end
+ end
+ local url = imports.utf8.sub(path, pointerEndN or 1, #path - ((extension and (#extension + 1)) or 0))
+ if imports.utf8.match(url, "%w") then
+ local cURL = {
+ pointer = pointer or false,
+ url = (extension and (url.."."..extension)) or url,
+ extension = extension,
+ directory = imports.utf8.match(url, "(.*[/\\])") or false
+ }
+ cURL.file = (cURL.extension and imports.utf8.sub(cURL.url, (cURL.directory and (#cURL.directory + 1)) or 1)) or false
+ return cURL
end
return false
end,
+ resolveURL = function(path, chroot)
+ if not path or (imports.type(path) ~= "string") or (chroot and (imports.type(chroot) ~= "string")) then return false end
+ local cURL = file.parseURL(path)
+ if not cURL then return false end
+ cURL.url = (cURL.pointer and imports.utf8.gsub(cURL.url, file.validPointers[(cURL.pointer)], "")) or cURL.url
+ local cDirs = imports.split(cURL.url, "/")
+ if #cDirs > 0 then
+ if chroot then
+ chroot = file.parseURL(((imports.utf8.sub(chroot, #chroot) ~= "/") and chroot.."/") or chroot)
+ chroot = (chroot and chroot.pointer and imports.utf8.gsub(chroot.url, file.validPointers[(chroot.pointer)], "")) or chroot
+ end
+ cURL.url = false
+ local vDirs = {}
+ for i = 1, #cDirs, 1 do
+ local j = cDirs[i]
+ if j == "..." then
+ if not chroot or (chroot ~= cURL.url) then
+ imports.table.remove(vDirs, vDirs.__N)
+ end
+ else
+ imports.table.insert(vDirs, j)
+ end
+ cURL.url = imports.table.concat(vDirs, "/")
+ local __cURL = file.parseURL(cURL.url)
+ cURL.url = (__cURL and not __cURL.file and cURL.url.."/") or cURL.url
+ end
+ cURL.url = ((cURL.pointer and file.validPointers[(cURL.pointer)]) or "")..(cURL.url or "")
+ end
+ return cURL.url
+ end,
+
read = function(path)
if not path or not imports.fileExists(path) then return false end
local cFile = imports.fileOpen(path, true)
@@ -179,10 +226,13 @@ file = {
---------------------
local __utf8_gsub = imports.utf8.gsub
-utf8.gsub = function(string, matchWord, replaceWord, isStrictcMatch, matchPrefix, matchPostfix)
+utf8.gsub = function(string, matchWord, replaceWord, matchLimit, isStrictcMatch, matchPrefix, matchPostfix)
+ if not matchWord then
+ print(string)
+ end
matchPrefix, matchPostfix = matchPrefix or "", matchPostfix or ""
matchWord = (isStrictcMatch and "%f[^"..matchPrefix.."%z%s]"..matchWord.."%f["..matchPostfix.."%z%s]") or matchPrefix..matchWord..matchPostfix
- return __utf8_gsub(string, matchWord, replaceWord)
+ return __utf8_gsub(string, matchWord, replaceWord, matchLimit)
end
diff --git a/[Library]/assetify_mapper/meta.xml b/[Library]/assetify_mapper/meta.xml
index 451b3bbad..c91495572 100644
--- a/[Library]/assetify_mapper/meta.xml
+++ b/[Library]/assetify_mapper/meta.xml
@@ -1,6 +1,6 @@
-
+