@affectively/aeon-pages-runtime 0.3.0 → 0.5.0

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.
@@ -0,0 +1,321 @@
1
+ // node:path
2
+ function assertPath(path) {
3
+ if (typeof path !== "string")
4
+ throw TypeError("Path must be a string. Received " + JSON.stringify(path));
5
+ }
6
+ function normalizeStringPosix(path, allowAboveRoot) {
7
+ var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
8
+ for (var i = 0;i <= path.length; ++i) {
9
+ if (i < path.length)
10
+ code = path.charCodeAt(i);
11
+ else if (code === 47)
12
+ break;
13
+ else
14
+ code = 47;
15
+ if (code === 47) {
16
+ if (lastSlash === i - 1 || dots === 1)
17
+ ;
18
+ else if (lastSlash !== i - 1 && dots === 2) {
19
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
20
+ if (res.length > 2) {
21
+ var lastSlashIndex = res.lastIndexOf("/");
22
+ if (lastSlashIndex !== res.length - 1) {
23
+ if (lastSlashIndex === -1)
24
+ res = "", lastSegmentLength = 0;
25
+ else
26
+ res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
27
+ lastSlash = i, dots = 0;
28
+ continue;
29
+ }
30
+ } else if (res.length === 2 || res.length === 1) {
31
+ res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
32
+ continue;
33
+ }
34
+ }
35
+ if (allowAboveRoot) {
36
+ if (res.length > 0)
37
+ res += "/..";
38
+ else
39
+ res = "..";
40
+ lastSegmentLength = 2;
41
+ }
42
+ } else {
43
+ if (res.length > 0)
44
+ res += "/" + path.slice(lastSlash + 1, i);
45
+ else
46
+ res = path.slice(lastSlash + 1, i);
47
+ lastSegmentLength = i - lastSlash - 1;
48
+ }
49
+ lastSlash = i, dots = 0;
50
+ } else if (code === 46 && dots !== -1)
51
+ ++dots;
52
+ else
53
+ dots = -1;
54
+ }
55
+ return res;
56
+ }
57
+ function _format(sep, pathObject) {
58
+ var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
59
+ if (!dir)
60
+ return base;
61
+ if (dir === pathObject.root)
62
+ return dir + base;
63
+ return dir + sep + base;
64
+ }
65
+ function resolve() {
66
+ var resolvedPath = "", resolvedAbsolute = false, cwd;
67
+ for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
68
+ var path;
69
+ if (i >= 0)
70
+ path = arguments[i];
71
+ else {
72
+ if (cwd === undefined)
73
+ cwd = process.cwd();
74
+ path = cwd;
75
+ }
76
+ if (assertPath(path), path.length === 0)
77
+ continue;
78
+ resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
79
+ }
80
+ if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
81
+ if (resolvedPath.length > 0)
82
+ return "/" + resolvedPath;
83
+ else
84
+ return "/";
85
+ else if (resolvedPath.length > 0)
86
+ return resolvedPath;
87
+ else
88
+ return ".";
89
+ }
90
+ function normalize(path) {
91
+ if (assertPath(path), path.length === 0)
92
+ return ".";
93
+ var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
94
+ if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
95
+ path = ".";
96
+ if (path.length > 0 && trailingSeparator)
97
+ path += "/";
98
+ if (isAbsolute)
99
+ return "/" + path;
100
+ return path;
101
+ }
102
+ function isAbsolute(path) {
103
+ return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
104
+ }
105
+ function join() {
106
+ if (arguments.length === 0)
107
+ return ".";
108
+ var joined;
109
+ for (var i = 0;i < arguments.length; ++i) {
110
+ var arg = arguments[i];
111
+ if (assertPath(arg), arg.length > 0)
112
+ if (joined === undefined)
113
+ joined = arg;
114
+ else
115
+ joined += "/" + arg;
116
+ }
117
+ if (joined === undefined)
118
+ return ".";
119
+ return normalize(joined);
120
+ }
121
+ function relative(from, to) {
122
+ if (assertPath(from), assertPath(to), from === to)
123
+ return "";
124
+ if (from = resolve(from), to = resolve(to), from === to)
125
+ return "";
126
+ var fromStart = 1;
127
+ for (;fromStart < from.length; ++fromStart)
128
+ if (from.charCodeAt(fromStart) !== 47)
129
+ break;
130
+ var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
131
+ for (;toStart < to.length; ++toStart)
132
+ if (to.charCodeAt(toStart) !== 47)
133
+ break;
134
+ var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
135
+ for (;i <= length; ++i) {
136
+ if (i === length) {
137
+ if (toLen > length) {
138
+ if (to.charCodeAt(toStart + i) === 47)
139
+ return to.slice(toStart + i + 1);
140
+ else if (i === 0)
141
+ return to.slice(toStart + i);
142
+ } else if (fromLen > length) {
143
+ if (from.charCodeAt(fromStart + i) === 47)
144
+ lastCommonSep = i;
145
+ else if (i === 0)
146
+ lastCommonSep = 0;
147
+ }
148
+ break;
149
+ }
150
+ var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
151
+ if (fromCode !== toCode)
152
+ break;
153
+ else if (fromCode === 47)
154
+ lastCommonSep = i;
155
+ }
156
+ var out = "";
157
+ for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
158
+ if (i === fromEnd || from.charCodeAt(i) === 47)
159
+ if (out.length === 0)
160
+ out += "..";
161
+ else
162
+ out += "/..";
163
+ if (out.length > 0)
164
+ return out + to.slice(toStart + lastCommonSep);
165
+ else {
166
+ if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
167
+ ++toStart;
168
+ return to.slice(toStart);
169
+ }
170
+ }
171
+ function _makeLong(path) {
172
+ return path;
173
+ }
174
+ function dirname(path) {
175
+ if (assertPath(path), path.length === 0)
176
+ return ".";
177
+ var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
178
+ for (var i = path.length - 1;i >= 1; --i)
179
+ if (code = path.charCodeAt(i), code === 47) {
180
+ if (!matchedSlash) {
181
+ end = i;
182
+ break;
183
+ }
184
+ } else
185
+ matchedSlash = false;
186
+ if (end === -1)
187
+ return hasRoot ? "/" : ".";
188
+ if (hasRoot && end === 1)
189
+ return "//";
190
+ return path.slice(0, end);
191
+ }
192
+ function basename(path, ext) {
193
+ if (ext !== undefined && typeof ext !== "string")
194
+ throw TypeError('"ext" argument must be a string');
195
+ assertPath(path);
196
+ var start = 0, end = -1, matchedSlash = true, i;
197
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
198
+ if (ext.length === path.length && ext === path)
199
+ return "";
200
+ var extIdx = ext.length - 1, firstNonSlashEnd = -1;
201
+ for (i = path.length - 1;i >= 0; --i) {
202
+ var code = path.charCodeAt(i);
203
+ if (code === 47) {
204
+ if (!matchedSlash) {
205
+ start = i + 1;
206
+ break;
207
+ }
208
+ } else {
209
+ if (firstNonSlashEnd === -1)
210
+ matchedSlash = false, firstNonSlashEnd = i + 1;
211
+ if (extIdx >= 0)
212
+ if (code === ext.charCodeAt(extIdx)) {
213
+ if (--extIdx === -1)
214
+ end = i;
215
+ } else
216
+ extIdx = -1, end = firstNonSlashEnd;
217
+ }
218
+ }
219
+ if (start === end)
220
+ end = firstNonSlashEnd;
221
+ else if (end === -1)
222
+ end = path.length;
223
+ return path.slice(start, end);
224
+ } else {
225
+ for (i = path.length - 1;i >= 0; --i)
226
+ if (path.charCodeAt(i) === 47) {
227
+ if (!matchedSlash) {
228
+ start = i + 1;
229
+ break;
230
+ }
231
+ } else if (end === -1)
232
+ matchedSlash = false, end = i + 1;
233
+ if (end === -1)
234
+ return "";
235
+ return path.slice(start, end);
236
+ }
237
+ }
238
+ function extname(path) {
239
+ assertPath(path);
240
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
241
+ for (var i = path.length - 1;i >= 0; --i) {
242
+ var code = path.charCodeAt(i);
243
+ if (code === 47) {
244
+ if (!matchedSlash) {
245
+ startPart = i + 1;
246
+ break;
247
+ }
248
+ continue;
249
+ }
250
+ if (end === -1)
251
+ matchedSlash = false, end = i + 1;
252
+ if (code === 46) {
253
+ if (startDot === -1)
254
+ startDot = i;
255
+ else if (preDotState !== 1)
256
+ preDotState = 1;
257
+ } else if (startDot !== -1)
258
+ preDotState = -1;
259
+ }
260
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
261
+ return "";
262
+ return path.slice(startDot, end);
263
+ }
264
+ function format(pathObject) {
265
+ if (pathObject === null || typeof pathObject !== "object")
266
+ throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
267
+ return _format("/", pathObject);
268
+ }
269
+ function parse(path) {
270
+ assertPath(path);
271
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
272
+ if (path.length === 0)
273
+ return ret;
274
+ var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
275
+ if (isAbsolute2)
276
+ ret.root = "/", start = 1;
277
+ else
278
+ start = 0;
279
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
280
+ for (;i >= start; --i) {
281
+ if (code = path.charCodeAt(i), code === 47) {
282
+ if (!matchedSlash) {
283
+ startPart = i + 1;
284
+ break;
285
+ }
286
+ continue;
287
+ }
288
+ if (end === -1)
289
+ matchedSlash = false, end = i + 1;
290
+ if (code === 46) {
291
+ if (startDot === -1)
292
+ startDot = i;
293
+ else if (preDotState !== 1)
294
+ preDotState = 1;
295
+ } else if (startDot !== -1)
296
+ preDotState = -1;
297
+ }
298
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
299
+ if (end !== -1)
300
+ if (startPart === 0 && isAbsolute2)
301
+ ret.base = ret.name = path.slice(1, end);
302
+ else
303
+ ret.base = ret.name = path.slice(startPart, end);
304
+ } else {
305
+ if (startPart === 0 && isAbsolute2)
306
+ ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
307
+ else
308
+ ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
309
+ ret.ext = path.slice(startDot, end);
310
+ }
311
+ if (startPart > 0)
312
+ ret.dir = path.slice(0, startPart - 1);
313
+ else if (isAbsolute2)
314
+ ret.dir = "/";
315
+ return ret;
316
+ }
317
+ var sep = "/";
318
+ var delimiter = ":";
319
+ var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
320
+ var path_default = posix;
321
+ export { resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, posix, path_default };