@zipify/wysiwyg 1.1.1 → 1.2.1-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.
Files changed (176) hide show
  1. package/.github/actions/lint-css/action.yaml +1 -3
  2. package/.release-it.json +2 -1
  3. package/dist/cli.js +3 -3
  4. package/dist/wysiwyg.css +24 -25
  5. package/dist/wysiwyg.mjs +641 -618
  6. package/jest.config.js +3 -0
  7. package/lib/components/base/Modal.vue +21 -2
  8. package/lib/components/base/__tests__/Modal.test.js +1 -0
  9. package/lib/components/toolbar/controls/link/LinkControl.vue +22 -10
  10. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +3 -3
  11. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +8 -8
  12. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
  13. package/lib/components/toolbar/controls/link/composables/useLink.js +10 -6
  14. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -1
  15. package/lib/composables/useEditor.js +4 -3
  16. package/lib/enums/TextSettings.js +2 -0
  17. package/lib/extensions/FontStyle.js +2 -2
  18. package/lib/extensions/FontWeight.js +2 -0
  19. package/lib/extensions/Link.js +13 -15
  20. package/lib/extensions/StylePreset.js +33 -3
  21. package/lib/extensions/TextDecoration.js +6 -12
  22. package/lib/extensions/__tests__/FontFamily.test.js +7 -6
  23. package/lib/extensions/__tests__/FontWeight.test.js +19 -10
  24. package/lib/extensions/__tests__/StylePreset.test.js +52 -2
  25. package/lib/extensions/__tests__/TextDecoration.test.js +11 -40
  26. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
  27. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +1 -1
  28. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +1 -1
  29. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +19 -1
  30. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +2 -2
  31. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +17 -1
  32. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +26 -1
  33. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +2 -2
  34. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +2 -2
  35. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +22 -2
  36. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +3 -46
  37. package/package.json +22 -22
  38. package/lib/components/toolbar/controls/link/LinkControlApply.vue +0 -35
  39. package/node_modules_lambda/acorn-globals/node_modules/.bin/acorn +0 -4
  40. package/node_modules_lambda/acorn-globals/node_modules/acorn/CHANGELOG.md +0 -620
  41. package/node_modules_lambda/acorn-globals/node_modules/acorn/LICENSE +0 -21
  42. package/node_modules_lambda/acorn-globals/node_modules/acorn/README.md +0 -269
  43. package/node_modules_lambda/acorn-globals/node_modules/acorn/bin/acorn +0 -4
  44. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.d.ts +0 -209
  45. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js +0 -5186
  46. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js.map +0 -1
  47. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs +0 -5155
  48. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  49. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.map +0 -1
  50. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/bin.js +0 -64
  51. package/node_modules_lambda/acorn-globals/node_modules/acorn/package.json +0 -35
  52. package/node_modules_lambda/cssstyle/node_modules/cssom/LICENSE.txt +0 -20
  53. package/node_modules_lambda/cssstyle/node_modules/cssom/README.mdown +0 -67
  54. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSDocumentRule.js +0 -39
  55. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSFontFaceRule.js +0 -36
  56. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSHostRule.js +0 -37
  57. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSImportRule.js +0 -132
  58. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframeRule.js +0 -37
  59. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframesRule.js +0 -39
  60. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSMediaRule.js +0 -41
  61. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSOM.js +0 -3
  62. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSRule.js +0 -43
  63. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleDeclaration.js +0 -148
  64. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleRule.js +0 -190
  65. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleSheet.js +0 -88
  66. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSSupportsRule.js +0 -36
  67. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValue.js +0 -43
  68. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValueExpression.js +0 -344
  69. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MatcherList.js +0 -62
  70. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MediaList.js +0 -61
  71. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/StyleSheet.js +0 -17
  72. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/clone.js +0 -82
  73. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/index.js +0 -21
  74. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/parse.js +0 -464
  75. package/node_modules_lambda/cssstyle/node_modules/cssom/package.json +0 -18
  76. package/node_modules_lambda/data-urls/node_modules/whatwg-url/LICENSE.txt +0 -21
  77. package/node_modules_lambda/data-urls/node_modules/whatwg-url/README.md +0 -106
  78. package/node_modules_lambda/data-urls/node_modules/whatwg-url/index.js +0 -27
  79. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/Function.js +0 -42
  80. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL-impl.js +0 -209
  81. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL.js +0 -442
  82. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams-impl.js +0 -130
  83. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams.js +0 -472
  84. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/VoidFunction.js +0 -26
  85. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/encoding.js +0 -16
  86. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/infra.js +0 -26
  87. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/percent-encoding.js +0 -142
  88. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/url-state-machine.js +0 -1244
  89. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/urlencoded.js +0 -106
  90. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/utils.js +0 -190
  91. package/node_modules_lambda/data-urls/node_modules/whatwg-url/package.json +0 -58
  92. package/node_modules_lambda/data-urls/node_modules/whatwg-url/webidl2js-wrapper.js +0 -7
  93. package/node_modules_lambda/escodegen/node_modules/estraverse/.jshintrc +0 -16
  94. package/node_modules_lambda/escodegen/node_modules/estraverse/LICENSE.BSD +0 -19
  95. package/node_modules_lambda/escodegen/node_modules/estraverse/README.md +0 -153
  96. package/node_modules_lambda/escodegen/node_modules/estraverse/estraverse.js +0 -805
  97. package/node_modules_lambda/escodegen/node_modules/estraverse/gulpfile.js +0 -70
  98. package/node_modules_lambda/escodegen/node_modules/estraverse/package.json +0 -40
  99. package/node_modules_lambda/escodegen/node_modules/levn/LICENSE +0 -22
  100. package/node_modules_lambda/escodegen/node_modules/levn/README.md +0 -196
  101. package/node_modules_lambda/escodegen/node_modules/levn/lib/cast.js +0 -298
  102. package/node_modules_lambda/escodegen/node_modules/levn/lib/coerce.js +0 -285
  103. package/node_modules_lambda/escodegen/node_modules/levn/lib/index.js +0 -22
  104. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse-string.js +0 -113
  105. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse.js +0 -102
  106. package/node_modules_lambda/escodegen/node_modules/levn/package.json +0 -47
  107. package/node_modules_lambda/escodegen/node_modules/optionator/CHANGELOG.md +0 -56
  108. package/node_modules_lambda/escodegen/node_modules/optionator/LICENSE +0 -22
  109. package/node_modules_lambda/escodegen/node_modules/optionator/README.md +0 -238
  110. package/node_modules_lambda/escodegen/node_modules/optionator/lib/help.js +0 -260
  111. package/node_modules_lambda/escodegen/node_modules/optionator/lib/index.js +0 -465
  112. package/node_modules_lambda/escodegen/node_modules/optionator/lib/util.js +0 -54
  113. package/node_modules_lambda/escodegen/node_modules/optionator/package.json +0 -44
  114. package/node_modules_lambda/escodegen/node_modules/prelude-ls/CHANGELOG.md +0 -99
  115. package/node_modules_lambda/escodegen/node_modules/prelude-ls/LICENSE +0 -22
  116. package/node_modules_lambda/escodegen/node_modules/prelude-ls/README.md +0 -15
  117. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Func.js +0 -65
  118. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/List.js +0 -686
  119. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Num.js +0 -130
  120. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Obj.js +0 -154
  121. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Str.js +0 -92
  122. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/index.js +0 -178
  123. package/node_modules_lambda/escodegen/node_modules/prelude-ls/package.json +0 -52
  124. package/node_modules_lambda/escodegen/node_modules/source-map/CHANGELOG.md +0 -301
  125. package/node_modules_lambda/escodegen/node_modules/source-map/LICENSE +0 -28
  126. package/node_modules_lambda/escodegen/node_modules/source-map/README.md +0 -742
  127. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.debug.js +0 -3234
  128. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.js +0 -3233
  129. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js +0 -2
  130. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js.map +0 -1
  131. package/node_modules_lambda/escodegen/node_modules/source-map/lib/array-set.js +0 -121
  132. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64-vlq.js +0 -140
  133. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64.js +0 -67
  134. package/node_modules_lambda/escodegen/node_modules/source-map/lib/binary-search.js +0 -111
  135. package/node_modules_lambda/escodegen/node_modules/source-map/lib/mapping-list.js +0 -79
  136. package/node_modules_lambda/escodegen/node_modules/source-map/lib/quick-sort.js +0 -114
  137. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  138. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-generator.js +0 -425
  139. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-node.js +0 -413
  140. package/node_modules_lambda/escodegen/node_modules/source-map/lib/util.js +0 -488
  141. package/node_modules_lambda/escodegen/node_modules/source-map/package.json +0 -73
  142. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.d.ts +0 -98
  143. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.js +0 -8
  144. package/node_modules_lambda/escodegen/node_modules/type-check/LICENSE +0 -22
  145. package/node_modules_lambda/escodegen/node_modules/type-check/README.md +0 -210
  146. package/node_modules_lambda/escodegen/node_modules/type-check/lib/check.js +0 -126
  147. package/node_modules_lambda/escodegen/node_modules/type-check/lib/index.js +0 -16
  148. package/node_modules_lambda/escodegen/node_modules/type-check/lib/parse-type.js +0 -196
  149. package/node_modules_lambda/escodegen/node_modules/type-check/package.json +0 -40
  150. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  151. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/Changelog.md +0 -212
  152. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/LICENSE +0 -21
  153. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/README.md +0 -130
  154. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  155. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  156. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/index.js +0 -23
  157. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/internal.js +0 -198
  158. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  159. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  160. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  161. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  162. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  163. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  164. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  165. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  166. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  167. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  168. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  169. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf16.js +0 -197
  170. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf32.js +0 -319
  171. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf7.js +0 -290
  172. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  173. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.d.ts +0 -41
  174. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.js +0 -180
  175. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/streams.js +0 -109
  176. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/package.json +0 -44
