@zephyr3d/editor 0.3.4 → 0.3.5
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/dist/assets/{index-DzQzWsCG.js → index-DlnbO59X.js} +2 -2
- package/dist/assistant/zephyr-types-index.json +9 -10
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +13 -12
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_base.js +152 -152
- package/dist/modules/zephyr3d_base.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +15 -15
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_loaders.js +6 -6
- package/dist/modules/zephyr3d_loaders.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +1382 -1385
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +7 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +6 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/base/dist/vfs/common.js +152 -152
- package/dist/vendor/zephyr3d/base/dist/vfs/common.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +15 -15
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js +6 -6
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +191 -194
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js +19 -19
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js +131 -131
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js +119 -119
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js +62 -62
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js +13 -13
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +201 -201
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js +4 -4
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js +11 -11
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +284 -284
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +9 -9
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +7 -7
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js +45 -45
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +275 -275
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/package.json +3 -3
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -9920,35 +9920,35 @@ const mimeTypes = {
|
|
|
9920
9920
|
'.zprefab': 'application/vnd.zephyr3d.prefab+json',
|
|
9921
9921
|
'.zabc': 'application/vnd.zephyr3d.alembic-cache+json'
|
|
9922
9922
|
};
|
|
9923
|
-
/**
|
|
9924
|
-
* Path utilities.
|
|
9925
|
-
*
|
|
9926
|
-
* Provides POSIX-like path manipulation helpers (pure string operations),
|
|
9927
|
-
* including normalization, joining, dirname/basename/extname extraction,
|
|
9928
|
-
* absolute-path detection, and relative path computation.
|
|
9929
|
-
*
|
|
9930
|
-
* Notes:
|
|
9931
|
-
* - Uses "/" as the separator (web/URL or POSIX-like paths).
|
|
9932
|
-
* - All methods are pure and do not touch a real filesystem.
|
|
9933
|
-
* - `normalize` collapses ".", "..", and redundant slashes.
|
|
9934
|
-
*
|
|
9935
|
-
* @public
|
|
9923
|
+
/**
|
|
9924
|
+
* Path utilities.
|
|
9925
|
+
*
|
|
9926
|
+
* Provides POSIX-like path manipulation helpers (pure string operations),
|
|
9927
|
+
* including normalization, joining, dirname/basename/extname extraction,
|
|
9928
|
+
* absolute-path detection, and relative path computation.
|
|
9929
|
+
*
|
|
9930
|
+
* Notes:
|
|
9931
|
+
* - Uses "/" as the separator (web/URL or POSIX-like paths).
|
|
9932
|
+
* - All methods are pure and do not touch a real filesystem.
|
|
9933
|
+
* - `normalize` collapses ".", "..", and redundant slashes.
|
|
9934
|
+
*
|
|
9935
|
+
* @public
|
|
9936
9936
|
*/ class PathUtils {
|
|
9937
|
-
/**
|
|
9938
|
-
* Normalizes a path by collapsing redundant slashes, removing "." segments,
|
|
9939
|
-
* and resolving ".." segments.
|
|
9940
|
-
*
|
|
9941
|
-
* Rules:
|
|
9942
|
-
* - Multiple consecutive "/" are collapsed into a single "/".
|
|
9943
|
-
* - "." segments are removed.
|
|
9944
|
-
* - ".." removes the previous segment (no-op at root).
|
|
9945
|
-
* - The result always starts with "/" (absolute form).
|
|
9946
|
-
*
|
|
9947
|
-
* Example:
|
|
9948
|
-
* - normalize('/a//b/./c/../d') -\> '/a/b/d'
|
|
9949
|
-
*
|
|
9950
|
-
* @param path - Input path (relative or absolute).
|
|
9951
|
-
* @returns The normalized absolute path (always starting with "/").
|
|
9937
|
+
/**
|
|
9938
|
+
* Normalizes a path by collapsing redundant slashes, removing "." segments,
|
|
9939
|
+
* and resolving ".." segments.
|
|
9940
|
+
*
|
|
9941
|
+
* Rules:
|
|
9942
|
+
* - Multiple consecutive "/" are collapsed into a single "/".
|
|
9943
|
+
* - "." segments are removed.
|
|
9944
|
+
* - ".." removes the previous segment (no-op at root).
|
|
9945
|
+
* - The result always starts with "/" (absolute form).
|
|
9946
|
+
*
|
|
9947
|
+
* Example:
|
|
9948
|
+
* - normalize('/a//b/./c/../d') -\> '/a/b/d'
|
|
9949
|
+
*
|
|
9950
|
+
* @param path - Input path (relative or absolute).
|
|
9951
|
+
* @returns The normalized absolute path (always starting with "/").
|
|
9952
9952
|
*/ static normalize(path) {
|
|
9953
9953
|
const parts = path.split('/').filter((p)=>p && p !== '.');
|
|
9954
9954
|
const result = [];
|
|
@@ -9961,55 +9961,55 @@ const mimeTypes = {
|
|
|
9961
9961
|
}
|
|
9962
9962
|
return '/' + result.join('/');
|
|
9963
9963
|
}
|
|
9964
|
-
/**
|
|
9965
|
-
* Joins multiple path segments and normalizes the result.
|
|
9966
|
-
*
|
|
9967
|
-
* Behavior:
|
|
9968
|
-
* - Concatenates segments with "/" and then runs `normalize`.
|
|
9969
|
-
* - The returned path is always absolute.
|
|
9970
|
-
*
|
|
9971
|
-
* Example:
|
|
9972
|
-
* - join('/a', 'b', '../c') -\> '/a/c'
|
|
9973
|
-
*
|
|
9974
|
-
* @param paths - Path segments in order.
|
|
9975
|
-
* @returns Normalized absolute path.
|
|
9964
|
+
/**
|
|
9965
|
+
* Joins multiple path segments and normalizes the result.
|
|
9966
|
+
*
|
|
9967
|
+
* Behavior:
|
|
9968
|
+
* - Concatenates segments with "/" and then runs `normalize`.
|
|
9969
|
+
* - The returned path is always absolute.
|
|
9970
|
+
*
|
|
9971
|
+
* Example:
|
|
9972
|
+
* - join('/a', 'b', '../c') -\> '/a/c'
|
|
9973
|
+
*
|
|
9974
|
+
* @param paths - Path segments in order.
|
|
9975
|
+
* @returns Normalized absolute path.
|
|
9976
9976
|
*/ static join(...paths) {
|
|
9977
9977
|
return this.normalize(paths.join('/'));
|
|
9978
9978
|
}
|
|
9979
|
-
/**
|
|
9980
|
-
* Returns the directory name (parent directory) of a path.
|
|
9981
|
-
*
|
|
9982
|
-
* Behavior:
|
|
9983
|
-
* - Applies `normalize` first.
|
|
9984
|
-
* - If the path is root "/" or has no parent, returns "/".
|
|
9985
|
-
*
|
|
9986
|
-
* Examples:
|
|
9987
|
-
* - dirname('/a/b/c') -\> '/a/b'
|
|
9988
|
-
* - dirname('/a') -\> '/'
|
|
9989
|
-
* - dirname('/') -\> '/'
|
|
9990
|
-
*
|
|
9991
|
-
* @param path - Input path.
|
|
9992
|
-
* @returns Directory path of the input.
|
|
9979
|
+
/**
|
|
9980
|
+
* Returns the directory name (parent directory) of a path.
|
|
9981
|
+
*
|
|
9982
|
+
* Behavior:
|
|
9983
|
+
* - Applies `normalize` first.
|
|
9984
|
+
* - If the path is root "/" or has no parent, returns "/".
|
|
9985
|
+
*
|
|
9986
|
+
* Examples:
|
|
9987
|
+
* - dirname('/a/b/c') -\> '/a/b'
|
|
9988
|
+
* - dirname('/a') -\> '/'
|
|
9989
|
+
* - dirname('/') -\> '/'
|
|
9990
|
+
*
|
|
9991
|
+
* @param path - Input path.
|
|
9992
|
+
* @returns Directory path of the input.
|
|
9993
9993
|
*/ static dirname(path) {
|
|
9994
9994
|
const normalized = this.normalize(path);
|
|
9995
9995
|
const lastSlash = normalized.lastIndexOf('/');
|
|
9996
9996
|
return lastSlash <= 0 ? '/' : normalized.slice(0, lastSlash);
|
|
9997
9997
|
}
|
|
9998
|
-
/**
|
|
9999
|
-
* Returns the last portion of a path (file name).
|
|
10000
|
-
*
|
|
10001
|
-
* Behavior:
|
|
10002
|
-
* - Applies `normalize` first.
|
|
10003
|
-
* - If `ext` is provided and the name ends with it, the extension is stripped.
|
|
10004
|
-
*
|
|
10005
|
-
* Examples:
|
|
10006
|
-
* - basename('/a/b/c.txt') -\> 'c.txt'
|
|
10007
|
-
* - basename('/a/b/c.txt', '.txt') -\> 'c'
|
|
10008
|
-
* - basename('/') -\> ''
|
|
10009
|
-
*
|
|
10010
|
-
* @param path - Input path.
|
|
10011
|
-
* @param ext - Optional extension to strip (exact suffix match).
|
|
10012
|
-
* @returns The base name of the path.
|
|
9998
|
+
/**
|
|
9999
|
+
* Returns the last portion of a path (file name).
|
|
10000
|
+
*
|
|
10001
|
+
* Behavior:
|
|
10002
|
+
* - Applies `normalize` first.
|
|
10003
|
+
* - If `ext` is provided and the name ends with it, the extension is stripped.
|
|
10004
|
+
*
|
|
10005
|
+
* Examples:
|
|
10006
|
+
* - basename('/a/b/c.txt') -\> 'c.txt'
|
|
10007
|
+
* - basename('/a/b/c.txt', '.txt') -\> 'c'
|
|
10008
|
+
* - basename('/') -\> ''
|
|
10009
|
+
*
|
|
10010
|
+
* @param path - Input path.
|
|
10011
|
+
* @param ext - Optional extension to strip (exact suffix match).
|
|
10012
|
+
* @returns The base name of the path.
|
|
10013
10013
|
*/ static basename(path, ext) {
|
|
10014
10014
|
const normalized = this.normalize(path);
|
|
10015
10015
|
const lastSlash = normalized.lastIndexOf('/');
|
|
@@ -10019,44 +10019,44 @@ const mimeTypes = {
|
|
|
10019
10019
|
}
|
|
10020
10020
|
return name;
|
|
10021
10021
|
}
|
|
10022
|
-
/**
|
|
10023
|
-
* Returns the extension of the path, including the leading dot.
|
|
10024
|
-
*
|
|
10025
|
-
* Behavior:
|
|
10026
|
-
* - Based on the result of `basename`.
|
|
10027
|
-
* - If there is no dot, returns an empty string.
|
|
10028
|
-
*
|
|
10029
|
-
* Examples:
|
|
10030
|
-
* - extname('/a/b/c.txt') -\> '.txt'
|
|
10031
|
-
* - extname('/a/b/c') -\> ''
|
|
10032
|
-
*
|
|
10033
|
-
* @param path - Input path.
|
|
10034
|
-
* @returns The extension (e.g., ".txt") or an empty string if none.
|
|
10022
|
+
/**
|
|
10023
|
+
* Returns the extension of the path, including the leading dot.
|
|
10024
|
+
*
|
|
10025
|
+
* Behavior:
|
|
10026
|
+
* - Based on the result of `basename`.
|
|
10027
|
+
* - If there is no dot, returns an empty string.
|
|
10028
|
+
*
|
|
10029
|
+
* Examples:
|
|
10030
|
+
* - extname('/a/b/c.txt') -\> '.txt'
|
|
10031
|
+
* - extname('/a/b/c') -\> ''
|
|
10032
|
+
*
|
|
10033
|
+
* @param path - Input path.
|
|
10034
|
+
* @returns The extension (e.g., ".txt") or an empty string if none.
|
|
10035
10035
|
*/ static extname(path) {
|
|
10036
10036
|
const basename = this.basename(path);
|
|
10037
10037
|
const lastDot = basename.lastIndexOf('.');
|
|
10038
10038
|
return lastDot === -1 ? '' : basename.slice(lastDot);
|
|
10039
10039
|
}
|
|
10040
|
-
/**
|
|
10041
|
-
* Sanitizes a file or directory name by replacing or removing invalid characters.
|
|
10042
|
-
*
|
|
10043
|
-
* Behavior:
|
|
10044
|
-
* - Removes or replaces characters that are invalid in common filesystems.
|
|
10045
|
-
* - Trims leading/trailing spaces and dots.
|
|
10046
|
-
* - Collapses multiple spaces into single spaces.
|
|
10047
|
-
* - Replaces reserved names with safe alternatives.
|
|
10048
|
-
* - Optionally limits the length of the result.
|
|
10049
|
-
*
|
|
10050
|
-
* Examples:
|
|
10051
|
-
* - sanitizeFilename('my file.txt') -\> 'my file.txt'
|
|
10052
|
-
* - sanitizeFilename('file:name*.txt') -\> 'file_name_.txt'
|
|
10053
|
-
* - sanitizeFilename(' .hidden ') -\> 'hidden'
|
|
10054
|
-
* - sanitizeFilename('CON') -\> '_CON'
|
|
10055
|
-
* - sanitizeFilename('a'.repeat(300)) -\> (truncated to maxLength)
|
|
10056
|
-
*
|
|
10057
|
-
* @param filename - Input filename to sanitize.
|
|
10058
|
-
* @param options - Optional configuration.
|
|
10059
|
-
* @returns Sanitized filename safe for use across platforms.
|
|
10040
|
+
/**
|
|
10041
|
+
* Sanitizes a file or directory name by replacing or removing invalid characters.
|
|
10042
|
+
*
|
|
10043
|
+
* Behavior:
|
|
10044
|
+
* - Removes or replaces characters that are invalid in common filesystems.
|
|
10045
|
+
* - Trims leading/trailing spaces and dots.
|
|
10046
|
+
* - Collapses multiple spaces into single spaces.
|
|
10047
|
+
* - Replaces reserved names with safe alternatives.
|
|
10048
|
+
* - Optionally limits the length of the result.
|
|
10049
|
+
*
|
|
10050
|
+
* Examples:
|
|
10051
|
+
* - sanitizeFilename('my file.txt') -\> 'my file.txt'
|
|
10052
|
+
* - sanitizeFilename('file:name*.txt') -\> 'file_name_.txt'
|
|
10053
|
+
* - sanitizeFilename(' .hidden ') -\> 'hidden'
|
|
10054
|
+
* - sanitizeFilename('CON') -\> '_CON'
|
|
10055
|
+
* - sanitizeFilename('a'.repeat(300)) -\> (truncated to maxLength)
|
|
10056
|
+
*
|
|
10057
|
+
* @param filename - Input filename to sanitize.
|
|
10058
|
+
* @param options - Optional configuration.
|
|
10059
|
+
* @returns Sanitized filename safe for use across platforms.
|
|
10060
10060
|
*/ static sanitizeFilename(filename, options) {
|
|
10061
10061
|
const { replacement = '_', maxLength = 255, asciiOnly = false } = options ?? {};
|
|
10062
10062
|
const reserved = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
|
|
@@ -10097,32 +10097,32 @@ const mimeTypes = {
|
|
|
10097
10097
|
}
|
|
10098
10098
|
return sanitized;
|
|
10099
10099
|
}
|
|
10100
|
-
/**
|
|
10101
|
-
* Determines whether the path is absolute.
|
|
10102
|
-
*
|
|
10103
|
-
* Definition here: absolute paths start with "/".
|
|
10104
|
-
*
|
|
10105
|
-
* @param path - Input path.
|
|
10106
|
-
* @returns True if the path starts with "/", otherwise false.
|
|
10100
|
+
/**
|
|
10101
|
+
* Determines whether the path is absolute.
|
|
10102
|
+
*
|
|
10103
|
+
* Definition here: absolute paths start with "/".
|
|
10104
|
+
*
|
|
10105
|
+
* @param path - Input path.
|
|
10106
|
+
* @returns True if the path starts with "/", otherwise false.
|
|
10107
10107
|
*/ static isAbsolute(path) {
|
|
10108
10108
|
return path.startsWith('/');
|
|
10109
10109
|
}
|
|
10110
|
-
/**
|
|
10111
|
-
* Computes a relative path from one path to another.
|
|
10112
|
-
*
|
|
10113
|
-
* Behavior:
|
|
10114
|
-
* - Both `from` and `to` are normalized first.
|
|
10115
|
-
* - The returned path does not start with "/" (relative form).
|
|
10116
|
-
* - If both resolve to the same path, returns ".".
|
|
10117
|
-
*
|
|
10118
|
-
* Examples:
|
|
10119
|
-
* - relative('/a/b/c', '/a/d/e') -\> '../../d/e'
|
|
10120
|
-
* - relative('/a/b', '/a/b/c') -\> 'c'
|
|
10121
|
-
* - relative('/a/b', '/a/b') -\> '.'
|
|
10122
|
-
*
|
|
10123
|
-
* @param from - Base path to start from.
|
|
10124
|
-
* @param to - Target path to reach.
|
|
10125
|
-
* @returns Relative path from `from` to `to`.
|
|
10110
|
+
/**
|
|
10111
|
+
* Computes a relative path from one path to another.
|
|
10112
|
+
*
|
|
10113
|
+
* Behavior:
|
|
10114
|
+
* - Both `from` and `to` are normalized first.
|
|
10115
|
+
* - The returned path does not start with "/" (relative form).
|
|
10116
|
+
* - If both resolve to the same path, returns ".".
|
|
10117
|
+
*
|
|
10118
|
+
* Examples:
|
|
10119
|
+
* - relative('/a/b/c', '/a/d/e') -\> '../../d/e'
|
|
10120
|
+
* - relative('/a/b', '/a/b/c') -\> 'c'
|
|
10121
|
+
* - relative('/a/b', '/a/b') -\> '.'
|
|
10122
|
+
*
|
|
10123
|
+
* @param from - Base path to start from.
|
|
10124
|
+
* @param to - Target path to reach.
|
|
10125
|
+
* @returns Relative path from `from` to `to`.
|
|
10126
10126
|
*/ static relative(from, to) {
|
|
10127
10127
|
const fromParts = this.normalize(from).split('/').filter(Boolean);
|
|
10128
10128
|
const toParts = this.normalize(to).split('/').filter(Boolean);
|
|
@@ -10135,37 +10135,37 @@ const mimeTypes = {
|
|
|
10135
10135
|
return up + down || '.';
|
|
10136
10136
|
}
|
|
10137
10137
|
}
|
|
10138
|
-
/**
|
|
10139
|
-
* Guesses the MIME type based on a file path or file name.
|
|
10140
|
-
*
|
|
10141
|
-
* Behavior:
|
|
10142
|
-
* - Uses `PathUtils.extname` to extract the extension (case-insensitive).
|
|
10143
|
-
* - Falls back to `application/octet-stream` if unknown.
|
|
10144
|
-
*
|
|
10145
|
-
* Notes:
|
|
10146
|
-
* - The mapping is intentionally minimal and web-oriented.
|
|
10147
|
-
* - Extend the `mimeTypes` table if you need additional types.
|
|
10148
|
-
*
|
|
10149
|
-
* Examples:
|
|
10150
|
-
* - guessMimeType('image.png') -\> 'image/png'
|
|
10151
|
-
* - guessMimeType('/a/b/model.glb') -\> 'model/gltf-binary'
|
|
10152
|
-
* - guessMimeType('unknown.ext') -\> 'application/octet-stream'
|
|
10153
|
-
*
|
|
10154
|
-
* @param path - File path or name used to infer the MIME type.
|
|
10155
|
-
* @returns The guessed MIME type string.
|
|
10156
|
-
*
|
|
10157
|
-
* @public
|
|
10138
|
+
/**
|
|
10139
|
+
* Guesses the MIME type based on a file path or file name.
|
|
10140
|
+
*
|
|
10141
|
+
* Behavior:
|
|
10142
|
+
* - Uses `PathUtils.extname` to extract the extension (case-insensitive).
|
|
10143
|
+
* - Falls back to `application/octet-stream` if unknown.
|
|
10144
|
+
*
|
|
10145
|
+
* Notes:
|
|
10146
|
+
* - The mapping is intentionally minimal and web-oriented.
|
|
10147
|
+
* - Extend the `mimeTypes` table if you need additional types.
|
|
10148
|
+
*
|
|
10149
|
+
* Examples:
|
|
10150
|
+
* - guessMimeType('image.png') -\> 'image/png'
|
|
10151
|
+
* - guessMimeType('/a/b/model.glb') -\> 'model/gltf-binary'
|
|
10152
|
+
* - guessMimeType('unknown.ext') -\> 'application/octet-stream'
|
|
10153
|
+
*
|
|
10154
|
+
* @param path - File path or name used to infer the MIME type.
|
|
10155
|
+
* @returns The guessed MIME type string.
|
|
10156
|
+
*
|
|
10157
|
+
* @public
|
|
10158
10158
|
*/ function guessMimeType(path) {
|
|
10159
10159
|
const ext = PathUtils.extname(path).toLowerCase();
|
|
10160
10160
|
return mimeTypes[ext] || 'application/octet-stream';
|
|
10161
10161
|
}
|
|
10162
|
-
/**
|
|
10163
|
-
* Gets the MIME type based on a file extension.
|
|
10164
|
-
*
|
|
10165
|
-
* @param ext - File extension (e.g., "png", ".jpg").
|
|
10166
|
-
* @returns The corresponding MIME type or 'application/octet-stream' if unknown.
|
|
10167
|
-
*
|
|
10168
|
-
* @public
|
|
10162
|
+
/**
|
|
10163
|
+
* Gets the MIME type based on a file extension.
|
|
10164
|
+
*
|
|
10165
|
+
* @param ext - File extension (e.g., "png", ".jpg").
|
|
10166
|
+
* @returns The corresponding MIME type or 'application/octet-stream' if unknown.
|
|
10167
|
+
*
|
|
10168
|
+
* @public
|
|
10169
10169
|
*/ function mimeTypeOf(ext) {
|
|
10170
10170
|
ext = ext.toLowerCase();
|
|
10171
10171
|
if (!ext.startsWith('.')) {
|