ventojs 0.8.0 → 0.9.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.
Files changed (136) hide show
  1. package/README.md +7 -61
  2. package/esm/deps/deno.land/std@0.201.0/html/entities.d.ts +38 -0
  3. package/esm/deps/deno.land/std@0.201.0/html/entities.js +76 -0
  4. package/esm/deps/deno.land/std@0.201.0/html/mod.d.ts +6 -0
  5. package/esm/deps/deno.land/std@0.201.0/html/mod.js +8 -0
  6. package/esm/deps.d.ts +1 -0
  7. package/esm/deps.js +1 -0
  8. package/esm/mod.d.ts +1 -0
  9. package/esm/mod.js +1 -0
  10. package/esm/plugins/escape.js +2 -12
  11. package/esm/plugins/export.js +5 -4
  12. package/esm/plugins/import.js +4 -11
  13. package/esm/plugins/include.js +3 -2
  14. package/esm/plugins/layout.js +4 -3
  15. package/esm/plugins/set.js +5 -4
  16. package/esm/plugins/unescape.js +2 -12
  17. package/esm/src/environment.d.ts +1 -0
  18. package/esm/src/environment.js +9 -12
  19. package/package.json +4 -2
  20. package/script/_dnt.shims.d.ts +5 -0
  21. package/script/_dnt.shims.js +65 -0
  22. package/script/deps/deno.land/std@0.201.0/assert/assert.d.ts +2 -0
  23. package/script/deps/deno.land/std@0.201.0/assert/assert.js +12 -0
  24. package/script/deps/deno.land/std@0.201.0/assert/assertion_error.d.ts +4 -0
  25. package/script/deps/deno.land/std@0.201.0/assert/assertion_error.js +11 -0
  26. package/script/deps/deno.land/std@0.201.0/html/entities.d.ts +38 -0
  27. package/script/deps/deno.land/std@0.201.0/html/entities.js +81 -0
  28. package/script/deps/deno.land/std@0.201.0/html/mod.d.ts +6 -0
  29. package/script/deps/deno.land/std@0.201.0/html/mod.js +24 -0
  30. package/script/deps/deno.land/std@0.201.0/path/_basename.d.ts +16 -0
  31. package/script/deps/deno.land/std@0.201.0/path/_basename.js +83 -0
  32. package/script/deps/deno.land/std@0.201.0/path/_constants.d.ts +39 -0
  33. package/script/deps/deno.land/std@0.201.0/path/_constants.js +49 -0
  34. package/script/deps/deno.land/std@0.201.0/path/_dirname.d.ts +10 -0
  35. package/script/deps/deno.land/std@0.201.0/path/_dirname.js +137 -0
  36. package/script/deps/deno.land/std@0.201.0/path/_extname.d.ts +12 -0
  37. package/script/deps/deno.land/std@0.201.0/path/_extname.js +126 -0
  38. package/script/deps/deno.land/std@0.201.0/path/_format.d.ts +11 -0
  39. package/script/deps/deno.land/std@0.201.0/path/_format.js +40 -0
  40. package/script/deps/deno.land/std@0.201.0/path/_from_file_url.d.ts +25 -0
  41. package/script/deps/deno.land/std@0.201.0/path/_from_file_url.js +51 -0
  42. package/script/deps/deno.land/std@0.201.0/path/_interface.d.ts +26 -0
  43. package/script/deps/deno.land/std@0.201.0/path/_interface.js +4 -0
  44. package/script/deps/deno.land/std@0.201.0/path/_is_absolute.d.ts +10 -0
  45. package/script/deps/deno.land/std@0.201.0/path/_is_absolute.js +39 -0
  46. package/script/deps/deno.land/std@0.201.0/path/_join.d.ts +10 -0
  47. package/script/deps/deno.land/std@0.201.0/path/_join.js +98 -0
  48. package/script/deps/deno.land/std@0.201.0/path/_normalize.d.ts +14 -0
  49. package/script/deps/deno.land/std@0.201.0/path/_normalize.js +158 -0
  50. package/script/deps/deno.land/std@0.201.0/path/_os.d.ts +4 -0
  51. package/script/deps/deno.land/std@0.201.0/path/_os.js +44 -0
  52. package/script/deps/deno.land/std@0.201.0/path/_parse.d.ts +11 -0
  53. package/script/deps/deno.land/std@0.201.0/path/_parse.js +255 -0
  54. package/script/deps/deno.land/std@0.201.0/path/_relative.d.ts +19 -0
  55. package/script/deps/deno.land/std@0.201.0/path/_relative.js +221 -0
  56. package/script/deps/deno.land/std@0.201.0/path/_resolve.d.ts +10 -0
  57. package/script/deps/deno.land/std@0.201.0/path/_resolve.js +211 -0
  58. package/script/deps/deno.land/std@0.201.0/path/_to_file_url.d.ts +25 -0
  59. package/script/deps/deno.land/std@0.201.0/path/_to_file_url.js +66 -0
  60. package/script/deps/deno.land/std@0.201.0/path/_to_namespaced_path.d.ts +10 -0
  61. package/script/deps/deno.land/std@0.201.0/path/_to_namespaced_path.js +51 -0
  62. package/script/deps/deno.land/std@0.201.0/path/_util.d.ts +6 -0
  63. package/script/deps/deno.land/std@0.201.0/path/_util.js +116 -0
  64. package/script/deps/deno.land/std@0.201.0/path/basename.d.ts +8 -0
  65. package/script/deps/deno.land/std@0.201.0/path/basename.js +20 -0
  66. package/script/deps/deno.land/std@0.201.0/path/common.d.ts +13 -0
  67. package/script/deps/deno.land/std@0.201.0/path/common.js +40 -0
  68. package/script/deps/deno.land/std@0.201.0/path/dirname.d.ts +5 -0
  69. package/script/deps/deno.land/std@0.201.0/path/dirname.js +15 -0
  70. package/script/deps/deno.land/std@0.201.0/path/extname.d.ts +6 -0
  71. package/script/deps/deno.land/std@0.201.0/path/extname.js +16 -0
  72. package/script/deps/deno.land/std@0.201.0/path/format.d.ts +6 -0
  73. package/script/deps/deno.land/std@0.201.0/path/format.js +15 -0
  74. package/script/deps/deno.land/std@0.201.0/path/from_file_url.d.ts +18 -0
  75. package/script/deps/deno.land/std@0.201.0/path/from_file_url.js +27 -0
  76. package/script/deps/deno.land/std@0.201.0/path/glob.d.ts +83 -0
  77. package/script/deps/deno.land/std@0.201.0/path/glob.js +391 -0
  78. package/script/deps/deno.land/std@0.201.0/path/is_absolute.d.ts +5 -0
  79. package/script/deps/deno.land/std@0.201.0/path/is_absolute.js +15 -0
  80. package/script/deps/deno.land/std@0.201.0/path/join.d.ts +5 -0
  81. package/script/deps/deno.land/std@0.201.0/path/join.js +15 -0
  82. package/script/deps/deno.land/std@0.201.0/path/mod.d.ts +22 -0
  83. package/script/deps/deno.land/std@0.201.0/path/mod.js +74 -0
  84. package/script/deps/deno.land/std@0.201.0/path/normalize.d.ts +7 -0
  85. package/script/deps/deno.land/std@0.201.0/path/normalize.js +17 -0
  86. package/script/deps/deno.land/std@0.201.0/path/parse.d.ts +6 -0
  87. package/script/deps/deno.land/std@0.201.0/path/parse.js +15 -0
  88. package/script/deps/deno.land/std@0.201.0/path/posix.d.ts +15 -0
  89. package/script/deps/deno.land/std@0.201.0/path/posix.js +35 -0
  90. package/script/deps/deno.land/std@0.201.0/path/relative.d.ts +12 -0
  91. package/script/deps/deno.land/std@0.201.0/path/relative.js +22 -0
  92. package/script/deps/deno.land/std@0.201.0/path/resolve.d.ts +5 -0
  93. package/script/deps/deno.land/std@0.201.0/path/resolve.js +17 -0
  94. package/script/deps/deno.land/std@0.201.0/path/separator.d.ts +2 -0
  95. package/script/deps/deno.land/std@0.201.0/path/separator.js +8 -0
  96. package/script/deps/deno.land/std@0.201.0/path/to_file_url.d.ts +18 -0
  97. package/script/deps/deno.land/std@0.201.0/path/to_file_url.js +27 -0
  98. package/script/deps/deno.land/std@0.201.0/path/to_namespaced_path.d.ts +5 -0
  99. package/script/deps/deno.land/std@0.201.0/path/to_namespaced_path.js +17 -0
  100. package/script/deps/deno.land/std@0.201.0/path/win32.d.ts +15 -0
  101. package/script/deps/deno.land/std@0.201.0/path/win32.js +35 -0
  102. package/script/deps.d.ts +2 -0
  103. package/script/deps.js +28 -0
  104. package/script/mod.d.ts +9 -0
  105. package/script/mod.js +69 -0
  106. package/script/package.json +3 -0
  107. package/script/plugins/echo.d.ts +2 -0
  108. package/script/plugins/echo.js +16 -0
  109. package/script/plugins/escape.d.ts +2 -0
  110. package/script/plugins/escape.js +9 -0
  111. package/script/plugins/export.d.ts +2 -0
  112. package/script/plugins/export.js +50 -0
  113. package/script/plugins/for.d.ts +2 -0
  114. package/script/plugins/for.js +51 -0
  115. package/script/plugins/function.d.ts +2 -0
  116. package/script/plugins/function.js +40 -0
  117. package/script/plugins/if.d.ts +2 -0
  118. package/script/plugins/if.js +35 -0
  119. package/script/plugins/import.d.ts +2 -0
  120. package/script/plugins/import.js +20 -0
  121. package/script/plugins/include.d.ts +2 -0
  122. package/script/plugins/include.js +26 -0
  123. package/script/plugins/js.d.ts +2 -0
  124. package/script/plugins/js.js +14 -0
  125. package/script/plugins/layout.d.ts +2 -0
  126. package/script/plugins/layout.js +37 -0
  127. package/script/plugins/set.d.ts +2 -0
  128. package/script/plugins/set.js +48 -0
  129. package/script/plugins/unescape.d.ts +2 -0
  130. package/script/plugins/unescape.js +9 -0
  131. package/script/src/environment.d.ts +42 -0
  132. package/script/src/environment.js +176 -0
  133. package/script/src/loader.d.ts +14 -0
  134. package/script/src/loader.js +46 -0
  135. package/script/src/tokenizer.d.ts +8 -0
  136. package/script/src/tokenizer.js +190 -0
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.windowsResolve = exports.posixResolve = void 0;
27
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
28
+ // This module is browser compatible.
29
+ const dntShim = __importStar(require("../../../../_dnt.shims.js"));
30
+ const _constants_js_1 = require("./_constants.js");
31
+ const _util_js_1 = require("./_util.js");
32
+ /**
33
+ * Resolves path segments into a `path`
34
+ * @param pathSegments to process to path
35
+ */
36
+ function posixResolve(...pathSegments) {
37
+ let resolvedPath = "";
38
+ let resolvedAbsolute = false;
39
+ for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
40
+ let path;
41
+ if (i >= 0)
42
+ path = pathSegments[i];
43
+ else {
44
+ // deno-lint-ignore no-explicit-any
45
+ const { Deno } = dntShim.dntGlobalThis;
46
+ if (typeof Deno?.cwd !== "function") {
47
+ throw new TypeError("Resolved a relative path without a CWD.");
48
+ }
49
+ path = Deno.cwd();
50
+ }
51
+ (0, _util_js_1.assertPath)(path);
52
+ // Skip empty entries
53
+ if (path.length === 0) {
54
+ continue;
55
+ }
56
+ resolvedPath = `${path}/${resolvedPath}`;
57
+ resolvedAbsolute = (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0));
58
+ }
59
+ // At this point the path should be resolved to a full absolute path, but
60
+ // handle relative paths to be safe (might happen when Deno.cwd() fails)
61
+ // Normalize the path
62
+ resolvedPath = (0, _util_js_1.normalizeString)(resolvedPath, !resolvedAbsolute, "/", _util_js_1.isPosixPathSeparator);
63
+ if (resolvedAbsolute) {
64
+ if (resolvedPath.length > 0)
65
+ return `/${resolvedPath}`;
66
+ else
67
+ return "/";
68
+ }
69
+ else if (resolvedPath.length > 0)
70
+ return resolvedPath;
71
+ else
72
+ return ".";
73
+ }
74
+ exports.posixResolve = posixResolve;
75
+ /**
76
+ * Resolves path segments into a `path`
77
+ * @param pathSegments to process to path
78
+ */
79
+ function windowsResolve(...pathSegments) {
80
+ let resolvedDevice = "";
81
+ let resolvedTail = "";
82
+ let resolvedAbsolute = false;
83
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
84
+ let path;
85
+ // deno-lint-ignore no-explicit-any
86
+ const { Deno } = dntShim.dntGlobalThis;
87
+ if (i >= 0) {
88
+ path = pathSegments[i];
89
+ }
90
+ else if (!resolvedDevice) {
91
+ if (typeof Deno?.cwd !== "function") {
92
+ throw new TypeError("Resolved a drive-letter-less path without a CWD.");
93
+ }
94
+ path = Deno.cwd();
95
+ }
96
+ else {
97
+ if (typeof Deno?.env?.get !== "function" || typeof Deno?.cwd !== "function") {
98
+ throw new TypeError("Resolved a relative path without a CWD.");
99
+ }
100
+ path = Deno.cwd();
101
+ // Verify that a cwd was found and that it actually points
102
+ // to our drive. If not, default to the drive's root.
103
+ if (path === undefined ||
104
+ path.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`) {
105
+ path = `${resolvedDevice}\\`;
106
+ }
107
+ }
108
+ (0, _util_js_1.assertPath)(path);
109
+ const len = path.length;
110
+ // Skip empty entries
111
+ if (len === 0)
112
+ continue;
113
+ let rootEnd = 0;
114
+ let device = "";
115
+ let isAbsolute = false;
116
+ const code = path.charCodeAt(0);
117
+ // Try to match a root
118
+ if (len > 1) {
119
+ if ((0, _util_js_1.isPathSeparator)(code)) {
120
+ // Possible UNC root
121
+ // If we started with a separator, we know we at least have an
122
+ // absolute path of some kind (UNC or otherwise)
123
+ isAbsolute = true;
124
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(1))) {
125
+ // Matched double path separator at beginning
126
+ let j = 2;
127
+ let last = j;
128
+ // Match 1 or more non-path separators
129
+ for (; j < len; ++j) {
130
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
131
+ break;
132
+ }
133
+ if (j < len && j !== last) {
134
+ const firstPart = path.slice(last, j);
135
+ // Matched!
136
+ last = j;
137
+ // Match 1 or more path separators
138
+ for (; j < len; ++j) {
139
+ if (!(0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
140
+ break;
141
+ }
142
+ if (j < len && j !== last) {
143
+ // Matched!
144
+ last = j;
145
+ // Match 1 or more non-path separators
146
+ for (; j < len; ++j) {
147
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
148
+ break;
149
+ }
150
+ if (j === len) {
151
+ // We matched a UNC root only
152
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
153
+ rootEnd = j;
154
+ }
155
+ else if (j !== last) {
156
+ // We matched a UNC root with leftovers
157
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
158
+ rootEnd = j;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ else {
164
+ rootEnd = 1;
165
+ }
166
+ }
167
+ else if ((0, _util_js_1.isWindowsDeviceRoot)(code)) {
168
+ // Possible device root
169
+ if (path.charCodeAt(1) === _constants_js_1.CHAR_COLON) {
170
+ device = path.slice(0, 2);
171
+ rootEnd = 2;
172
+ if (len > 2) {
173
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(2))) {
174
+ // Treat separator following drive name as an absolute path
175
+ // indicator
176
+ isAbsolute = true;
177
+ rootEnd = 3;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ else if ((0, _util_js_1.isPathSeparator)(code)) {
184
+ // `path` contains just a path separator
185
+ rootEnd = 1;
186
+ isAbsolute = true;
187
+ }
188
+ if (device.length > 0 &&
189
+ resolvedDevice.length > 0 &&
190
+ device.toLowerCase() !== resolvedDevice.toLowerCase()) {
191
+ // This path points to another device so it is not applicable
192
+ continue;
193
+ }
194
+ if (resolvedDevice.length === 0 && device.length > 0) {
195
+ resolvedDevice = device;
196
+ }
197
+ if (!resolvedAbsolute) {
198
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
199
+ resolvedAbsolute = isAbsolute;
200
+ }
201
+ if (resolvedAbsolute && resolvedDevice.length > 0)
202
+ break;
203
+ }
204
+ // At this point the path should be resolved to a full absolute path,
205
+ // but handle relative paths to be safe (might happen when Deno.cwd()
206
+ // fails)
207
+ // Normalize the tail path
208
+ resolvedTail = (0, _util_js_1.normalizeString)(resolvedTail, !resolvedAbsolute, "\\", _util_js_1.isPathSeparator);
209
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
210
+ }
211
+ exports.windowsResolve = windowsResolve;
@@ -0,0 +1,25 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Converts a path string to a file URL.
4
+ *
5
+ * ```ts
6
+ * import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
7
+ *
8
+ * toFileUrl("/home/foo"); // new URL("file:///home/foo")
9
+ * ```
10
+ * @param path to convert to file URL
11
+ */
12
+ export declare function posixToFileUrl(path: string): import("url").URL;
13
+ /**
14
+ * Converts a path string to a file URL.
15
+ *
16
+ * ```ts
17
+ * import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
18
+ *
19
+ * toFileUrl("\\home\\foo"); // new URL("file:///home/foo")
20
+ * toFileUrl("C:\\Users\\foo"); // new URL("file:///C:/Users/foo")
21
+ * toFileUrl("\\\\127.0.0.1\\home\\foo"); // new URL("file://127.0.0.1/home/foo")
22
+ * ```
23
+ * @param path to convert to file URL
24
+ */
25
+ export declare function windowsToFileUrl(path: string): URL;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.windowsToFileUrl = exports.posixToFileUrl = void 0;
6
+ const _is_absolute_js_1 = require("./_is_absolute.js");
7
+ const WHITESPACE_ENCODINGS = {
8
+ "\u0009": "%09",
9
+ "\u000A": "%0A",
10
+ "\u000B": "%0B",
11
+ "\u000C": "%0C",
12
+ "\u000D": "%0D",
13
+ "\u0020": "%20",
14
+ };
15
+ function encodeWhitespace(string) {
16
+ return string.replaceAll(/[\s]/g, (c) => {
17
+ return WHITESPACE_ENCODINGS[c] ?? c;
18
+ });
19
+ }
20
+ /**
21
+ * Converts a path string to a file URL.
22
+ *
23
+ * ```ts
24
+ * import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
25
+ *
26
+ * toFileUrl("/home/foo"); // new URL("file:///home/foo")
27
+ * ```
28
+ * @param path to convert to file URL
29
+ */
30
+ function posixToFileUrl(path) {
31
+ if (!(0, _is_absolute_js_1.posixIsAbsolute)(path)) {
32
+ throw new TypeError("Must be an absolute path.");
33
+ }
34
+ const url = new URL("file:///");
35
+ url.pathname = encodeWhitespace(path.replace(/%/g, "%25").replace(/\\/g, "%5C"));
36
+ return url;
37
+ }
38
+ exports.posixToFileUrl = posixToFileUrl;
39
+ /**
40
+ * Converts a path string to a file URL.
41
+ *
42
+ * ```ts
43
+ * import { toFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
44
+ *
45
+ * toFileUrl("\\home\\foo"); // new URL("file:///home/foo")
46
+ * toFileUrl("C:\\Users\\foo"); // new URL("file:///C:/Users/foo")
47
+ * toFileUrl("\\\\127.0.0.1\\home\\foo"); // new URL("file://127.0.0.1/home/foo")
48
+ * ```
49
+ * @param path to convert to file URL
50
+ */
51
+ function windowsToFileUrl(path) {
52
+ if (!(0, _is_absolute_js_1.windowsIsAbsolute)(path)) {
53
+ throw new TypeError("Must be an absolute path.");
54
+ }
55
+ const [, hostname, pathname] = path.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/);
56
+ const url = new URL("file:///");
57
+ url.pathname = encodeWhitespace(pathname.replace(/%/g, "%25"));
58
+ if (hostname !== undefined && hostname !== "localhost") {
59
+ url.hostname = hostname;
60
+ if (!url.hostname) {
61
+ throw new TypeError("Invalid hostname.");
62
+ }
63
+ }
64
+ return url;
65
+ }
66
+ exports.windowsToFileUrl = windowsToFileUrl;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Resolves path to a namespace path
3
+ * @param path to resolve to namespace
4
+ */
5
+ export declare function posixToNamespacedPath(path: string): string;
6
+ /**
7
+ * Resolves path to a namespace path
8
+ * @param path to resolve to namespace
9
+ */
10
+ export declare function windowsToNamespacedPath(path: string): string;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.windowsToNamespacedPath = exports.posixToNamespacedPath = void 0;
6
+ const _constants_js_1 = require("./_constants.js");
7
+ const _util_js_1 = require("./_util.js");
8
+ const _resolve_js_1 = require("./_resolve.js");
9
+ /**
10
+ * Resolves path to a namespace path
11
+ * @param path to resolve to namespace
12
+ */
13
+ function posixToNamespacedPath(path) {
14
+ // Non-op on posix systems
15
+ return path;
16
+ }
17
+ exports.posixToNamespacedPath = posixToNamespacedPath;
18
+ /**
19
+ * Resolves path to a namespace path
20
+ * @param path to resolve to namespace
21
+ */
22
+ function windowsToNamespacedPath(path) {
23
+ // Note: this will *probably* throw somewhere.
24
+ if (typeof path !== "string")
25
+ return path;
26
+ if (path.length === 0)
27
+ return "";
28
+ const resolvedPath = (0, _resolve_js_1.windowsResolve)(path);
29
+ if (resolvedPath.length >= 3) {
30
+ if (resolvedPath.charCodeAt(0) === _constants_js_1.CHAR_BACKWARD_SLASH) {
31
+ // Possible UNC root
32
+ if (resolvedPath.charCodeAt(1) === _constants_js_1.CHAR_BACKWARD_SLASH) {
33
+ const code = resolvedPath.charCodeAt(2);
34
+ if (code !== _constants_js_1.CHAR_QUESTION_MARK && code !== _constants_js_1.CHAR_DOT) {
35
+ // Matched non-long UNC root, convert the path to a long UNC path
36
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
37
+ }
38
+ }
39
+ }
40
+ else if ((0, _util_js_1.isWindowsDeviceRoot)(resolvedPath.charCodeAt(0))) {
41
+ // Possible device root
42
+ if (resolvedPath.charCodeAt(1) === _constants_js_1.CHAR_COLON &&
43
+ resolvedPath.charCodeAt(2) === _constants_js_1.CHAR_BACKWARD_SLASH) {
44
+ // Matched device root, convert the path to a long UNC path
45
+ return `\\\\?\\${resolvedPath}`;
46
+ }
47
+ }
48
+ }
49
+ return path;
50
+ }
51
+ exports.windowsToNamespacedPath = windowsToNamespacedPath;
@@ -0,0 +1,6 @@
1
+ export declare function assertPath(path: string): void;
2
+ export declare function isPosixPathSeparator(code: number): boolean;
3
+ export declare function isPathSeparator(code: number): boolean;
4
+ export declare function isWindowsDeviceRoot(code: number): boolean;
5
+ export declare function normalizeString(path: string, allowAboveRoot: boolean, separator: string, isPathSeparator: (code: number) => boolean): string;
6
+ export declare function stripTrailingSeparators(segment: string, isSep: (char: number) => boolean): string;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // Copyright the Browserify authors. MIT License.
4
+ // Ported from https://github.com/browserify/path-browserify/
5
+ // This module is browser compatible.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.stripTrailingSeparators = exports.normalizeString = exports.isWindowsDeviceRoot = exports.isPathSeparator = exports.isPosixPathSeparator = exports.assertPath = void 0;
8
+ const _constants_js_1 = require("./_constants.js");
9
+ function assertPath(path) {
10
+ if (typeof path !== "string") {
11
+ throw new TypeError(`Path must be a string. Received ${JSON.stringify(path)}`);
12
+ }
13
+ }
14
+ exports.assertPath = assertPath;
15
+ function isPosixPathSeparator(code) {
16
+ return code === _constants_js_1.CHAR_FORWARD_SLASH;
17
+ }
18
+ exports.isPosixPathSeparator = isPosixPathSeparator;
19
+ function isPathSeparator(code) {
20
+ return isPosixPathSeparator(code) || code === _constants_js_1.CHAR_BACKWARD_SLASH;
21
+ }
22
+ exports.isPathSeparator = isPathSeparator;
23
+ function isWindowsDeviceRoot(code) {
24
+ return ((code >= _constants_js_1.CHAR_LOWERCASE_A && code <= _constants_js_1.CHAR_LOWERCASE_Z) ||
25
+ (code >= _constants_js_1.CHAR_UPPERCASE_A && code <= _constants_js_1.CHAR_UPPERCASE_Z));
26
+ }
27
+ exports.isWindowsDeviceRoot = isWindowsDeviceRoot;
28
+ // Resolves . and .. elements in a path with directory names
29
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
30
+ let res = "";
31
+ let lastSegmentLength = 0;
32
+ let lastSlash = -1;
33
+ let dots = 0;
34
+ let code;
35
+ for (let i = 0, len = path.length; i <= len; ++i) {
36
+ if (i < len)
37
+ code = path.charCodeAt(i);
38
+ else if (isPathSeparator(code))
39
+ break;
40
+ else
41
+ code = _constants_js_1.CHAR_FORWARD_SLASH;
42
+ if (isPathSeparator(code)) {
43
+ if (lastSlash === i - 1 || dots === 1) {
44
+ // NOOP
45
+ }
46
+ else if (lastSlash !== i - 1 && dots === 2) {
47
+ if (res.length < 2 ||
48
+ lastSegmentLength !== 2 ||
49
+ res.charCodeAt(res.length - 1) !== _constants_js_1.CHAR_DOT ||
50
+ res.charCodeAt(res.length - 2) !== _constants_js_1.CHAR_DOT) {
51
+ if (res.length > 2) {
52
+ const lastSlashIndex = res.lastIndexOf(separator);
53
+ if (lastSlashIndex === -1) {
54
+ res = "";
55
+ lastSegmentLength = 0;
56
+ }
57
+ else {
58
+ res = res.slice(0, lastSlashIndex);
59
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
60
+ }
61
+ lastSlash = i;
62
+ dots = 0;
63
+ continue;
64
+ }
65
+ else if (res.length === 2 || res.length === 1) {
66
+ res = "";
67
+ lastSegmentLength = 0;
68
+ lastSlash = i;
69
+ dots = 0;
70
+ continue;
71
+ }
72
+ }
73
+ if (allowAboveRoot) {
74
+ if (res.length > 0)
75
+ res += `${separator}..`;
76
+ else
77
+ res = "..";
78
+ lastSegmentLength = 2;
79
+ }
80
+ }
81
+ else {
82
+ if (res.length > 0)
83
+ res += separator + path.slice(lastSlash + 1, i);
84
+ else
85
+ res = path.slice(lastSlash + 1, i);
86
+ lastSegmentLength = i - lastSlash - 1;
87
+ }
88
+ lastSlash = i;
89
+ dots = 0;
90
+ }
91
+ else if (code === _constants_js_1.CHAR_DOT && dots !== -1) {
92
+ ++dots;
93
+ }
94
+ else {
95
+ dots = -1;
96
+ }
97
+ }
98
+ return res;
99
+ }
100
+ exports.normalizeString = normalizeString;
101
+ function stripTrailingSeparators(segment, isSep) {
102
+ if (segment.length <= 1) {
103
+ return segment;
104
+ }
105
+ let end = segment.length;
106
+ for (let i = segment.length - 1; i > 0; i--) {
107
+ if (isSep(segment.charCodeAt(i))) {
108
+ end = i;
109
+ }
110
+ else {
111
+ break;
112
+ }
113
+ }
114
+ return segment.slice(0, end);
115
+ }
116
+ exports.stripTrailingSeparators = stripTrailingSeparators;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Return the last portion of a `path`.
3
+ * Trailing directory separators are ignored, and optional suffix is removed.
4
+ *
5
+ * @param path - path to extract the name from.
6
+ * @param [suffix] - suffix to remove from extracted name.
7
+ */
8
+ export declare function basename(path: string, suffix?: string): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.basename = void 0;
6
+ const _os_js_1 = require("./_os.js");
7
+ const _basename_js_1 = require("./_basename.js");
8
+ /**
9
+ * Return the last portion of a `path`.
10
+ * Trailing directory separators are ignored, and optional suffix is removed.
11
+ *
12
+ * @param path - path to extract the name from.
13
+ * @param [suffix] - suffix to remove from extracted name.
14
+ */
15
+ function basename(path, suffix = "") {
16
+ return _os_js_1.isWindows
17
+ ? (0, _basename_js_1.windowsBasename)(path, suffix)
18
+ : (0, _basename_js_1.posixBasename)(path, suffix);
19
+ }
20
+ exports.basename = basename;
@@ -0,0 +1,13 @@
1
+ /** Determines the common path from a set of paths, using an optional separator,
2
+ * which defaults to the OS default separator.
3
+ *
4
+ * ```ts
5
+ * import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
6
+ * const p = common([
7
+ * "./deno/std/path/mod.ts",
8
+ * "./deno/std/fs/mod.ts",
9
+ * ]);
10
+ * console.log(p); // "./deno/std/"
11
+ * ```
12
+ */
13
+ export declare function common(paths: string[], sep?: string): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.common = void 0;
6
+ const separator_js_1 = require("./separator.js");
7
+ /** Determines the common path from a set of paths, using an optional separator,
8
+ * which defaults to the OS default separator.
9
+ *
10
+ * ```ts
11
+ * import { common } from "https://deno.land/std@$STD_VERSION/path/mod.ts";
12
+ * const p = common([
13
+ * "./deno/std/path/mod.ts",
14
+ * "./deno/std/fs/mod.ts",
15
+ * ]);
16
+ * console.log(p); // "./deno/std/"
17
+ * ```
18
+ */
19
+ function common(paths, sep = separator_js_1.SEP) {
20
+ const [first = "", ...remaining] = paths;
21
+ if (first === "" || remaining.length === 0) {
22
+ return first.substring(0, first.lastIndexOf(sep) + 1);
23
+ }
24
+ const parts = first.split(sep);
25
+ let endOfPrefix = parts.length;
26
+ for (const path of remaining) {
27
+ const compare = path.split(sep);
28
+ for (let i = 0; i < endOfPrefix; i++) {
29
+ if (compare[i] !== parts[i]) {
30
+ endOfPrefix = i;
31
+ }
32
+ }
33
+ if (endOfPrefix === 0) {
34
+ return "";
35
+ }
36
+ }
37
+ const prefix = parts.slice(0, endOfPrefix).join(sep);
38
+ return prefix.endsWith(sep) ? prefix : `${prefix}${sep}`;
39
+ }
40
+ exports.common = common;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Return the directory path of a `path`.
3
+ * @param path - path to extract the directory from.
4
+ */
5
+ export declare function dirname(path: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.dirname = void 0;
6
+ const _os_js_1 = require("./_os.js");
7
+ const _dirname_js_1 = require("./_dirname.js");
8
+ /**
9
+ * Return the directory path of a `path`.
10
+ * @param path - path to extract the directory from.
11
+ */
12
+ function dirname(path) {
13
+ return _os_js_1.isWindows ? (0, _dirname_js_1.windowsDirname)(path) : (0, _dirname_js_1.posixDirname)(path);
14
+ }
15
+ exports.dirname = dirname;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Return the extension of the `path` with leading period.
3
+ * @param path with extension
4
+ * @returns extension (ex. for `file.ts` returns `.ts`)
5
+ */
6
+ export declare function extname(path: string): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.extname = void 0;
6
+ const _os_js_1 = require("./_os.js");
7
+ const _extname_js_1 = require("./_extname.js");
8
+ /**
9
+ * Return the extension of the `path` with leading period.
10
+ * @param path with extension
11
+ * @returns extension (ex. for `file.ts` returns `.ts`)
12
+ */
13
+ function extname(path) {
14
+ return _os_js_1.isWindows ? (0, _extname_js_1.windowsExtname)(path) : (0, _extname_js_1.posixExtname)(path);
15
+ }
16
+ exports.extname = extname;
@@ -0,0 +1,6 @@
1
+ import { FormatInputPathObject } from "./_interface.js";
2
+ /**
3
+ * Generate a path from `FormatInputPathObject` object.
4
+ * @param pathObject with path
5
+ */
6
+ export declare function format(pathObject: FormatInputPathObject): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.format = void 0;
6
+ const _os_js_1 = require("./_os.js");
7
+ const _format_js_1 = require("./_format.js");
8
+ /**
9
+ * Generate a path from `FormatInputPathObject` object.
10
+ * @param pathObject with path
11
+ */
12
+ function format(pathObject) {
13
+ return _os_js_1.isWindows ? (0, _format_js_1.windowsFormat)(pathObject) : (0, _format_js_1.posixFormat)(pathObject);
14
+ }
15
+ exports.format = format;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Converts a file URL to a path string.
4
+ *
5
+ * ```ts
6
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/from_file_url.ts";
7
+ *
8
+ * // posix
9
+ * fromFileUrl("file:///home/foo"); // "/home/foo"
10
+ *
11
+ * // win32
12
+ * fromFileUrl("file:///home/foo"); // "\\home\\foo"
13
+ * fromFileUrl("file:///C:/Users/foo"); // "C:\\Users\\foo"
14
+ * fromFileUrl("file://localhost/home/foo"); // "\\\\localhost\\home\\foo"
15
+ * ```
16
+ * @param url of a file URL
17
+ */
18
+ export declare function fromFileUrl(url: string | URL): string;