@wabot-dev/framework 0.1.0-beta.9 → 0.2.0-beta.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 (212) hide show
  1. package/dist/src/addon/async/pg/PgJobRepository.js +26 -0
  2. package/dist/src/addon/auth/api-key/@apiKeyConnectionGuard.js +16 -0
  3. package/dist/src/addon/auth/api-key/@apiKeyGuard.js +17 -0
  4. package/dist/src/addon/auth/api-key/ApiKey.js +45 -0
  5. package/dist/src/addon/auth/api-key/ApiKeyConnectionGuardMiddleware.js +57 -0
  6. package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +45 -0
  7. package/dist/src/addon/auth/api-key/ApiKeyRepository.js +22 -0
  8. package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +53 -0
  9. package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +62 -0
  10. package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +16 -0
  11. package/dist/src/addon/auth/jwt/@jwtGuard.js +17 -0
  12. package/dist/src/addon/auth/jwt/Jwt.js +53 -0
  13. package/dist/src/addon/auth/jwt/JwtAccessAndRefreshTokenDto.js +20 -0
  14. package/dist/src/addon/auth/jwt/JwtConfig.js +28 -0
  15. package/dist/src/addon/auth/jwt/JwtConnectionGuardMiddleware.js +57 -0
  16. package/dist/src/addon/auth/jwt/JwtGuardMiddleware.js +45 -0
  17. package/dist/src/addon/auth/jwt/JwtRefreshToken.js +56 -0
  18. package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +25 -0
  19. package/dist/src/addon/auth/jwt/JwtSigner.js +36 -0
  20. package/dist/src/addon/auth/jwt/JwtTokenDto.js +22 -0
  21. package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +21 -0
  22. package/dist/src/addon/chat-bot/anthropic/AnthropicChatAdapter.js +135 -0
  23. package/dist/src/addon/chat-bot/deepseek/DeepSeekChatAdapter.js +137 -0
  24. package/dist/src/addon/chat-bot/google/GoogleChatAdapter.js +128 -0
  25. package/dist/src/addon/chat-bot/openia/OpenaiChatAdapter.js +117 -0
  26. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatMemory.js +6 -4
  27. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/pg/PgChatRepository.js +6 -5
  28. package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatRepository.js +2 -2
  29. package/dist/src/addon/chat-bot/wabot/WabotChatAdapter.js +41 -0
  30. package/dist/src/addon/chat-controller/cmd/@cmd.js +24 -0
  31. package/dist/src/addon/chat-controller/cmd/CmdChannel.js +91 -0
  32. package/dist/src/{channels → addon/chat-controller}/socket/@socket.js +10 -4
  33. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannel.js +9 -23
  34. package/dist/src/{channels → addon/chat-controller}/socket/SocketChannelConfig.js +1 -1
  35. package/dist/src/{channels → addon/chat-controller}/telegram/@telegram.js +10 -4
  36. package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannel.js +4 -22
  37. package/dist/src/addon/chat-controller/whatsapp/@whatsApp.js +26 -0
  38. package/dist/src/{channels → addon/chat-controller}/whatsapp/EnvWhatsAppRepository.js +3 -3
  39. package/dist/src/{channels → addon/chat-controller}/whatsapp/PgWhatsAppRepository.js +2 -2
  40. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsApp.js +2 -4
  41. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannel.js +6 -18
  42. package/dist/src/addon/chat-controller/whatsapp/WhatsAppReceiver.js +10 -0
  43. package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppSender.js +15 -39
  44. package/dist/src/addon/chat-controller/whatsapp/cloud-api/WhatsAppReceiverByCloudApi.js +97 -0
  45. package/dist/src/{channels/whatsapp → addon/chat-controller/whatsapp/cloud-api}/WhatsAppSenderByCloudApi.js +27 -20
  46. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppProxyContracts.js +5 -0
  47. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppReceiverByWabotProxy.js +65 -0
  48. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppSenderByWabotProxy.js +61 -0
  49. package/dist/src/addon/chat-controller/whatsapp/proxy/WhatsAppWabotProxyConnection.js +45 -0
  50. package/dist/src/{pre-made/module → addon/mindset}/html/HtmlModule.js +7 -7
  51. package/dist/src/core/auth/Auth.js +33 -0
  52. package/dist/src/core/{Persistent.js → entity/Entity.js} +24 -12
  53. package/dist/src/core/env/Env.js +39 -0
  54. package/dist/src/core/error/CustomError.js +15 -0
  55. package/dist/src/core/injection/index.js +4 -0
  56. package/dist/src/core/mapper/Mapper.js +42 -0
  57. package/dist/src/core/password/Password.js +30 -0
  58. package/dist/src/core/random/Random.js +65 -0
  59. package/dist/src/core/storable/Storable.js +8 -0
  60. package/dist/src/core/validation/core/validateArray.js +51 -0
  61. package/dist/src/core/validation/core/validateModel.js +36 -0
  62. package/dist/src/{validation/metadata/@isNumber.js → core/validation/metadata/@isArray.js} +5 -4
  63. package/dist/src/{validation/metadata/@isDate.js → core/validation/metadata/@isModel.js} +5 -4
  64. package/dist/src/{validation → core/validation}/metadata/@isOptional.js +1 -1
  65. package/dist/src/core/validation/metadata/ValidationMetadataStore.js +98 -0
  66. package/dist/src/core/validation/modelInfo.js +9 -0
  67. package/dist/src/{validation/validateModel2.js → core/validation/validate.js} +3 -3
  68. package/dist/src/{validation/metadata → core/validation/validators/is-boolean}/@isBoolean.js +3 -3
  69. package/dist/src/core/validation/validators/is-date/@isDate.js +17 -0
  70. package/dist/src/core/validation/validators/is-in/@isIn.js +18 -0
  71. package/dist/src/core/validation/validators/is-in/validateIsIn.js +12 -0
  72. package/dist/src/{validation/metadata → core/validation/validators/is-not-empty}/@isNotEmpty.js +3 -3
  73. package/dist/src/core/validation/validators/is-number/@isNumber.js +17 -0
  74. package/dist/src/{validation/metadata → core/validation/validators/is-present}/@isPresent.js +3 -3
  75. package/dist/src/{validation/metadata → core/validation/validators/is-string}/@isString.js +3 -3
  76. package/dist/src/{validation/metadata → core/validation/validators/max}/@max.js +3 -3
  77. package/dist/src/{validation/metadata → core/validation/validators/min}/@min.js +3 -3
  78. package/dist/src/feature/async/@command.js +11 -0
  79. package/dist/src/feature/async/@commandHandler.js +12 -0
  80. package/dist/src/feature/async/Async.js +38 -0
  81. package/dist/src/feature/async/Command.js +9 -0
  82. package/dist/src/feature/async/CommandMetadataStore.js +38 -0
  83. package/dist/src/feature/async/Job.js +27 -0
  84. package/dist/src/feature/async/JobRepository.js +31 -0
  85. package/dist/src/feature/async/JobRunner.js +48 -0
  86. package/dist/src/feature/async/JobsEventsHub.js +36 -0
  87. package/dist/src/feature/async/runCommandHandlers.js +29 -0
  88. package/dist/src/{core/chat → feature/chat-bot}/Chat.js +2 -2
  89. package/dist/src/feature/chat-bot/ChatAdapter.js +7 -0
  90. package/dist/src/feature/chat-bot/ChatBot.js +73 -0
  91. package/dist/src/feature/chat-bot/ChatItem.js +24 -0
  92. package/dist/src/feature/chat-bot/ChatMemory.js +10 -0
  93. package/dist/src/{core/chat/repository/IChatRepository.js → feature/chat-bot/ChatRepository.js} +2 -8
  94. package/dist/src/feature/chat-bot/IChatItem.js +3 -0
  95. package/dist/src/{chatbot → feature/chat-bot}/metadata/@chatBot.js +1 -1
  96. package/dist/src/{chatbot → feature/chat-bot}/metadata/ChatBotMetadataStore.js +1 -1
  97. package/dist/src/{controller/channel → feature/chat-controller}/ChatResolver.js +6 -4
  98. package/dist/src/{controller → feature/chat-controller}/metadata/ControllerMetadataStore.js +1 -1
  99. package/dist/src/{controller → feature/chat-controller}/metadata/controller/@chatController.js +1 -1
  100. package/dist/src/feature/chat-controller/runChatControllers.js +83 -0
  101. package/dist/src/{channels → feature}/express/ExpressProvider.js +2 -4
  102. package/dist/src/{channels → feature}/http/HttpServerProvider.js +2 -2
  103. package/dist/src/{mindset → feature/mindset}/IMindset.js +6 -0
  104. package/dist/src/feature/mindset/MindsetOperator.js +180 -0
  105. package/dist/src/{mindset → feature/mindset}/metadata/MindsetMetadataStore.js +1 -1
  106. package/dist/src/{mindset → feature/mindset}/metadata/functions/@mindsetFunction.js +1 -1
  107. package/dist/src/{mindset → feature/mindset}/metadata/mindsets/@mindset.js +1 -1
  108. package/dist/src/{mindset → feature/mindset}/metadata/modules/@mindsetModule.js +1 -2
  109. package/dist/src/{mindset → feature/mindset}/metadata/params/@param.js +1 -1
  110. package/dist/src/feature/money/Money.js +61 -0
  111. package/dist/src/feature/money/MoneyDto.js +22 -0
  112. package/dist/src/{repository → feature}/pg/PgCrudRepository.js +24 -10
  113. package/dist/src/{repository → feature}/pg/PgRepositoryBase.js +2 -2
  114. package/dist/src/feature/rest-controller/injection-tokens.js +4 -0
  115. package/dist/src/{rest-controller/metadata/@post.js → feature/rest-controller/metadata/@middleware.js} +5 -8
  116. package/dist/src/feature/rest-controller/metadata/@onDelete.js +7 -0
  117. package/dist/src/feature/rest-controller/metadata/@onGet.js +7 -0
  118. package/dist/src/feature/rest-controller/metadata/@onPost.js +7 -0
  119. package/dist/src/feature/rest-controller/metadata/@onPut.js +7 -0
  120. package/dist/src/{rest-controller → feature/rest-controller}/metadata/@restController.js +2 -2
  121. package/dist/src/{rest-controller → feature/rest-controller}/metadata/RestControllerMetadataStore.js +14 -1
  122. package/dist/src/{rest-controller/metadata/@get.js → feature/rest-controller/metadata/methodDecorator.js} +5 -5
  123. package/dist/src/feature/rest-controller/runRestControllers.js +103 -0
  124. package/dist/src/{channels → feature}/socket/SocketServerProvider.js +2 -2
  125. package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +16 -0
  126. package/dist/src/feature/socket-controller/metadata/@socketConnection.js +18 -0
  127. package/dist/src/feature/socket-controller/metadata/@socketController.js +15 -0
  128. package/dist/src/feature/socket-controller/metadata/@socketEvent.js +18 -0
  129. package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +65 -0
  130. package/dist/src/feature/socket-controller/runSocketControllers.js +99 -0
  131. package/dist/src/index.d.ts +1219 -718
  132. package/dist/src/index.js +147 -102
  133. package/package.json +8 -2
  134. package/dist/src/_virtual/_commonjsHelpers.js +0 -5
  135. package/dist/src/_virtual/cjs.js +0 -7
  136. package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +0 -107
  137. package/dist/src/ai/openia/OpenaiChatBotAdapter.js +0 -88
  138. package/dist/src/channels/cmd/@cmd.js +0 -18
  139. package/dist/src/channels/cmd/CmdChannel.js +0 -73
  140. package/dist/src/channels/wabot/WabotDevConnection.js +0 -57
  141. package/dist/src/channels/wabot/WabotDevSocketContracts.js +0 -10
  142. package/dist/src/channels/whatsapp/@whatsapp.js +0 -20
  143. package/dist/src/channels/whatsapp/WhatsAppReceiver.js +0 -59
  144. package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +0 -32
  145. package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +0 -63
  146. package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +0 -61
  147. package/dist/src/chatbot/ChatBot.js +0 -51
  148. package/dist/src/chatbot/ChatBotAdapter.js +0 -72
  149. package/dist/src/controller/channel/UserResolver.js +0 -21
  150. package/dist/src/core/IMessageContext.js +0 -12
  151. package/dist/src/core/chat/ChatItem.js +0 -15
  152. package/dist/src/core/chat/repository/IChatMemory.js +0 -10
  153. package/dist/src/core/user/IUserRepository.js +0 -19
  154. package/dist/src/core/user/User.js +0 -26
  155. package/dist/src/env/WabotEnv.js +0 -27
  156. package/dist/src/injection/index.js +0 -4
  157. package/dist/src/mindset/MindsetOperator.js +0 -101
  158. package/dist/src/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +0 -90
  159. package/dist/src/node_modules/deepmerge/dist/cjs.js +0 -142
  160. package/dist/src/node_modules/dom-serializer/lib/esm/foreignNames.js +0 -102
  161. package/dist/src/node_modules/dom-serializer/lib/esm/index.js +0 -186
  162. package/dist/src/node_modules/domelementtype/lib/esm/index.js +0 -53
  163. package/dist/src/node_modules/domhandler/lib/esm/index.js +0 -148
  164. package/dist/src/node_modules/domhandler/lib/esm/node.js +0 -334
  165. package/dist/src/node_modules/entities/lib/esm/decode.js +0 -458
  166. package/dist/src/node_modules/entities/lib/esm/decode_codepoint.js +0 -62
  167. package/dist/src/node_modules/entities/lib/esm/escape.js +0 -99
  168. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -8
  169. package/dist/src/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -8
  170. package/dist/src/node_modules/html-to-text/lib/html-to-text.js +0 -2147
  171. package/dist/src/node_modules/htmlparser2/lib/esm/Parser.js +0 -491
  172. package/dist/src/node_modules/htmlparser2/lib/esm/Tokenizer.js +0 -928
  173. package/dist/src/node_modules/htmlparser2/lib/esm/index.js +0 -18
  174. package/dist/src/node_modules/leac/lib/leac.js +0 -3
  175. package/dist/src/node_modules/parseley/lib/parseley.js +0 -270
  176. package/dist/src/node_modules/peberminta/lib/core.js +0 -171
  177. package/dist/src/node_modules/selderee/lib/selderee.js +0 -380
  178. package/dist/src/pre-made/module/authentication/AuthenticationModule.js +0 -97
  179. package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -25
  180. package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -25
  181. package/dist/src/pre-made/module/register-user/RegisterUserModule.js +0 -56
  182. package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -25
  183. package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -33
  184. package/dist/src/pre-made/repository/user/ram/RamUserRepository.js +0 -27
  185. package/dist/src/pre-made/service/EmailService.js +0 -13
  186. package/dist/src/pre-made/service/OtpService.js +0 -14
  187. package/dist/src/rest-controller/runRestControllers.js +0 -74
  188. package/dist/src/server/prepareChatContainer.js +0 -43
  189. package/dist/src/server/runChannel.js +0 -27
  190. package/dist/src/server/runServer.js +0 -40
  191. package/dist/src/validation/metadata/@validable.js +0 -14
  192. package/dist/src/validation/metadata/ValidationMetadataStore.js +0 -55
  193. package/dist/src/validation/validators/validateModel.js +0 -47
  194. /package/dist/src/{pre-made/repository/chat → addon/chat-bot}/ram/RamChatMemory.js +0 -0
  195. /package/dist/src/{channels → addon/chat-controller}/telegram/TelegramChannelConfig.js +0 -0
  196. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppChannelConfig.js +0 -0
  197. /package/dist/src/{channels → addon/chat-controller}/whatsapp/WhatsAppRepository.js +0 -0
  198. /package/dist/src/{injection → core/injection}/Container.js +0 -0
  199. /package/dist/src/{logger → core/logger}/Logger.js +0 -0
  200. /package/dist/src/{validation/validators → core/validation/core}/validateIsOptional.js +0 -0
  201. /package/dist/src/{validation/validators → core/validation/validators/is-boolean}/validateIsBoolean.js +0 -0
  202. /package/dist/src/{validation/validators → core/validation/validators/is-date}/validateIsDate.js +0 -0
  203. /package/dist/src/{validation/validators → core/validation/validators/is-not-empty}/validateIsNotEmpty.js +0 -0
  204. /package/dist/src/{validation/validators → core/validation/validators/is-number}/validateIsNumber.js +0 -0
  205. /package/dist/src/{validation/validators → core/validation/validators/is-present}/validateIsPresent.js +0 -0
  206. /package/dist/src/{validation/validators → core/validation/validators/is-string}/validateIsString.js +0 -0
  207. /package/dist/src/{validation/validators → core/validation/validators/max}/validateMax.js +0 -0
  208. /package/dist/src/{validation/validators → core/validation/validators/min}/validateMin.js +0 -0
  209. /package/dist/src/{mindset → feature/mindset}/metadata/functions/decoratorNames.js +0 -0
  210. /package/dist/src/{mindset → feature/mindset}/metadata/mindsets/decoratorNames.js +0 -0
  211. /package/dist/src/{mindset → feature/mindset}/metadata/modules/decoratorNames.js +0 -0
  212. /package/dist/src/{mindset → feature/mindset}/metadata/params/decoratorNames.js +0 -0