@@ -1,209 +0,0 @@
1
- "use strict";
2
- const usm = require("./url-state-machine");
3
- const urlencoded = require("./urlencoded");
4
- const URLSearchParams = require("./URLSearchParams");
5
-
6
- exports.implementation = class URLImpl {
7
- constructor(globalObject, constructorArgs) {
8
- const url = constructorArgs[0];
9
- const base = constructorArgs[1];
10
-
11
- let parsedBase = null;
12
- if (base !== undefined) {
13
- parsedBase = usm.basicURLParse(base);
14
- if (parsedBase === null) {
15
- throw new TypeError(`Invalid base URL: ${base}`);
16
- }
17
- }
18
-
19
- const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
20
- if (parsedURL === null) {
21
- throw new TypeError(`Invalid URL: ${url}`);
22
- }
23
-
24
- const query = parsedURL.query !== null ? parsedURL.query : "";
25
-
26
- this._url = parsedURL;
27
-
28
- // We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
29
- // question mark by default. Therefore the doNotStripQMark hack is used.
30
- this._query = URLSearchParams.createImpl(globalObject, [query], { doNotStripQMark: true });
31
- this._query._url = this;
32
- }
33
-
34
- get href() {
35
- return usm.serializeURL(this._url);
36
- }
37
-
38
- set href(v) {
39
- const parsedURL = usm.basicURLParse(v);
40
- if (parsedURL === null) {
41
- throw new TypeError(`Invalid URL: ${v}`);
42
- }
43
-
44
- this._url = parsedURL;
45
-
46
- this._query._list.splice(0);
47
- const { query } = parsedURL;
48
- if (query !== null) {
49
- this._query._list = urlencoded.parseUrlencodedString(query);
50
- }
51
- }
52
-
53
- get origin() {
54
- return usm.serializeURLOrigin(this._url);
55
- }
56
-
57
- get protocol() {
58
- return `${this._url.scheme}:`;
59
- }
60
-
61
- set protocol(v) {
62
- usm.basicURLParse(`${v}:`, { url: this._url, stateOverride: "scheme start" });
63
- }
64
-
65
- get username() {
66
- return this._url.username;
67
- }
68
-
69
- set username(v) {
70
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
71
- return;
72
- }
73
-
74
- usm.setTheUsername(this._url, v);
75
- }
76
-
77
- get password() {
78
- return this._url.password;
79
- }
80
-
81
- set password(v) {
82
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
83
- return;
84
- }
85
-
86
- usm.setThePassword(this._url, v);
87
- }
88
-
89
- get host() {
90
- const url = this._url;
91
-
92
- if (url.host === null) {
93
- return "";
94
- }
95
-
96
- if (url.port === null) {
97
- return usm.serializeHost(url.host);
98
- }
99
-
100
- return `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;
101
- }
102
-
103
- set host(v) {
104
- if (usm.hasAnOpaquePath(this._url)) {
105
- return;
106
- }
107
-
108
- usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
109
- }
110
-
111
- get hostname() {
112
- if (this._url.host === null) {
113
- return "";
114
- }
115
-
116
- return usm.serializeHost(this._url.host);
117
- }
118
-
119
- set hostname(v) {
120
- if (usm.hasAnOpaquePath(this._url)) {
121
- return;
122
- }
123
-
124
- usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" });
125
- }
126
-
127
- get port() {
128
- if (this._url.port === null) {
129
- return "";
130
- }
131
-
132
- return usm.serializeInteger(this._url.port);
133
- }
134
-
135
- set port(v) {
136
- if (usm.cannotHaveAUsernamePasswordPort(this._url)) {
137
- return;
138
- }
139
-
140
- if (v === "") {
141
- this._url.port = null;
142
- } else {
143
- usm.basicURLParse(v, { url: this._url, stateOverride: "port" });
144
- }
145
- }
146
-
147
- get pathname() {
148
- return usm.serializePath(this._url);
149
- }
150
-
151
- set pathname(v) {
152
- if (usm.hasAnOpaquePath(this._url)) {
153
- return;
154
- }
155
-
156
- this._url.path = [];
157
- usm.basicURLParse(v, { url: this._url, stateOverride: "path start" });
158
- }
159
-
160
- get search() {
161
- if (this._url.query === null || this._url.query === "") {
162
- return "";
163
- }
164
-
165
- return `?${this._url.query}`;
166
- }
167
-
168
- set search(v) {
169
- const url = this._url;
170
-
171
- if (v === "") {
172
- url.query = null;
173
- this._query._list = [];
174
- return;
175
- }
176
-
177
- const input = v[0] === "?" ? v.substring(1) : v;
178
- url.query = "";
179
- usm.basicURLParse(input, { url, stateOverride: "query" });
180
- this._query._list = urlencoded.parseUrlencodedString(input);
181
- }
182
-
183
- get searchParams() {
184
- return this._query;
185
- }
186
-
187
- get hash() {
188
- if (this._url.fragment === null || this._url.fragment === "") {
189
- return "";
190
- }
191
-
192
- return `#${this._url.fragment}`;
193
- }
194
-
195
- set hash(v) {
196
- if (v === "") {
197
- this._url.fragment = null;
198
- return;
199
- }
200
-
201
- const input = v[0] === "#" ? v.substring(1) : v;
202
- this._url.fragment = "";
203
- usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" });
204
- }
205
-
206
- toJSON() {
207
- return this.href;
208
- }
209
- };
@@ -1,442 +0,0 @@
1
- "use strict";
2
-
3
- const conversions = require("webidl-conversions");
4
- const utils = require("./utils.js");
5
-
6
- const implSymbol = utils.implSymbol;
7
- const ctorRegistrySymbol = utils.ctorRegistrySymbol;
8
-
9
- const interfaceName = "URL";
10
-
11
- exports.is = value => {
12
- return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
13
- };
14
- exports.isImpl = value => {
15
- return utils.isObject(value) && value instanceof Impl.implementation;
16
- };
17
- exports.convert = (globalObject, value, { context = "The provided value" } = {}) => {
18
- if (exports.is(value)) {
19
- return utils.implForWrapper(value);
20
- }
21
- throw new globalObject.TypeError(`${context} is not of type 'URL'.`);
22
- };
23
-
24
- function makeWrapper(globalObject, newTarget) {
25
- let proto;
26
- if (newTarget !== undefined) {
27
- proto = newTarget.prototype;
28
- }
29
-
30
- if (!utils.isObject(proto)) {
31
- proto = globalObject[ctorRegistrySymbol]["URL"].prototype;
32
- }
33
-
34
- return Object.create(proto);
35
- }
36
-
37
- exports.create = (globalObject, constructorArgs, privateData) => {
38
- const wrapper = makeWrapper(globalObject);
39
- return exports.setup(wrapper, globalObject, constructorArgs, privateData);
40
- };
41
-
42
- exports.createImpl = (globalObject, constructorArgs, privateData) => {
43
- const wrapper = exports.create(globalObject, constructorArgs, privateData);
44
- return utils.implForWrapper(wrapper);
45
- };
46
-
47
- exports._internalSetup = (wrapper, globalObject) => {};
48
-
49
- exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
50
- privateData.wrapper = wrapper;
51
-
52
- exports._internalSetup(wrapper, globalObject);
53
- Object.defineProperty(wrapper, implSymbol, {
54
- value: new Impl.implementation(globalObject, constructorArgs, privateData),
55
- configurable: true
56
- });
57
-
58
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
59
- if (Impl.init) {
60
- Impl.init(wrapper[implSymbol]);
61
- }
62
- return wrapper;
63
- };
64
-
65
- exports.new = (globalObject, newTarget) => {
66
- const wrapper = makeWrapper(globalObject, newTarget);
67
-
68
- exports._internalSetup(wrapper, globalObject);
69
- Object.defineProperty(wrapper, implSymbol, {
70
- value: Object.create(Impl.implementation.prototype),
71
- configurable: true
72
- });
73
-
74
- wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
75
- if (Impl.init) {
76
- Impl.init(wrapper[implSymbol]);
77
- }
78
- return wrapper[implSymbol];
79
- };
80
-
81
- const exposed = new Set(["Window", "Worker"]);
82
-
83
- exports.install = (globalObject, globalNames) => {
84
- if (!globalNames.some(globalName => exposed.has(globalName))) {
85
- return;
86
- }
87
-
88
- const ctorRegistry = utils.initCtorRegistry(globalObject);
89
- class URL {
90
- constructor(url) {
91
- if (arguments.length < 1) {
92
- throw new globalObject.TypeError(
93
- `Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`
94
- );
95
- }
96
- const args = [];
97
- {
98
- let curArg = arguments[0];
99
- curArg = conversions["USVString"](curArg, {
100
- context: "Failed to construct 'URL': parameter 1",
101
- globals: globalObject
102
- });
103
- args.push(curArg);
104
- }
105
- {
106
- let curArg = arguments[1];
107
- if (curArg !== undefined) {
108
- curArg = conversions["USVString"](curArg, {
109
- context: "Failed to construct 'URL': parameter 2",
110
- globals: globalObject
111
- });
112
- }
113
- args.push(curArg);
114
- }
115
- return exports.setup(Object.create(new.target.prototype), globalObject, args);
116
- }
117
-
118
- toJSON() {
119
- const esValue = this !== null && this !== undefined ? this : globalObject;
120
- if (!exports.is(esValue)) {
121
- throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of URL.");
122
- }
123
-
124
- return esValue[implSymbol].toJSON();
125
- }
126
-
127
- get href() {
128
- const esValue = this !== null && this !== undefined ? this : globalObject;
129
-
130
- if (!exports.is(esValue)) {
131
- throw new globalObject.TypeError("'get href' called on an object that is not a valid instance of URL.");
132
- }
133
-
134
- return esValue[implSymbol]["href"];
135
- }
136
-
137
- set href(V) {
138
- const esValue = this !== null && this !== undefined ? this : globalObject;
139
-
140
- if (!exports.is(esValue)) {
141
- throw new globalObject.TypeError("'set href' called on an object that is not a valid instance of URL.");
142
- }
143
-
144
- V = conversions["USVString"](V, {
145
- context: "Failed to set the 'href' property on 'URL': The provided value",
146
- globals: globalObject
147
- });
148
-
149
- esValue[implSymbol]["href"] = V;
150
- }
151
-
152
- toString() {
153
- const esValue = this;
154
- if (!exports.is(esValue)) {
155
- throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of URL.");
156
- }
157
-
158
- return esValue[implSymbol]["href"];
159
- }
160
-
161
- get origin() {
162
- const esValue = this !== null && this !== undefined ? this : globalObject;
163
-
164
- if (!exports.is(esValue)) {
165
- throw new globalObject.TypeError("'get origin' called on an object that is not a valid instance of URL.");
166
- }
167
-
168
- return esValue[implSymbol]["origin"];
169
- }
170
-
171
- get protocol() {
172
- const esValue = this !== null && this !== undefined ? this : globalObject;
173
-
174
- if (!exports.is(esValue)) {
175
- throw new globalObject.TypeError("'get protocol' called on an object that is not a valid instance of URL.");
176
- }
177
-
178
- return esValue[implSymbol]["protocol"];
179
- }
180
-
181
- set protocol(V) {
182
- const esValue = this !== null && this !== undefined ? this : globalObject;
183
-
184
- if (!exports.is(esValue)) {
185
- throw new globalObject.TypeError("'set protocol' called on an object that is not a valid instance of URL.");
186
- }
187
-
188
- V = conversions["USVString"](V, {
189
- context: "Failed to set the 'protocol' property on 'URL': The provided value",
190
- globals: globalObject
191
- });
192
-
193
- esValue[implSymbol]["protocol"] = V;
194
- }
195
-
196
- get username() {
197
- const esValue = this !== null && this !== undefined ? this : globalObject;
198
-
199
- if (!exports.is(esValue)) {
200
- throw new globalObject.TypeError("'get username' called on an object that is not a valid instance of URL.");
201
- }
202
-
203
- return esValue[implSymbol]["username"];
204
- }
205
-
206
- set username(V) {
207
- const esValue = this !== null && this !== undefined ? this : globalObject;
208
-
209
- if (!exports.is(esValue)) {
210
- throw new globalObject.TypeError("'set username' called on an object that is not a valid instance of URL.");
211
- }
212
-
213
- V = conversions["USVString"](V, {
214
- context: "Failed to set the 'username' property on 'URL': The provided value",
215
- globals: globalObject
216
- });
217
-
218
- esValue[implSymbol]["username"] = V;
219
- }
220
-
221
- get password() {
222
- const esValue = this !== null && this !== undefined ? this : globalObject;
223
-
224
- if (!exports.is(esValue)) {
225
- throw new globalObject.TypeError("'get password' called on an object that is not a valid instance of URL.");
226
- }
227
-
228
- return esValue[implSymbol]["password"];
229
- }
230
-
231
- set password(V) {
232
- const esValue = this !== null && this !== undefined ? this : globalObject;
233
-
234
- if (!exports.is(esValue)) {
235
- throw new globalObject.TypeError("'set password' called on an object that is not a valid instance of URL.");
236
- }
237
-
238
- V = conversions["USVString"](V, {
239
- context: "Failed to set the 'password' property on 'URL': The provided value",
240
- globals: globalObject
241
- });
242
-
243
- esValue[implSymbol]["password"] = V;
244
- }
245
-
246
- get host() {
247
- const esValue = this !== null && this !== undefined ? this : globalObject;
248
-
249
- if (!exports.is(esValue)) {
250
- throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of URL.");
251
- }
252
-
253
- return esValue[implSymbol]["host"];
254
- }
255
-
256
- set host(V) {
257
- const esValue = this !== null && this !== undefined ? this : globalObject;
258
-
259
- if (!exports.is(esValue)) {
260
- throw new globalObject.TypeError("'set host' called on an object that is not a valid instance of URL.");
261
- }
262
-
263
- V = conversions["USVString"](V, {
264
- context: "Failed to set the 'host' property on 'URL': The provided value",
265
- globals: globalObject
266
- });
267
-
268
- esValue[implSymbol]["host"] = V;
269
- }
270
-
271
- get hostname() {
272
- const esValue = this !== null && this !== undefined ? this : globalObject;
273
-
274
- if (!exports.is(esValue)) {
275
- throw new globalObject.TypeError("'get hostname' called on an object that is not a valid instance of URL.");
276
- }
277
-
278
- return esValue[implSymbol]["hostname"];
279
- }
280
-
281
- set hostname(V) {
282
- const esValue = this !== null && this !== undefined ? this : globalObject;
283
-
284
- if (!exports.is(esValue)) {
285
- throw new globalObject.TypeError("'set hostname' called on an object that is not a valid instance of URL.");
286
- }
287
-
288
- V = conversions["USVString"](V, {
289
- context: "Failed to set the 'hostname' property on 'URL': The provided value",
290
- globals: globalObject
291
- });
292
-
293
- esValue[implSymbol]["hostname"] = V;
294
- }
295
-
296
- get port() {
297
- const esValue = this !== null && this !== undefined ? this : globalObject;
298
-
299
- if (!exports.is(esValue)) {
300
- throw new globalObject.TypeError("'get port' called on an object that is not a valid instance of URL.");
301
- }
302
-
303
- return esValue[implSymbol]["port"];
304
- }
305
-
306
- set port(V) {
307
- const esValue = this !== null && this !== undefined ? this : globalObject;
308
-
309
- if (!exports.is(esValue)) {
310
- throw new globalObject.TypeError("'set port' called on an object that is not a valid instance of URL.");
311
- }
312
-
313
- V = conversions["USVString"](V, {
314
- context: "Failed to set the 'port' property on 'URL': The provided value",
315
- globals: globalObject
316
- });
317
-
318
- esValue[implSymbol]["port"] = V;
319
- }
320
-
321
- get pathname() {
322
- const esValue = this !== null && this !== undefined ? this : globalObject;
323
-
324
- if (!exports.is(esValue)) {
325
- throw new globalObject.TypeError("'get pathname' called on an object that is not a valid instance of URL.");
326
- }
327
-
328
- return esValue[implSymbol]["pathname"];
329
- }
330
-
331
- set pathname(V) {
332
- const esValue = this !== null && this !== undefined ? this : globalObject;
333
-
334
- if (!exports.is(esValue)) {
335
- throw new globalObject.TypeError("'set pathname' called on an object that is not a valid instance of URL.");
336
- }
337
-
338
- V = conversions["USVString"](V, {
339
- context: "Failed to set the 'pathname' property on 'URL': The provided value",
340
- globals: globalObject
341
- });
342
-
343
- esValue[implSymbol]["pathname"] = V;
344
- }
345
-
346
- get search() {
347
- const esValue = this !== null && this !== undefined ? this : globalObject;
348
-
349
- if (!exports.is(esValue)) {
350
- throw new globalObject.TypeError("'get search' called on an object that is not a valid instance of URL.");
351
- }
352
-
353
- return esValue[implSymbol]["search"];
354
- }
355
-
356
- set search(V) {
357
- const esValue = this !== null && this !== undefined ? this : globalObject;
358
-
359
- if (!exports.is(esValue)) {
360
- throw new globalObject.TypeError("'set search' called on an object that is not a valid instance of URL.");
361
- }
362
-
363
- V = conversions["USVString"](V, {
364
- context: "Failed to set the 'search' property on 'URL': The provided value",
365
- globals: globalObject
366
- });
367
-
368
- esValue[implSymbol]["search"] = V;
369
- }
370
-
371
- get searchParams() {
372
- const esValue = this !== null && this !== undefined ? this : globalObject;
373
-
374
- if (!exports.is(esValue)) {
375
- throw new globalObject.TypeError("'get searchParams' called on an object that is not a valid instance of URL.");
376
- }
377
-
378
- return utils.getSameObject(this, "searchParams", () => {
379
- return utils.tryWrapperForImpl(esValue[implSymbol]["searchParams"]);
380
- });
381
- }
382
-
383
- get hash() {
384
- const esValue = this !== null && this !== undefined ? this : globalObject;
385
-
386
- if (!exports.is(esValue)) {
387
- throw new globalObject.TypeError("'get hash' called on an object that is not a valid instance of URL.");
388
- }
389
-
390
- return esValue[implSymbol]["hash"];
391
- }
392
-
393
- set hash(V) {
394
- const esValue = this !== null && this !== undefined ? this : globalObject;
395
-
396
- if (!exports.is(esValue)) {
397
- throw new globalObject.TypeError("'set hash' called on an object that is not a valid instance of URL.");
398
- }
399
-
400
- V = conversions["USVString"](V, {
401
- context: "Failed to set the 'hash' property on 'URL': The provided value",
402
- globals: globalObject
403
- });
404
-
405
- esValue[implSymbol]["hash"] = V;
406
- }
407
- }
408
- Object.defineProperties(URL.prototype, {
409
- toJSON: { enumerable: true },
410
- href: { enumerable: true },
411
- toString: { enumerable: true },
412
- origin: { enumerable: true },
413
- protocol: { enumerable: true },
414
- username: { enumerable: true },
415
- password: { enumerable: true },
416
- host: { enumerable: true },
417
- hostname: { enumerable: true },
418
- port: { enumerable: true },
419
- pathname: { enumerable: true },
420
- search: { enumerable: true },
421
- searchParams: { enumerable: true },
422
- hash: { enumerable: true },
423
- [Symbol.toStringTag]: { value: "URL", configurable: true }
424
- });
425
- ctorRegistry[interfaceName] = URL;
426
-
427
- Object.defineProperty(globalObject, interfaceName, {
428
- configurable: true,
429
- writable: true,
430
- value: URL
431
- });
432
-
433
- if (globalNames.includes("Window")) {
434
- Object.defineProperty(globalObject, "webkitURL", {
435
- configurable: true,
436
- writable: true,
437
- value: URL
438
- });
439
- }
440
- };
441
-
442
- const Impl = require("./URL-impl.js");