@scalar/json-magic 0.11.0 → 0.11.4
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/CHANGELOG.md +42 -0
- package/dist/helpers/resolve-reference-path.js +2 -2
- package/dist/helpers/resolve-reference-path.js.map +2 -2
- package/dist/helpers/to-relative-path.d.ts.map +1 -1
- package/dist/helpers/to-relative-path.js +6 -7
- package/dist/helpers/to-relative-path.js.map +2 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @scalar/json-magic
|
|
2
2
|
|
|
3
|
+
## 0.11.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#8212](https://github.com/scalar/scalar/pull/8212): chore: version bump
|
|
8
|
+
|
|
9
|
+
#### Updated Dependencies
|
|
10
|
+
|
|
11
|
+
- **@scalar/helpers@0.2.15**
|
|
12
|
+
- [#8212](https://github.com/scalar/scalar/pull/8212): chore: version bump
|
|
13
|
+
|
|
14
|
+
## 0.11.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#8207](https://github.com/scalar/scalar/pull/8207): chore: version bump
|
|
19
|
+
|
|
20
|
+
#### Updated Dependencies
|
|
21
|
+
|
|
22
|
+
- **@scalar/helpers@0.2.14**
|
|
23
|
+
- [#8207](https://github.com/scalar/scalar/pull/8207): chore: version bump
|
|
24
|
+
|
|
25
|
+
## 0.11.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#8151](https://github.com/scalar/scalar/pull/8151): fix: resolve external references on windows
|
|
30
|
+
|
|
31
|
+
#### Updated Dependencies
|
|
32
|
+
|
|
33
|
+
- **@scalar/helpers@0.2.13**
|
|
34
|
+
- [#7826](https://github.com/scalar/scalar/pull/7826): feat: added migrator for v1 local storage to v2 indexdb
|
|
35
|
+
|
|
36
|
+
## 0.11.1
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
#### Updated Dependencies
|
|
41
|
+
|
|
42
|
+
- **@scalar/helpers@0.2.12**
|
|
43
|
+
- [#8178](https://github.com/scalar/scalar/pull/8178): chore: package bump due to ci failure
|
|
44
|
+
|
|
3
45
|
## 0.11.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "pathe";
|
|
2
2
|
import { isHttpUrl } from "../helpers/is-http-url.js";
|
|
3
3
|
const resolveReferencePath = (base, relativePath) => {
|
|
4
4
|
if (isHttpUrl(relativePath)) {
|
|
@@ -6,7 +6,7 @@ const resolveReferencePath = (base, relativePath) => {
|
|
|
6
6
|
}
|
|
7
7
|
if (isHttpUrl(base)) {
|
|
8
8
|
const baseUrl = new URL(base);
|
|
9
|
-
baseUrl.pathname = path.resolve(path.dirname(baseUrl.pathname), relativePath);
|
|
9
|
+
baseUrl.pathname = path.posix.resolve("/", path.dirname(baseUrl.pathname), relativePath);
|
|
10
10
|
return baseUrl.toString();
|
|
11
11
|
}
|
|
12
12
|
return path.resolve(path.dirname(base), relativePath);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/resolve-reference-path.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'pathe'\n\nimport { isHttpUrl } from '@/helpers/is-http-url'\n\n/**\n * Resolves a reference path by combining a base path with a relative path.\n * Handles both remote URLs and local file paths.\n *\n * @param base - The base path (can be a URL or local file path)\n * @param relativePath - The relative path to resolve against the base\n * @returns The resolved absolute path\n * @example\n * // Resolve remote URL\n * resolveReferencePath('https://example.com/api/schema.json', 'user.json')\n * // Returns: 'https://example.com/api/user.json'\n *\n * // Resolve local path\n * resolveReferencePath('/path/to/schema.json', 'user.json')\n * // Returns: '/path/to/user.json'\n */\nexport const resolveReferencePath = (base: string, relativePath: string) => {\n if (isHttpUrl(relativePath)) {\n return relativePath\n }\n\n if (isHttpUrl(base)) {\n const baseUrl = new URL(base)\n baseUrl.pathname = path.posix.resolve('/', path.dirname(baseUrl.pathname), relativePath)\n return baseUrl.toString()\n }\n\n return path.resolve(path.dirname(base), relativePath)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,SAAS,iBAAiB;AAkBnB,MAAM,uBAAuB,CAAC,MAAc,iBAAyB;AAC1E,MAAI,UAAU,YAAY,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,IAAI,GAAG;AACnB,UAAM,UAAU,IAAI,IAAI,IAAI;AAC5B,YAAQ,WAAW,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,QAAQ,QAAQ,GAAG,YAAY;AACvF,WAAO,QAAQ,SAAS;AAAA,EAC1B;AAEA,SAAO,KAAK,QAAQ,KAAK,QAAQ,IAAI,GAAG,YAAY;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-relative-path.d.ts","sourceRoot":"","sources":["../../src/helpers/to-relative-path.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"to-relative-path.d.ts","sourceRoot":"","sources":["../../src/helpers/to-relative-path.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,WAmCzD,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "pathe";
|
|
2
2
|
import { isHttpUrl } from "../helpers/is-http-url.js";
|
|
3
3
|
const toRelativePath = (input, base) => {
|
|
4
4
|
if (isHttpUrl(input) && isHttpUrl(base)) {
|
|
@@ -7,15 +7,14 @@ const toRelativePath = (input, base) => {
|
|
|
7
7
|
if (inputUrl.origin !== baseUrl.origin) {
|
|
8
8
|
return input;
|
|
9
9
|
}
|
|
10
|
-
const baseDir2 = path.dirname(path.resolve(baseUrl.pathname));
|
|
11
|
-
const inputPath2 = path.resolve(inputUrl.pathname);
|
|
12
|
-
return path.relative(baseDir2, inputPath2);
|
|
10
|
+
const baseDir2 = path.dirname(path.posix.resolve("/", baseUrl.pathname));
|
|
11
|
+
const inputPath2 = path.posix.resolve("/", inputUrl.pathname);
|
|
12
|
+
return path.posix.relative(baseDir2, inputPath2);
|
|
13
13
|
}
|
|
14
14
|
if (isHttpUrl(base)) {
|
|
15
15
|
const baseUrl = new URL(base);
|
|
16
|
-
const baseDir2 = path.dirname(path.resolve(baseUrl.pathname));
|
|
17
|
-
|
|
18
|
-
baseUrl.pathname = path.relative(baseDir2, inputPath2);
|
|
16
|
+
const baseDir2 = path.dirname(path.posix.resolve("/", baseUrl.pathname));
|
|
17
|
+
baseUrl.pathname = path.posix.relative(baseDir2, path.posix.resolve("/", input));
|
|
19
18
|
return baseUrl.toString();
|
|
20
19
|
}
|
|
21
20
|
if (isHttpUrl(input)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/to-relative-path.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'pathe'\n\nimport { isHttpUrl } from '@/helpers/is-http-url'\n\n/**\n * Converts an input path or URL to a relative path based on the provided base.\n * Handles both remote URLs and local file system paths.\n * - If both input and base are remote URLs and share the same origin, computes the relative pathname.\n * - If base is a remote URL but input is local, returns a remote URL with a relative pathname.\n * - If input is a remote URL but base is local, returns input as is.\n * - Otherwise, computes the relative path between two local paths.\n */\nexport const toRelativePath = (input: string, base: string) => {\n // Both input and base are remote URLs\n if (isHttpUrl(input) && isHttpUrl(base)) {\n const inputUrl = new URL(input)\n const baseUrl = new URL(base)\n // If origins aren't the same, return input as is\n if (inputUrl.origin !== baseUrl.origin) {\n return input\n }\n\n // Get the directory of the base URL pathname (not the file itself)\n const baseDir = path.dirname(path.posix.resolve('/', baseUrl.pathname))\n const inputPath = path.posix.resolve('/', inputUrl.pathname)\n // Return the relative path from baseDir to inputPath\n return path.posix.relative(baseDir, inputPath)\n }\n\n // Base is a remote URL, input is a local path\n if (isHttpUrl(base)) {\n const baseUrl = new URL(base)\n const baseDir = path.dirname(path.posix.resolve('/', baseUrl.pathname))\n // Set the pathname of the base URL to the relative path and return the URL as a string\n baseUrl.pathname = path.posix.relative(baseDir, path.posix.resolve('/', input))\n return baseUrl.toString()\n }\n\n // Input is a remote URL, base is a local path; just return input\n if (isHttpUrl(input)) {\n return input\n }\n\n // Both input and base are local paths; return the relative path\n const baseDir = path.dirname(path.resolve(base))\n const inputPath = path.resolve(input)\n return path.relative(baseDir, inputPath)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,SAAS,iBAAiB;AAUnB,MAAM,iBAAiB,CAAC,OAAe,SAAiB;AAE7D,MAAI,UAAU,KAAK,KAAK,UAAU,IAAI,GAAG;AACvC,UAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,UAAM,UAAU,IAAI,IAAI,IAAI;AAE5B,QAAI,SAAS,WAAW,QAAQ,QAAQ;AACtC,aAAO;AAAA,IACT;AAGA,UAAMA,WAAU,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,QAAQ,QAAQ,CAAC;AACtE,UAAMC,aAAY,KAAK,MAAM,QAAQ,KAAK,SAAS,QAAQ;AAE3D,WAAO,KAAK,MAAM,SAASD,UAASC,UAAS;AAAA,EAC/C;AAGA,MAAI,UAAU,IAAI,GAAG;AACnB,UAAM,UAAU,IAAI,IAAI,IAAI;AAC5B,UAAMD,WAAU,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,QAAQ,QAAQ,CAAC;AAEtE,YAAQ,WAAW,KAAK,MAAM,SAASA,UAAS,KAAK,MAAM,QAAQ,KAAK,KAAK,CAAC;AAC9E,WAAO,QAAQ,SAAS;AAAA,EAC1B;AAGA,MAAI,UAAU,KAAK,GAAG;AACpB,WAAO;AAAA,EACT;AAGA,QAAM,UAAU,KAAK,QAAQ,KAAK,QAAQ,IAAI,CAAC;AAC/C,QAAM,YAAY,KAAK,QAAQ,KAAK;AACpC,SAAO,KAAK,SAAS,SAAS,SAAS;AACzC;",
|
|
6
6
|
"names": ["baseDir", "inputPath"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/json-magic"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.11.
|
|
13
|
+
"version": "0.11.4",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -77,8 +77,9 @@
|
|
|
77
77
|
"CHANGELOG.md"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
+
"pathe": "^2.0.3",
|
|
80
81
|
"yaml": "^2.8.0",
|
|
81
|
-
"@scalar/helpers": "0.2.
|
|
82
|
+
"@scalar/helpers": "0.2.15"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"fastify": "^5.3.3",
|