@@ -1,90 +0,0 @@
1
- import { Picker } from '../../../selderee/lib/selderee.js';
2
- import { isTag } from '../../../domhandler/lib/esm/node.js';
3
-
4
- function hp2Builder(nodes) {
5
- return new Picker(handleArray(nodes));
6
- }
7
- function handleArray(nodes) {
8
- const matchers = nodes.map(handleNode);
9
- return (el, ...tail) => matchers.flatMap(m => m(el, ...tail));
10
- }
11
- function handleNode(node) {
12
- switch (node.type) {
13
- case 'terminal': {
14
- const result = [node.valueContainer];
15
- return (el, ...tail) => result;
16
- }
17
- case 'tagName':
18
- return handleTagName(node);
19
- case 'attrValue':
20
- return handleAttrValueName(node);
21
- case 'attrPresence':
22
- return handleAttrPresenceName(node);
23
- case 'pushElement':
24
- return handlePushElementNode(node);
25
- case 'popElement':
26
- return handlePopElementNode(node);
27
- }
28
- }
29
- function handleTagName(node) {
30
- const variants = {};
31
- for (const variant of node.variants) {
32
- variants[variant.value] = handleArray(variant.cont);
33
- }
34
- return (el, ...tail) => {
35
- const continuation = variants[el.name];
36
- return (continuation) ? continuation(el, ...tail) : [];
37
- };
38
- }
39
- function handleAttrPresenceName(node) {
40
- const attrName = node.name;
41
- const continuation = handleArray(node.cont);
42
- return (el, ...tail) => (Object.prototype.hasOwnProperty.call(el.attribs, attrName))
43
- ? continuation(el, ...tail)
44
- : [];
45
- }
46
- function handleAttrValueName(node) {
47
- const callbacks = [];
48
- for (const matcher of node.matchers) {
49
- const predicate = matcher.predicate;
50
- const continuation = handleArray(matcher.cont);
51
- callbacks.push((attr, el, ...tail) => (predicate(attr) ? continuation(el, ...tail) : []));
52
- }
53
- const attrName = node.name;
54
- return (el, ...tail) => {
55
- const attr = el.attribs[attrName];
56
- return (attr || attr === '')
57
- ? callbacks.flatMap(cb => cb(attr, el, ...tail))
58
- : [];
59
- };
60
- }
61
- function handlePushElementNode(node) {
62
- const continuation = handleArray(node.cont);
63
- const leftElementGetter = (node.combinator === '+')
64
- ? getPrecedingElement
65
- : getParentElement;
66
- return (el, ...tail) => {
67
- const next = leftElementGetter(el);
68
- if (next === null) {
69
- return [];
70
- }
71
- return continuation(next, el, ...tail);
72
- };
73
- }
74
- const getPrecedingElement = (el) => {
75
- const prev = el.prev;
76
- if (prev === null) {
77
- return null;
78
- }
79
- return (isTag(prev)) ? prev : getPrecedingElement(prev);
80
- };
81
- const getParentElement = (el) => {
82
- const parent = el.parent;
83
- return (parent && isTag(parent)) ? parent : null;
84
- };
85
- function handlePopElementNode(node) {
86
- const continuation = handleArray(node.cont);
87
- return (el, next, ...tail) => continuation(next, ...tail);
88
- }
89
-
90
- export { hp2Builder };
@@ -1,142 +0,0 @@
1
- var cjs;
2
- var hasRequiredCjs;
3
-
4
- function requireCjs () {
5
- if (hasRequiredCjs) return cjs;
6
- hasRequiredCjs = 1;
7
-
8
- var isMergeableObject = function isMergeableObject(value) {
9
- return isNonNullObject(value)
10
- && !isSpecial(value)
11
- };
12
-
13
- function isNonNullObject(value) {
14
- return !!value && typeof value === 'object'
15
- }
16
-
17
- function isSpecial(value) {
18
- var stringValue = Object.prototype.toString.call(value);
19
-
20
- return stringValue === '[object RegExp]'
21
- || stringValue === '[object Date]'
22
- || isReactElement(value)
23
- }
24
-
25
- // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
26
- var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
27
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
28
-
29
- function isReactElement(value) {
30
- return value.$$typeof === REACT_ELEMENT_TYPE
31
- }
32
-
33
- function emptyTarget(val) {
34
- return Array.isArray(val) ? [] : {}
35
- }
36
-
37
- function cloneUnlessOtherwiseSpecified(value, options) {
38
- return (options.clone !== false && options.isMergeableObject(value))
39
- ? deepmerge(emptyTarget(value), value, options)
40
- : value
41
- }
42
-
43
- function defaultArrayMerge(target, source, options) {
44
- return target.concat(source).map(function(element) {
45
- return cloneUnlessOtherwiseSpecified(element, options)
46
- })
47
- }
48
-
49
- function getMergeFunction(key, options) {
50
- if (!options.customMerge) {
51
- return deepmerge
52
- }
53
- var customMerge = options.customMerge(key);
54
- return typeof customMerge === 'function' ? customMerge : deepmerge
55
- }
56
-
57
- function getEnumerableOwnPropertySymbols(target) {
58
- return Object.getOwnPropertySymbols
59
- ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
60
- return Object.propertyIsEnumerable.call(target, symbol)
61
- })
62
- : []
63
- }
64
-
65
- function getKeys(target) {
66
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
67
- }
68
-
69
- function propertyIsOnObject(object, property) {
70
- try {
71
- return property in object
72
- } catch(_) {
73
- return false
74
- }
75
- }
76
-
77
- // Protects from prototype poisoning and unexpected merging up the prototype chain.
78
- function propertyIsUnsafe(target, key) {
79
- return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
80
- && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
81
- && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
82
- }
83
-
84
- function mergeObject(target, source, options) {
85
- var destination = {};
86
- if (options.isMergeableObject(target)) {
87
- getKeys(target).forEach(function(key) {
88
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
89
- });
90
- }
91
- getKeys(source).forEach(function(key) {
92
- if (propertyIsUnsafe(target, key)) {
93
- return
94
- }
95
-
96
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
97
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
98
- } else {
99
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
100
- }
101
- });
102
- return destination
103
- }
104
-
105
- function deepmerge(target, source, options) {
106
- options = options || {};
107
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
108
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
109
- // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
110
- // implementations can use it. The caller may not replace it.
111
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
112
-
113
- var sourceIsArray = Array.isArray(source);
114
- var targetIsArray = Array.isArray(target);
115
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
116
-
117
- if (!sourceAndTargetTypesMatch) {
118
- return cloneUnlessOtherwiseSpecified(source, options)
119
- } else if (sourceIsArray) {
120
- return options.arrayMerge(target, source, options)
121
- } else {
122
- return mergeObject(target, source, options)
123
- }
124
- }
125
-
126
- deepmerge.all = function deepmergeAll(array, options) {
127
- if (!Array.isArray(array)) {
128
- throw new Error('first argument should be an array')
129
- }
130
-
131
- return array.reduce(function(prev, next) {
132
- return deepmerge(prev, next, options)
133
- }, {})
134
- };
135
-
136
- var deepmerge_1 = deepmerge;
137
-
138
- cjs = deepmerge_1;
139
- return cjs;
140
- }
141
-
142
- export { requireCjs as __require };
@@ -1,102 +0,0 @@
1
- const elementNames = new Map([
2
- "altGlyph",
3
- "altGlyphDef",
4
- "altGlyphItem",
5
- "animateColor",
6
- "animateMotion",
7
- "animateTransform",
8
- "clipPath",
9
- "feBlend",
10
- "feColorMatrix",
11
- "feComponentTransfer",
12
- "feComposite",
13
- "feConvolveMatrix",
14
- "feDiffuseLighting",
15
- "feDisplacementMap",
16
- "feDistantLight",
17
- "feDropShadow",
18
- "feFlood",
19
- "feFuncA",
20
- "feFuncB",
21
- "feFuncG",
22
- "feFuncR",
23
- "feGaussianBlur",
24
- "feImage",
25
- "feMerge",
26
- "feMergeNode",
27
- "feMorphology",
28
- "feOffset",
29
- "fePointLight",
30
- "feSpecularLighting",
31
- "feSpotLight",
32
- "feTile",
33
- "feTurbulence",
34
- "foreignObject",
35
- "glyphRef",
36
- "linearGradient",
37
- "radialGradient",
38
- "textPath",
39
- ].map((val) => [val.toLowerCase(), val]));
40
- const attributeNames = new Map([
41
- "definitionURL",
42
- "attributeName",
43
- "attributeType",
44
- "baseFrequency",
45
- "baseProfile",
46
- "calcMode",
47
- "clipPathUnits",
48
- "diffuseConstant",
49
- "edgeMode",
50
- "filterUnits",
51
- "glyphRef",
52
- "gradientTransform",
53
- "gradientUnits",
54
- "kernelMatrix",
55
- "kernelUnitLength",
56
- "keyPoints",
57
- "keySplines",
58
- "keyTimes",
59
- "lengthAdjust",
60
- "limitingConeAngle",
61
- "markerHeight",
62
- "markerUnits",
63
- "markerWidth",
64
- "maskContentUnits",
65
- "maskUnits",
66
- "numOctaves",
67
- "pathLength",
68
- "patternContentUnits",
69
- "patternTransform",
70
- "patternUnits",
71
- "pointsAtX",
72
- "pointsAtY",
73
- "pointsAtZ",
74
- "preserveAlpha",
75
- "preserveAspectRatio",
76
- "primitiveUnits",
77
- "refX",
78
- "refY",
79
- "repeatCount",
80
- "repeatDur",
81
- "requiredExtensions",
82
- "requiredFeatures",
83
- "specularConstant",
84
- "specularExponent",
85
- "spreadMethod",
86
- "startOffset",
87
- "stdDeviation",
88
- "stitchTiles",
89
- "surfaceScale",
90
- "systemLanguage",
91
- "tableValues",
92
- "targetX",
93
- "targetY",
94
- "textLength",
95
- "viewBox",
96
- "viewTarget",
97
- "xChannelSelector",
98
- "yChannelSelector",
99
- "zoomAndPan",
100
- ].map((val) => [val.toLowerCase(), val]));
101
-
102
- export { attributeNames, elementNames };
@@ -1,186 +0,0 @@
1
- import { Text, Tag, Style, Script, CDATA, Comment, Directive, Doctype, Root } from '../../../domelementtype/lib/esm/index.js';
2
- import { elementNames, attributeNames } from './foreignNames.js';
3
- import { encodeXML, escapeText, escapeAttribute } from '../../../entities/lib/esm/escape.js';
4
-
5
- /*
6
- * Module dependencies
7
- */
8
- const unencodedElements = new Set([
9
- "style",
10
- "script",
11
- "xmp",
12
- "iframe",
13
- "noembed",
14
- "noframes",
15
- "plaintext",
16
- "noscript",
17
- ]);
18
- function replaceQuotes(value) {
19
- return value.replace(/"/g, """);
20
- }
21
- /**
22
- * Format attributes
23
- */
24
- function formatAttributes(attributes, opts) {
25
- var _a;
26
- if (!attributes)
27
- return;
28
- const encode = ((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) === false
29
- ? replaceQuotes
30
- : opts.xmlMode || opts.encodeEntities !== "utf8"
31
- ? encodeXML
32
- : escapeAttribute;
33
- return Object.keys(attributes)
34
- .map((key) => {
35
- var _a, _b;
36
- const value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : "";
37
- if (opts.xmlMode === "foreign") {
38
- /* Fix up mixed-case attribute names */
39
- key = (_b = attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
40
- }
41
- if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
42
- return key;
43
- }
44
- return `${key}="${encode(value)}"`;
45
- })
46
- .join(" ");
47
- }
48
- /**
49
- * Self-enclosing tags
50
- */
51
- const singleTag = new Set([
52
- "area",
53
- "base",
54
- "basefont",
55
- "br",
56
- "col",
57
- "command",
58
- "embed",
59
- "frame",
60
- "hr",
61
- "img",
62
- "input",
63
- "isindex",
64
- "keygen",
65
- "link",
66
- "meta",
67
- "param",
68
- "source",
69
- "track",
70
- "wbr",
71
- ]);
72
- /**
73
- * Renders a DOM node or an array of DOM nodes to a string.
74
- *
75
- * Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
76
- *
77
- * @param node Node to be rendered.
78
- * @param options Changes serialization behavior
79
- */
80
- function render(node, options = {}) {
81
- const nodes = "length" in node ? node : [node];
82
- let output = "";
83
- for (let i = 0; i < nodes.length; i++) {
84
- output += renderNode(nodes[i], options);
85
- }
86
- return output;
87
- }
88
- function renderNode(node, options) {
89
- switch (node.type) {
90
- case Root:
91
- return render(node.children, options);
92
- // @ts-expect-error We don't use `Doctype` yet
93
- case Doctype:
94
- case Directive:
95
- return renderDirective(node);
96
- case Comment:
97
- return renderComment(node);
98
- case CDATA:
99
- return renderCdata(node);
100
- case Script:
101
- case Style:
102
- case Tag:
103
- return renderTag(node, options);
104
- case Text:
105
- return renderText(node, options);
106
- }
107
- }
108
- const foreignModeIntegrationPoints = new Set([
109
- "mi",
110
- "mo",
111
- "mn",
112
- "ms",
113
- "mtext",
114
- "annotation-xml",
115
- "foreignObject",
116
- "desc",
117
- "title",
118
- ]);
119
- const foreignElements = new Set(["svg", "math"]);
120
- function renderTag(elem, opts) {
121
- var _a;
122
- // Handle SVG / MathML in HTML
123
- if (opts.xmlMode === "foreign") {
124
- /* Fix up mixed-case element names */
125
- elem.name = (_a = elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
126
- /* Exit foreign mode at integration points */
127
- if (elem.parent &&
128
- foreignModeIntegrationPoints.has(elem.parent.name)) {
129
- opts = { ...opts, xmlMode: false };
130
- }
131
- }
132
- if (!opts.xmlMode && foreignElements.has(elem.name)) {
133
- opts = { ...opts, xmlMode: "foreign" };
134
- }
135
- let tag = `<${elem.name}`;
136
- const attribs = formatAttributes(elem.attribs, opts);
137
- if (attribs) {
138
- tag += ` ${attribs}`;
139
- }
140
- if (elem.children.length === 0 &&
141
- (opts.xmlMode
142
- ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
143
- opts.selfClosingTags !== false
144
- : // User explicitly asked for self-closing tags, even in HTML mode
145
- opts.selfClosingTags && singleTag.has(elem.name))) {
146
- if (!opts.xmlMode)
147
- tag += " ";
148
- tag += "/>";
149
- }
150
- else {
151
- tag += ">";
152
- if (elem.children.length > 0) {
153
- tag += render(elem.children, opts);
154
- }
155
- if (opts.xmlMode || !singleTag.has(elem.name)) {
156
- tag += `</${elem.name}>`;
157
- }
158
- }
159
- return tag;
160
- }
161
- function renderDirective(elem) {
162
- return `<${elem.data}>`;
163
- }
164
- function renderText(elem, opts) {
165
- var _a;
166
- let data = elem.data || "";
167
- // If entities weren't decoded, no need to encode them back
168
- if (((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) !== false &&
169
- !(!opts.xmlMode &&
170
- elem.parent &&
171
- unencodedElements.has(elem.parent.name))) {
172
- data =
173
- opts.xmlMode || opts.encodeEntities !== "utf8"
174
- ? encodeXML(data)
175
- : escapeText(data);
176
- }
177
- return data;
178
- }
179
- function renderCdata(elem) {
180
- return `<![CDATA[${elem.children[0].data}]]>`;
181
- }
182
- function renderComment(elem) {
183
- return `<!--${elem.data}-->`;
184
- }
185
-
186
- export { render as default, render };
@@ -1,53 +0,0 @@
1
- /** Types of elements found in htmlparser2's DOM */
2
- var ElementType;
3
- (function (ElementType) {
4
- /** Type for the root element of a document */
5
- ElementType["Root"] = "root";
6
- /** Type for Text */
7
- ElementType["Text"] = "text";
8
- /** Type for <? ... ?> */
9
- ElementType["Directive"] = "directive";
10
- /** Type for <!-- ... --> */
11
- ElementType["Comment"] = "comment";
12
- /** Type for <script> tags */
13
- ElementType["Script"] = "script";
14
- /** Type for <style> tags */
15
- ElementType["Style"] = "style";
16
- /** Type for Any tag */
17
- ElementType["Tag"] = "tag";
18
- /** Type for <![CDATA[ ... ]]> */
19
- ElementType["CDATA"] = "cdata";
20
- /** Type for <!doctype ...> */
21
- ElementType["Doctype"] = "doctype";
22
- })(ElementType || (ElementType = {}));
23
- /**
24
- * Tests whether an element is a tag or not.
25
- *
26
- * @param elem Element to test
27
- */
28
- function isTag(elem) {
29
- return (elem.type === ElementType.Tag ||
30
- elem.type === ElementType.Script ||
31
- elem.type === ElementType.Style);
32
- }
33
- // Exports for backwards compatibility
34
- /** Type for the root element of a document */
35
- const Root = ElementType.Root;
36
- /** Type for Text */
37
- const Text = ElementType.Text;
38
- /** Type for <? ... ?> */
39
- const Directive = ElementType.Directive;
40
- /** Type for <!-- ... --> */
41
- const Comment = ElementType.Comment;
42
- /** Type for <script> tags */
43
- const Script = ElementType.Script;
44
- /** Type for <style> tags */
45
- const Style = ElementType.Style;
46
- /** Type for Any tag */
47
- const Tag = ElementType.Tag;
48
- /** Type for <![CDATA[ ... ]]> */
49
- const CDATA = ElementType.CDATA;
50
- /** Type for <!doctype ...> */
51
- const Doctype = ElementType.Doctype;
52
-
53
- export { CDATA, Comment, Directive, Doctype, ElementType, Root, Script, Style, Tag, Text, isTag };