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,81 @@
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.unescape = exports.escape = void 0;
6
+ const rawToEntityEntries = [
7
+ ["&", "&"],
8
+ ["<", "&lt;"],
9
+ [">", "&gt;"],
10
+ ['"', "&quot;"],
11
+ ["'", "&#39;"],
12
+ ];
13
+ const defaultEntityList = Object.fromEntries([
14
+ ...rawToEntityEntries.map(([raw, entity]) => [entity, raw]),
15
+ ["&apos;", "'"],
16
+ ["&nbsp;", "\xa0"],
17
+ ]);
18
+ const rawToEntity = new Map(rawToEntityEntries);
19
+ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
20
+ /**
21
+ * Escapes text for safe interpolation into HTML text content and quoted attributes
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { escape } from "https://deno.land/std@$STD_VERSION/html/entities.ts";
26
+ * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
27
+ *
28
+ * assertEquals(escape("<>'&AA"), "&lt;&gt;&#39;&amp;AA");
29
+ *
30
+ * // characters that don't need to be escaped will be left alone,
31
+ * // even if named HTML entities exist for them
32
+ * assertEquals(escape("þð"), "þð");
33
+ * ```
34
+ */
35
+ function escape(str) {
36
+ return str.replaceAll(rawRe, (m) => rawToEntity.get(m));
37
+ }
38
+ exports.escape = escape;
39
+ const defaultUnescapeOptions = {
40
+ entityList: defaultEntityList,
41
+ };
42
+ const MAX_CODE_POINT = 0x10ffff;
43
+ const RX_DEC_ENTITY = /&#([0-9]+);/g;
44
+ const RX_HEX_ENTITY = /&#x(\p{AHex}+);/gu;
45
+ const entityListRegexCache = new WeakMap();
46
+ /**
47
+ * Unescapes HTML entities in text
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { unescape } from "https://deno.land/std@$STD_VERSION/html/entities.ts";
52
+ * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
53
+ *
54
+ * // default options (only handles &<>'" and numeric entities)
55
+ * assertEquals(unescape("&lt;&gt;&apos;&amp;&#65;&#x41;"), "<>'&AA");
56
+ * assertEquals(unescape("&thorn;&eth;"), "&thorn;&eth;");
57
+ *
58
+ * // using the full named entity list from the HTML spec (~47K unminified)
59
+ * import entityList from "https://deno.land/std@$STD_VERSION/html/named_entity_list.json" assert { type: "json" };
60
+ * assertEquals(unescape("&thorn;&eth;", { entityList }), "þð");
61
+ * ```
62
+ */
63
+ function unescape(str, options = {}) {
64
+ const { entityList } = { ...defaultUnescapeOptions, ...options };
65
+ let entityRe = entityListRegexCache.get(entityList);
66
+ if (!entityRe) {
67
+ entityRe = new RegExp(`(${Object.keys(entityList)
68
+ .sort((a, b) => b.length - a.length)
69
+ .join("|")})`, "g");
70
+ entityListRegexCache.set(entityList, entityRe);
71
+ }
72
+ return str
73
+ .replaceAll(entityRe, (m) => entityList[m])
74
+ .replaceAll(RX_DEC_ENTITY, (_, dec) => codePointStrToChar(dec, 10))
75
+ .replaceAll(RX_HEX_ENTITY, (_, hex) => codePointStrToChar(hex, 16));
76
+ }
77
+ exports.unescape = unescape;
78
+ function codePointStrToChar(codePointStr, radix) {
79
+ const codePoint = parseInt(codePointStr, radix);
80
+ return codePoint > MAX_CODE_POINT ? "�" : String.fromCodePoint(codePoint);
81
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Functions for HTML tasks such as escaping or unescaping HTML entities
3
+ *
4
+ * @module
5
+ */
6
+ export * from "./entities.js";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ /**
20
+ * Functions for HTML tasks such as escaping or unescaping HTML entities
21
+ *
22
+ * @module
23
+ */
24
+ __exportStar(require("./entities.js"), exports);
@@ -0,0 +1,16 @@
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 posixBasename(path: string, suffix?: string): string;
9
+ /**
10
+ * Return the last portion of a `path`.
11
+ * Trailing directory separators are ignored, and optional suffix is removed.
12
+ *
13
+ * @param path - path to extract the name from.
14
+ * @param [suffix] - suffix to remove from extracted name.
15
+ */
16
+ export declare function windowsBasename(path: string, suffix?: string): string;
@@ -0,0 +1,83 @@
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.windowsBasename = exports.posixBasename = void 0;
6
+ const _constants_js_1 = require("./_constants.js");
7
+ const _util_js_1 = require("./_util.js");
8
+ function stripSuffix(name, suffix) {
9
+ if (suffix.length >= name.length) {
10
+ return name;
11
+ }
12
+ const lenDiff = name.length - suffix.length;
13
+ for (let i = suffix.length - 1; i >= 0; --i) {
14
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
15
+ return name;
16
+ }
17
+ }
18
+ return name.slice(0, -suffix.length);
19
+ }
20
+ function lastPathSegment(path, isSep, start = 0) {
21
+ let matchedNonSeparator = false;
22
+ let end = path.length;
23
+ for (let i = path.length - 1; i >= start; --i) {
24
+ if (isSep(path.charCodeAt(i))) {
25
+ if (matchedNonSeparator) {
26
+ start = i + 1;
27
+ break;
28
+ }
29
+ }
30
+ else if (!matchedNonSeparator) {
31
+ matchedNonSeparator = true;
32
+ end = i + 1;
33
+ }
34
+ }
35
+ return path.slice(start, end);
36
+ }
37
+ function assertArgs(path, suffix) {
38
+ (0, _util_js_1.assertPath)(path);
39
+ if (path.length === 0)
40
+ return path;
41
+ if (typeof suffix !== "string") {
42
+ throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
43
+ }
44
+ }
45
+ /**
46
+ * Return the last portion of a `path`.
47
+ * Trailing directory separators are ignored, and optional suffix is removed.
48
+ *
49
+ * @param path - path to extract the name from.
50
+ * @param [suffix] - suffix to remove from extracted name.
51
+ */
52
+ function posixBasename(path, suffix = "") {
53
+ assertArgs(path, suffix);
54
+ const lastSegment = lastPathSegment(path, _util_js_1.isPosixPathSeparator);
55
+ const strippedSegment = (0, _util_js_1.stripTrailingSeparators)(lastSegment, _util_js_1.isPosixPathSeparator);
56
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
57
+ }
58
+ exports.posixBasename = posixBasename;
59
+ /**
60
+ * Return the last portion of a `path`.
61
+ * Trailing directory separators are ignored, and optional suffix is removed.
62
+ *
63
+ * @param path - path to extract the name from.
64
+ * @param [suffix] - suffix to remove from extracted name.
65
+ */
66
+ function windowsBasename(path, suffix = "") {
67
+ assertArgs(path, suffix);
68
+ // Check for a drive letter prefix so as not to mistake the following
69
+ // path separator as an extra separator at the end of the path that can be
70
+ // disregarded
71
+ let start = 0;
72
+ if (path.length >= 2) {
73
+ const drive = path.charCodeAt(0);
74
+ if ((0, _util_js_1.isWindowsDeviceRoot)(drive)) {
75
+ if (path.charCodeAt(1) === _constants_js_1.CHAR_COLON)
76
+ start = 2;
77
+ }
78
+ }
79
+ const lastSegment = lastPathSegment(path, _util_js_1.isPathSeparator, start);
80
+ const strippedSegment = (0, _util_js_1.stripTrailingSeparators)(lastSegment, _util_js_1.isPathSeparator);
81
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
82
+ }
83
+ exports.windowsBasename = windowsBasename;
@@ -0,0 +1,39 @@
1
+ export declare const CHAR_UPPERCASE_A = 65;
2
+ export declare const CHAR_LOWERCASE_A = 97;
3
+ export declare const CHAR_UPPERCASE_Z = 90;
4
+ export declare const CHAR_LOWERCASE_Z = 122;
5
+ export declare const CHAR_DOT = 46;
6
+ export declare const CHAR_FORWARD_SLASH = 47;
7
+ export declare const CHAR_BACKWARD_SLASH = 92;
8
+ export declare const CHAR_VERTICAL_LINE = 124;
9
+ export declare const CHAR_COLON = 58;
10
+ export declare const CHAR_QUESTION_MARK = 63;
11
+ export declare const CHAR_UNDERSCORE = 95;
12
+ export declare const CHAR_LINE_FEED = 10;
13
+ export declare const CHAR_CARRIAGE_RETURN = 13;
14
+ export declare const CHAR_TAB = 9;
15
+ export declare const CHAR_FORM_FEED = 12;
16
+ export declare const CHAR_EXCLAMATION_MARK = 33;
17
+ export declare const CHAR_HASH = 35;
18
+ export declare const CHAR_SPACE = 32;
19
+ export declare const CHAR_NO_BREAK_SPACE = 160;
20
+ export declare const CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279;
21
+ export declare const CHAR_LEFT_SQUARE_BRACKET = 91;
22
+ export declare const CHAR_RIGHT_SQUARE_BRACKET = 93;
23
+ export declare const CHAR_LEFT_ANGLE_BRACKET = 60;
24
+ export declare const CHAR_RIGHT_ANGLE_BRACKET = 62;
25
+ export declare const CHAR_LEFT_CURLY_BRACKET = 123;
26
+ export declare const CHAR_RIGHT_CURLY_BRACKET = 125;
27
+ export declare const CHAR_HYPHEN_MINUS = 45;
28
+ export declare const CHAR_PLUS = 43;
29
+ export declare const CHAR_DOUBLE_QUOTE = 34;
30
+ export declare const CHAR_SINGLE_QUOTE = 39;
31
+ export declare const CHAR_PERCENT = 37;
32
+ export declare const CHAR_SEMICOLON = 59;
33
+ export declare const CHAR_CIRCUMFLEX_ACCENT = 94;
34
+ export declare const CHAR_GRAVE_ACCENT = 96;
35
+ export declare const CHAR_AT = 64;
36
+ export declare const CHAR_AMPERSAND = 38;
37
+ export declare const CHAR_EQUAL = 61;
38
+ export declare const CHAR_0 = 48;
39
+ export declare const CHAR_9 = 57;
@@ -0,0 +1,49 @@
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.CHAR_9 = exports.CHAR_0 = exports.CHAR_EQUAL = exports.CHAR_AMPERSAND = exports.CHAR_AT = exports.CHAR_GRAVE_ACCENT = exports.CHAR_CIRCUMFLEX_ACCENT = exports.CHAR_SEMICOLON = exports.CHAR_PERCENT = exports.CHAR_SINGLE_QUOTE = exports.CHAR_DOUBLE_QUOTE = exports.CHAR_PLUS = exports.CHAR_HYPHEN_MINUS = exports.CHAR_RIGHT_CURLY_BRACKET = exports.CHAR_LEFT_CURLY_BRACKET = exports.CHAR_RIGHT_ANGLE_BRACKET = exports.CHAR_LEFT_ANGLE_BRACKET = exports.CHAR_RIGHT_SQUARE_BRACKET = exports.CHAR_LEFT_SQUARE_BRACKET = exports.CHAR_ZERO_WIDTH_NOBREAK_SPACE = exports.CHAR_NO_BREAK_SPACE = exports.CHAR_SPACE = exports.CHAR_HASH = exports.CHAR_EXCLAMATION_MARK = exports.CHAR_FORM_FEED = exports.CHAR_TAB = exports.CHAR_CARRIAGE_RETURN = exports.CHAR_LINE_FEED = exports.CHAR_UNDERSCORE = exports.CHAR_QUESTION_MARK = exports.CHAR_COLON = exports.CHAR_VERTICAL_LINE = exports.CHAR_BACKWARD_SLASH = exports.CHAR_FORWARD_SLASH = exports.CHAR_DOT = exports.CHAR_LOWERCASE_Z = exports.CHAR_UPPERCASE_Z = exports.CHAR_LOWERCASE_A = exports.CHAR_UPPERCASE_A = void 0;
8
+ // Alphabet chars.
9
+ exports.CHAR_UPPERCASE_A = 65; /* A */
10
+ exports.CHAR_LOWERCASE_A = 97; /* a */
11
+ exports.CHAR_UPPERCASE_Z = 90; /* Z */
12
+ exports.CHAR_LOWERCASE_Z = 122; /* z */
13
+ // Non-alphabetic chars.
14
+ exports.CHAR_DOT = 46; /* . */
15
+ exports.CHAR_FORWARD_SLASH = 47; /* / */
16
+ exports.CHAR_BACKWARD_SLASH = 92; /* \ */
17
+ exports.CHAR_VERTICAL_LINE = 124; /* | */
18
+ exports.CHAR_COLON = 58; /* : */
19
+ exports.CHAR_QUESTION_MARK = 63; /* ? */
20
+ exports.CHAR_UNDERSCORE = 95; /* _ */
21
+ exports.CHAR_LINE_FEED = 10; /* \n */
22
+ exports.CHAR_CARRIAGE_RETURN = 13; /* \r */
23
+ exports.CHAR_TAB = 9; /* \t */
24
+ exports.CHAR_FORM_FEED = 12; /* \f */
25
+ exports.CHAR_EXCLAMATION_MARK = 33; /* ! */
26
+ exports.CHAR_HASH = 35; /* # */
27
+ exports.CHAR_SPACE = 32; /* */
28
+ exports.CHAR_NO_BREAK_SPACE = 160; /* \u00A0 */
29
+ exports.CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279; /* \uFEFF */
30
+ exports.CHAR_LEFT_SQUARE_BRACKET = 91; /* [ */
31
+ exports.CHAR_RIGHT_SQUARE_BRACKET = 93; /* ] */
32
+ exports.CHAR_LEFT_ANGLE_BRACKET = 60; /* < */
33
+ exports.CHAR_RIGHT_ANGLE_BRACKET = 62; /* > */
34
+ exports.CHAR_LEFT_CURLY_BRACKET = 123; /* { */
35
+ exports.CHAR_RIGHT_CURLY_BRACKET = 125; /* } */
36
+ exports.CHAR_HYPHEN_MINUS = 45; /* - */
37
+ exports.CHAR_PLUS = 43; /* + */
38
+ exports.CHAR_DOUBLE_QUOTE = 34; /* " */
39
+ exports.CHAR_SINGLE_QUOTE = 39; /* ' */
40
+ exports.CHAR_PERCENT = 37; /* % */
41
+ exports.CHAR_SEMICOLON = 59; /* ; */
42
+ exports.CHAR_CIRCUMFLEX_ACCENT = 94; /* ^ */
43
+ exports.CHAR_GRAVE_ACCENT = 96; /* ` */
44
+ exports.CHAR_AT = 64; /* @ */
45
+ exports.CHAR_AMPERSAND = 38; /* & */
46
+ exports.CHAR_EQUAL = 61; /* = */
47
+ // Digits
48
+ exports.CHAR_0 = 48; /* 0 */
49
+ exports.CHAR_9 = 57; /* 9 */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Return the directory path of a `path`.
3
+ * @param path - path to extract the directory from.
4
+ */
5
+ export declare function posixDirname(path: string): string;
6
+ /**
7
+ * Return the directory path of a `path`.
8
+ * @param path - path to extract the directory from.
9
+ */
10
+ export declare function windowsDirname(path: string): string;
@@ -0,0 +1,137 @@
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.windowsDirname = exports.posixDirname = void 0;
6
+ const _constants_js_1 = require("./_constants.js");
7
+ const _util_js_1 = require("./_util.js");
8
+ function assertArg(path) {
9
+ (0, _util_js_1.assertPath)(path);
10
+ if (path.length === 0)
11
+ return ".";
12
+ }
13
+ /**
14
+ * Return the directory path of a `path`.
15
+ * @param path - path to extract the directory from.
16
+ */
17
+ function posixDirname(path) {
18
+ assertArg(path);
19
+ let end = -1;
20
+ let matchedNonSeparator = false;
21
+ for (let i = path.length - 1; i >= 1; --i) {
22
+ if ((0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(i))) {
23
+ if (matchedNonSeparator) {
24
+ end = i;
25
+ break;
26
+ }
27
+ }
28
+ else {
29
+ matchedNonSeparator = true;
30
+ }
31
+ }
32
+ // No matches. Fallback based on provided path:
33
+ //
34
+ // - leading slashes paths
35
+ // "/foo" => "/"
36
+ // "///foo" => "/"
37
+ // - no slash path
38
+ // "foo" => "."
39
+ if (end === -1) {
40
+ return (0, _util_js_1.isPosixPathSeparator)(path.charCodeAt(0)) ? "/" : ".";
41
+ }
42
+ return (0, _util_js_1.stripTrailingSeparators)(path.slice(0, end), _util_js_1.isPosixPathSeparator);
43
+ }
44
+ exports.posixDirname = posixDirname;
45
+ /**
46
+ * Return the directory path of a `path`.
47
+ * @param path - path to extract the directory from.
48
+ */
49
+ function windowsDirname(path) {
50
+ assertArg(path);
51
+ const len = path.length;
52
+ let rootEnd = -1;
53
+ let end = -1;
54
+ let matchedSlash = true;
55
+ let offset = 0;
56
+ const code = path.charCodeAt(0);
57
+ // Try to match a root
58
+ if (len > 1) {
59
+ if ((0, _util_js_1.isPathSeparator)(code)) {
60
+ // Possible UNC root
61
+ rootEnd = offset = 1;
62
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(1))) {
63
+ // Matched double path separator at beginning
64
+ let j = 2;
65
+ let last = j;
66
+ // Match 1 or more non-path separators
67
+ for (; j < len; ++j) {
68
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
69
+ break;
70
+ }
71
+ if (j < len && j !== last) {
72
+ // Matched!
73
+ last = j;
74
+ // Match 1 or more path separators
75
+ for (; j < len; ++j) {
76
+ if (!(0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
77
+ break;
78
+ }
79
+ if (j < len && j !== last) {
80
+ // Matched!
81
+ last = j;
82
+ // Match 1 or more non-path separators
83
+ for (; j < len; ++j) {
84
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(j)))
85
+ break;
86
+ }
87
+ if (j === len) {
88
+ // We matched a UNC root only
89
+ return path;
90
+ }
91
+ if (j !== last) {
92
+ // We matched a UNC root with leftovers
93
+ // Offset by 1 to include the separator after the UNC root to
94
+ // treat it as a "normal root" on top of a (UNC) root
95
+ rootEnd = offset = j + 1;
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ else if ((0, _util_js_1.isWindowsDeviceRoot)(code)) {
102
+ // Possible device root
103
+ if (path.charCodeAt(1) === _constants_js_1.CHAR_COLON) {
104
+ rootEnd = offset = 2;
105
+ if (len > 2) {
106
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(2)))
107
+ rootEnd = offset = 3;
108
+ }
109
+ }
110
+ }
111
+ }
112
+ else if ((0, _util_js_1.isPathSeparator)(code)) {
113
+ // `path` contains just a path separator, exit early to avoid
114
+ // unnecessary work
115
+ return path;
116
+ }
117
+ for (let i = len - 1; i >= offset; --i) {
118
+ if ((0, _util_js_1.isPathSeparator)(path.charCodeAt(i))) {
119
+ if (!matchedSlash) {
120
+ end = i;
121
+ break;
122
+ }
123
+ }
124
+ else {
125
+ // We saw the first non-path separator
126
+ matchedSlash = false;
127
+ }
128
+ }
129
+ if (end === -1) {
130
+ if (rootEnd === -1)
131
+ return ".";
132
+ else
133
+ end = rootEnd;
134
+ }
135
+ return (0, _util_js_1.stripTrailingSeparators)(path.slice(0, end), _util_js_1.isPosixPathSeparator);
136
+ }
137
+ exports.windowsDirname = windowsDirname;
@@ -0,0 +1,12 @@
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 posixExtname(path: string): string;
7
+ /**
8
+ * Return the extension of the `path` with leading period.
9
+ * @param path with extension
10
+ * @returns extension (ex. for `file.ts` returns `.ts`)
11
+ */
12
+ export declare function windowsExtname(path: string): string;
@@ -0,0 +1,126 @@
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.windowsExtname = exports.posixExtname = void 0;
6
+ const _constants_js_1 = require("./_constants.js");
7
+ const _util_js_1 = require("./_util.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 posixExtname(path) {
14
+ (0, _util_js_1.assertPath)(path);
15
+ let startDot = -1;
16
+ let startPart = 0;
17
+ let end = -1;
18
+ let matchedSlash = true;
19
+ // Track the state of characters (if any) we see before our first dot and
20
+ // after any path separator we find
21
+ let preDotState = 0;
22
+ for (let i = path.length - 1; i >= 0; --i) {
23
+ const code = path.charCodeAt(i);
24
+ if ((0, _util_js_1.isPosixPathSeparator)(code)) {
25
+ // If we reached a path separator that was not part of a set of path
26
+ // separators at the end of the string, stop now
27
+ if (!matchedSlash) {
28
+ startPart = i + 1;
29
+ break;
30
+ }
31
+ continue;
32
+ }
33
+ if (end === -1) {
34
+ // We saw the first non-path separator, mark this as the end of our
35
+ // extension
36
+ matchedSlash = false;
37
+ end = i + 1;
38
+ }
39
+ if (code === _constants_js_1.CHAR_DOT) {
40
+ // If this is our first dot, mark it as the start of our extension
41
+ if (startDot === -1)
42
+ startDot = i;
43
+ else if (preDotState !== 1)
44
+ preDotState = 1;
45
+ }
46
+ else if (startDot !== -1) {
47
+ // We saw a non-dot and non-path separator before our dot, so we should
48
+ // have a good chance at having a non-empty extension
49
+ preDotState = -1;
50
+ }
51
+ }
52
+ if (startDot === -1 ||
53
+ end === -1 ||
54
+ // We saw a non-dot character immediately before the dot
55
+ preDotState === 0 ||
56
+ // The (right-most) trimmed path component is exactly '..'
57
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
58
+ return "";
59
+ }
60
+ return path.slice(startDot, end);
61
+ }
62
+ exports.posixExtname = posixExtname;
63
+ /**
64
+ * Return the extension of the `path` with leading period.
65
+ * @param path with extension
66
+ * @returns extension (ex. for `file.ts` returns `.ts`)
67
+ */
68
+ function windowsExtname(path) {
69
+ (0, _util_js_1.assertPath)(path);
70
+ let start = 0;
71
+ let startDot = -1;
72
+ let startPart = 0;
73
+ let end = -1;
74
+ let matchedSlash = true;
75
+ // Track the state of characters (if any) we see before our first dot and
76
+ // after any path separator we find
77
+ let preDotState = 0;
78
+ // Check for a drive letter prefix so as not to mistake the following
79
+ // path separator as an extra separator at the end of the path that can be
80
+ // disregarded
81
+ if (path.length >= 2 &&
82
+ path.charCodeAt(1) === _constants_js_1.CHAR_COLON &&
83
+ (0, _util_js_1.isWindowsDeviceRoot)(path.charCodeAt(0))) {
84
+ start = startPart = 2;
85
+ }
86
+ for (let i = path.length - 1; i >= start; --i) {
87
+ const code = path.charCodeAt(i);
88
+ if ((0, _util_js_1.isPathSeparator)(code)) {
89
+ // If we reached a path separator that was not part of a set of path
90
+ // separators at the end of the string, stop now
91
+ if (!matchedSlash) {
92
+ startPart = i + 1;
93
+ break;
94
+ }
95
+ continue;
96
+ }
97
+ if (end === -1) {
98
+ // We saw the first non-path separator, mark this as the end of our
99
+ // extension
100
+ matchedSlash = false;
101
+ end = i + 1;
102
+ }
103
+ if (code === _constants_js_1.CHAR_DOT) {
104
+ // If this is our first dot, mark it as the start of our extension
105
+ if (startDot === -1)
106
+ startDot = i;
107
+ else if (preDotState !== 1)
108
+ preDotState = 1;
109
+ }
110
+ else if (startDot !== -1) {
111
+ // We saw a non-dot and non-path separator before our dot, so we should
112
+ // have a good chance at having a non-empty extension
113
+ preDotState = -1;
114
+ }
115
+ }
116
+ if (startDot === -1 ||
117
+ end === -1 ||
118
+ // We saw a non-dot character immediately before the dot
119
+ preDotState === 0 ||
120
+ // The (right-most) trimmed path component is exactly '..'
121
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
122
+ return "";
123
+ }
124
+ return path.slice(startDot, end);
125
+ }
126
+ exports.windowsExtname = windowsExtname;
@@ -0,0 +1,11 @@
1
+ import type { FormatInputPathObject } from "./_interface.js";
2
+ /**
3
+ * Generate a path from `FormatInputPathObject` object.
4
+ * @param pathObject with path
5
+ */
6
+ export declare function posixFormat(pathObject: FormatInputPathObject): string;
7
+ /**
8
+ * Generate a path from `FormatInputPathObject` object.
9
+ * @param pathObject with path
10
+ */
11
+ export declare function windowsFormat(pathObject: FormatInputPathObject): 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.windowsFormat = exports.posixFormat = void 0;
6
+ function _format(sep, pathObject) {
7
+ const dir = pathObject.dir || pathObject.root;
8
+ const base = pathObject.base ||
9
+ (pathObject.name || "") + (pathObject.ext || "");
10
+ if (!dir)
11
+ return base;
12
+ if (base === sep)
13
+ return dir;
14
+ if (dir === pathObject.root)
15
+ return dir + base;
16
+ return dir + sep + base;
17
+ }
18
+ function assertArg(pathObject) {
19
+ if (pathObject === null || typeof pathObject !== "object") {
20
+ throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
21
+ }
22
+ }
23
+ /**
24
+ * Generate a path from `FormatInputPathObject` object.
25
+ * @param pathObject with path
26
+ */
27
+ function posixFormat(pathObject) {
28
+ assertArg(pathObject);
29
+ return _format("/", pathObject);
30
+ }
31
+ exports.posixFormat = posixFormat;
32
+ /**
33
+ * Generate a path from `FormatInputPathObject` object.
34
+ * @param pathObject with path
35
+ */
36
+ function windowsFormat(pathObject) {
37
+ assertArg(pathObject);
38
+ return _format("\\", pathObject);
39
+ }
40
+ exports.windowsFormat = windowsFormat;
@@ -0,0 +1,25 @@
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/posix.ts";
7
+ *
8
+ * fromFileUrl("file:///home/foo"); // "/home/foo"
9
+ * ```
10
+ * @param url of a file URL
11
+ */
12
+ export declare function posixFromFileUrl(url: URL | string): string;
13
+ /**
14
+ * Converts a file URL to a path string.
15
+ *
16
+ * ```ts
17
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
18
+ *
19
+ * fromFileUrl("file:///home/foo"); // "\\home\\foo"
20
+ * fromFileUrl("file:///C:/Users/foo"); // "C:\\Users\\foo"
21
+ * fromFileUrl("file://localhost/home/foo"); // "\\\\localhost\\home\\foo"
22
+ * ```
23
+ * @param url of a file URL
24
+ */
25
+ export declare function windowsFromFileUrl(url: URL | string): string;