@scalar/json-magic 0.7.0 → 0.8.1
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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +20 -0
- package/dist/bundle/bundle.d.ts.map +1 -1
- package/dist/bundle/bundle.js +1 -1
- package/dist/bundle/bundle.js.map +2 -2
- package/dist/bundle/value-generator.d.ts +6 -4
- package/dist/bundle/value-generator.d.ts.map +1 -1
- package/dist/bundle/value-generator.js +2 -5
- package/dist/bundle/value-generator.js.map +2 -2
- package/dist/helpers/generate-hash.d.ts +11 -0
- package/dist/helpers/generate-hash.d.ts.map +1 -0
- package/dist/helpers/generate-hash.js +16 -0
- package/dist/helpers/generate-hash.js.map +7 -0
- package/esbuild.ts +1 -0
- package/package.json +8 -2
- package/src/bundle/bundle.test.ts +17 -17
- package/src/bundle/bundle.ts +2 -1
- package/src/bundle/value-generator.ts +11 -15
- package/src/dereference/dereference.test.ts +4 -4
- package/src/helpers/generate-hash.test.ts +74 -0
- package/src/helpers/generate-hash.ts +29 -0
- package/dist/polyfills/index.d.ts +0 -2
- package/dist/polyfills/index.d.ts.map +0 -1
- package/dist/polyfills/index.js +0 -25
- package/dist/polyfills/index.js.map +0 -7
- package/dist/polyfills/path.d.ts +0 -24
- package/dist/polyfills/path.d.ts.map +0 -1
- package/dist/polyfills/path.js +0 -174
- package/dist/polyfills/path.js.map +0 -7
- package/src/polyfills/index.ts +0 -12
- package/src/polyfills/path.ts +0 -248
package/src/polyfills/path.ts
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
4
|
-
//
|
|
5
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
-
// copy of this software and associated documentation files (the
|
|
7
|
-
// "Software"), to deal in the Software without restriction, including
|
|
8
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
10
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
11
|
-
// following conditions:
|
|
12
|
-
//
|
|
13
|
-
// The above copyright notice and this permission notice shall be included
|
|
14
|
-
// in all copies or substantial portions of the Software.
|
|
15
|
-
//
|
|
16
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
19
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
22
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
// resolves . and .. elements in a path array with directory names there
|
|
25
|
-
// must be no slashes, empty elements, or device names (c:\) in the array
|
|
26
|
-
// (so also no leading and trailing slashes - it does not distinguish
|
|
27
|
-
// relative and absolute paths)
|
|
28
|
-
function normalizeArray(parts, allowAboveRoot) {
|
|
29
|
-
// if the path tries to go above the root, `up` ends up > 0
|
|
30
|
-
let up = 0
|
|
31
|
-
for (let i = parts.length - 1; i >= 0; i--) {
|
|
32
|
-
const last = parts[i]
|
|
33
|
-
if (last === '.') {
|
|
34
|
-
parts.splice(i, 1)
|
|
35
|
-
} else if (last === '..') {
|
|
36
|
-
parts.splice(i, 1)
|
|
37
|
-
up++
|
|
38
|
-
} else if (up) {
|
|
39
|
-
parts.splice(i, 1)
|
|
40
|
-
up--
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// if the path is allowed to go above the root, restore leading ..s
|
|
45
|
-
if (allowAboveRoot) {
|
|
46
|
-
for (; up--; up) {
|
|
47
|
-
parts.unshift('..')
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return parts
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Split a filename into [root, dir, basename, ext], unix version
|
|
55
|
-
// 'root' is just a slash, or nothing.
|
|
56
|
-
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/
|
|
57
|
-
const splitPath = (filename) => splitPathRe.exec(filename).slice(1)
|
|
58
|
-
|
|
59
|
-
// path.resolve([from ...], to)
|
|
60
|
-
// posix version
|
|
61
|
-
export function resolve(...parameters) {
|
|
62
|
-
let resolvedPath = '',
|
|
63
|
-
resolvedAbsolute = false
|
|
64
|
-
|
|
65
|
-
for (let i = parameters.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
66
|
-
const path = i >= 0 ? parameters[i] : '/'
|
|
67
|
-
|
|
68
|
-
// Skip empty and invalid entries
|
|
69
|
-
if (typeof path !== 'string') {
|
|
70
|
-
throw new TypeError('Arguments to path.resolve must be strings')
|
|
71
|
-
}
|
|
72
|
-
if (!path) {
|
|
73
|
-
continue
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
resolvedPath = path + '/' + resolvedPath
|
|
77
|
-
resolvedAbsolute = path.charAt(0) === '/'
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// At this point the path should be resolved to a full absolute path, but
|
|
81
|
-
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
82
|
-
|
|
83
|
-
// Normalize the path
|
|
84
|
-
resolvedPath = normalizeArray(
|
|
85
|
-
filter(resolvedPath.split('/'), (p) => !!p),
|
|
86
|
-
!resolvedAbsolute,
|
|
87
|
-
).join('/')
|
|
88
|
-
|
|
89
|
-
return (resolvedAbsolute ? '/' : '') + resolvedPath || '.'
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// path.normalize(path)
|
|
93
|
-
// posix version
|
|
94
|
-
export function normalize(path) {
|
|
95
|
-
const isPathAbsolute = isAbsolute(path),
|
|
96
|
-
trailingSlash = substr(path, -1) === '/'
|
|
97
|
-
|
|
98
|
-
// Normalize the path
|
|
99
|
-
path = normalizeArray(
|
|
100
|
-
filter(path.split('/'), (p) => !!p),
|
|
101
|
-
!isPathAbsolute,
|
|
102
|
-
).join('/')
|
|
103
|
-
|
|
104
|
-
if (!path && !isPathAbsolute) {
|
|
105
|
-
path = '.'
|
|
106
|
-
}
|
|
107
|
-
if (path && trailingSlash) {
|
|
108
|
-
path += '/'
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return (isPathAbsolute ? '/' : '') + path
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// posix version
|
|
115
|
-
export function isAbsolute(path) {
|
|
116
|
-
return path.charAt(0) === '/'
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// posix version
|
|
120
|
-
export function join(...paths: string[]) {
|
|
121
|
-
return normalize(
|
|
122
|
-
filter(paths, (p, _index) => {
|
|
123
|
-
if (typeof p !== 'string') {
|
|
124
|
-
throw new TypeError('Arguments to path.join must be strings')
|
|
125
|
-
}
|
|
126
|
-
return p
|
|
127
|
-
}).join('/'),
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// path.relative(from, to)
|
|
132
|
-
// posix version
|
|
133
|
-
export function relative(from, to) {
|
|
134
|
-
from = resolve(from).substr(1)
|
|
135
|
-
to = resolve(to).substr(1)
|
|
136
|
-
|
|
137
|
-
function trim(arr) {
|
|
138
|
-
let start = 0
|
|
139
|
-
for (; start < arr.length; start++) {
|
|
140
|
-
if (arr[start] !== '') {
|
|
141
|
-
break
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let end = arr.length - 1
|
|
146
|
-
for (; end >= 0; end--) {
|
|
147
|
-
if (arr[end] !== '') {
|
|
148
|
-
break
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (start > end) {
|
|
153
|
-
return []
|
|
154
|
-
}
|
|
155
|
-
return arr.slice(start, end - start + 1)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const fromParts = trim(from.split('/'))
|
|
159
|
-
const toParts = trim(to.split('/'))
|
|
160
|
-
|
|
161
|
-
const length = Math.min(fromParts.length, toParts.length)
|
|
162
|
-
let samePartsLength = length
|
|
163
|
-
for (let i = 0; i < length; i++) {
|
|
164
|
-
if (fromParts[i] !== toParts[i]) {
|
|
165
|
-
samePartsLength = i
|
|
166
|
-
break
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let outputParts = []
|
|
171
|
-
for (let i = samePartsLength; i < fromParts.length; i++) {
|
|
172
|
-
outputParts.push('..')
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
outputParts = outputParts.concat(toParts.slice(samePartsLength))
|
|
176
|
-
|
|
177
|
-
return outputParts.join('/')
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export const sep = '/'
|
|
181
|
-
export const delimiter = ':'
|
|
182
|
-
|
|
183
|
-
export function dirname(path) {
|
|
184
|
-
const result = splitPath(path),
|
|
185
|
-
root = result[0]
|
|
186
|
-
|
|
187
|
-
let dir = result[1]
|
|
188
|
-
|
|
189
|
-
if (!root && !dir) {
|
|
190
|
-
// No dirname whatsoever
|
|
191
|
-
return '.'
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (dir) {
|
|
195
|
-
// It has a dirname, strip trailing slash
|
|
196
|
-
dir = dir.substr(0, dir.length - 1)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return root + dir
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function basename(path, ext) {
|
|
203
|
-
let f = splitPath(path)[2]
|
|
204
|
-
// TODO: make this comparison case-insensitive on windows?
|
|
205
|
-
if (ext && f.substr(-1 * ext.length) === ext) {
|
|
206
|
-
f = f.substr(0, f.length - ext.length)
|
|
207
|
-
}
|
|
208
|
-
return f
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function extname(path) {
|
|
212
|
-
return splitPath(path)[3]
|
|
213
|
-
}
|
|
214
|
-
export default {
|
|
215
|
-
extname: extname,
|
|
216
|
-
basename: basename,
|
|
217
|
-
dirname: dirname,
|
|
218
|
-
sep: sep,
|
|
219
|
-
delimiter: delimiter,
|
|
220
|
-
relative: relative,
|
|
221
|
-
join: join,
|
|
222
|
-
isAbsolute: isAbsolute,
|
|
223
|
-
normalize: normalize,
|
|
224
|
-
resolve: resolve,
|
|
225
|
-
}
|
|
226
|
-
function filter(xs, f) {
|
|
227
|
-
if (xs.filter) {
|
|
228
|
-
return xs.filter(f)
|
|
229
|
-
}
|
|
230
|
-
const res = []
|
|
231
|
-
for (let i = 0; i < xs.length; i++) {
|
|
232
|
-
if (f(xs[i], i, xs)) {
|
|
233
|
-
res.push(xs[i])
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return res
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// String.prototype.substr - negative index don't work in IE8
|
|
240
|
-
const substr =
|
|
241
|
-
'ab'.substr(-1) === 'b'
|
|
242
|
-
? (str, start, len) => str.substr(start, len)
|
|
243
|
-
: (str, start, len) => {
|
|
244
|
-
if (start < 0) {
|
|
245
|
-
start = str.length + start
|
|
246
|
-
}
|
|
247
|
-
return str.substr(start, len)
|
|
248
|
-
}
|