@wabot-dev/framework 0.0.17 → 0.0.50
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.
- package/dist/src/_virtual/_commonjsHelpers.js +5 -0
- package/dist/src/_virtual/cjs.js +7 -0
- package/dist/src/ai/deepseek/DeepSeekChatBotAdapter.js +12 -13
- package/dist/src/ai/openia/OpenaiChatBotAdapter.js +9 -7
- package/dist/src/channels/cmd/@cmd.js +0 -4
- package/dist/src/channels/cmd/CmdChannel.js +0 -4
- package/dist/src/channels/express/ExpressProvider.js +46 -0
- package/dist/src/channels/http/HttpServerProvider.js +31 -0
- package/dist/src/channels/{socket-io → socket}/@socket.js +0 -4
- package/dist/src/channels/{socket-io → socket}/SocketChannel.js +12 -11
- package/dist/src/channels/socket/SocketServerProvider.js +50 -0
- package/dist/src/channels/telegram/@telegram.js +0 -4
- package/dist/src/channels/telegram/TelegramChannel.js +0 -4
- package/dist/src/channels/wabot/WabotDevConnection.js +57 -0
- package/dist/src/channels/{whatsapp/WhatsAppDevSocketContracts.js → wabot/WabotDevSocketContracts.js} +3 -3
- package/dist/src/channels/whatsapp/@whatsapp.js +0 -4
- package/dist/src/channels/whatsapp/EnvWhatsAppRepository.js +49 -0
- package/dist/src/channels/whatsapp/PgWhatsAppRepository.js +41 -0
- package/dist/src/channels/whatsapp/WhatsApp.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +33 -32
- package/dist/src/channels/whatsapp/{WhatsAppConnection.js → WhatsAppReceiver.js} +4 -6
- package/dist/src/channels/whatsapp/WhatsAppReceiverByDevConnection.js +32 -0
- package/dist/src/channels/whatsapp/WhatsAppReceiverByWebHook.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppRepository.js +10 -0
- package/dist/src/channels/whatsapp/WhatsAppSender.js +93 -17
- package/dist/src/channels/whatsapp/WhatsAppSenderByCloudApi.js +124 -0
- package/dist/src/channels/whatsapp/WhatsAppSenderByDevConnection.js +61 -0
- package/dist/src/chatbot/ChatBotAdapter.js +1 -5
- package/dist/src/chatbot/metadata/@chatBot.js +0 -5
- package/dist/src/chatbot/metadata/ChatBotMetadataStore.js +0 -5
- package/dist/src/controller/metadata/ControllerMetadataStore.js +0 -2
- package/dist/src/controller/metadata/controller/@chatController.js +0 -2
- package/dist/src/core/IMessageContext.js +0 -2
- package/dist/src/env/WabotEnv.js +6 -0
- package/dist/src/index.d.ts +419 -201
- package/dist/src/index.js +55 -28
- package/dist/src/mindset/MindsetOperator.js +1 -3
- package/dist/src/mindset/metadata/MindsetMetadataStore.js +0 -2
- package/dist/src/mindset/metadata/mindsets/@mindset.js +0 -2
- package/dist/src/mindset/metadata/modules/@mindsetModule.js +0 -2
- package/dist/src/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +90 -0
- package/dist/src/node_modules/deepmerge/dist/cjs.js +142 -0
- package/dist/src/node_modules/dom-serializer/lib/esm/foreignNames.js +102 -0
- package/dist/src/node_modules/dom-serializer/lib/esm/index.js +186 -0
- package/dist/src/node_modules/domelementtype/lib/esm/index.js +53 -0
- package/dist/src/node_modules/domhandler/lib/esm/index.js +148 -0
- package/dist/src/node_modules/domhandler/lib/esm/node.js +334 -0
- package/dist/src/node_modules/entities/lib/esm/decode.js +458 -0
- package/dist/src/node_modules/entities/lib/esm/decode_codepoint.js +62 -0
- package/dist/src/node_modules/entities/lib/esm/escape.js +99 -0
- package/dist/src/node_modules/entities/lib/esm/generated/decode-data-html.js +8 -0
- package/dist/src/node_modules/entities/lib/esm/generated/decode-data-xml.js +8 -0
- package/dist/src/node_modules/html-to-text/lib/html-to-text.js +2147 -0
- package/dist/src/node_modules/htmlparser2/lib/esm/Parser.js +491 -0
- package/dist/src/node_modules/htmlparser2/lib/esm/Tokenizer.js +928 -0
- package/dist/src/node_modules/htmlparser2/lib/esm/index.js +18 -0
- package/dist/src/node_modules/leac/lib/leac.js +3 -0
- package/dist/src/node_modules/parseley/lib/parseley.js +270 -0
- package/dist/src/node_modules/peberminta/lib/core.js +171 -0
- package/dist/src/node_modules/selderee/lib/selderee.js +380 -0
- package/dist/src/pre-made/module/authentication/requests/SendOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/authentication/requests/ValidateOneTimePasswordRequest.js +0 -2
- package/dist/src/pre-made/module/html/HtmlModule.js +70 -0
- package/dist/src/pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js +0 -2
- package/dist/src/pre-made/repository/chat/pg/PgChatMemory.js +1 -7
- package/dist/src/pre-made/repository/chat/pg/PgChatRepository.js +0 -5
- package/dist/src/pre-made/repository/user/pg/PgUserRepository.js +0 -5
- package/dist/src/repository/pg/PgCrudRepository.js +0 -1
- package/dist/src/rest-controller/metadata/@get.js +19 -0
- package/dist/src/rest-controller/metadata/@post.js +19 -0
- package/dist/src/rest-controller/metadata/@restController.js +15 -0
- package/dist/src/rest-controller/metadata/RestControllerMetadataStore.js +37 -0
- package/dist/src/rest-controller/runRestControllers.js +74 -0
- package/dist/src/server/prepareChatContainer.js +4 -4
- package/dist/src/server/runChannel.js +2 -10
- package/dist/src/server/runServer.js +0 -43
- package/dist/src/validation/metadata/@isBoolean.js +17 -0
- package/dist/src/validation/metadata/@isDate.js +17 -0
- package/dist/src/validation/metadata/@isNotEmpty.js +17 -0
- package/dist/src/validation/metadata/@isNumber.js +17 -0
- package/dist/src/validation/metadata/@isOptional.js +17 -0
- package/dist/src/validation/metadata/@isPresent.js +17 -0
- package/dist/src/validation/metadata/@isString.js +17 -0
- package/dist/src/validation/metadata/@max.js +18 -0
- package/dist/src/validation/metadata/@min.js +18 -0
- package/dist/src/validation/metadata/@validable.js +14 -0
- package/dist/src/validation/metadata/ValidationMetadataStore.js +55 -0
- package/dist/src/validation/validateModel2.js +11 -0
- package/dist/src/validation/validators/validateIsBoolean.js +12 -0
- package/dist/src/validation/validators/validateIsDate.js +16 -0
- package/dist/src/validation/validators/validateIsNotEmpty.js +12 -0
- package/dist/src/validation/validators/validateIsNumber.js +12 -0
- package/dist/src/validation/validators/validateIsOptional.js +5 -0
- package/dist/src/validation/validators/validateIsPresent.js +12 -0
- package/dist/src/validation/validators/validateIsString.js +12 -0
- package/dist/src/validation/validators/validateMax.js +17 -0
- package/dist/src/validation/validators/validateMin.js +17 -0
- package/dist/src/validation/validators/validateModel.js +47 -0
- package/package.json +4 -6
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +0 -69
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +0 -39
- package/dist/src/controller/express/Express.js +0 -5
- package/dist/src/controller/socket.io/SocketIO.js +0 -5
- package/dist/src/mindset/metadata/params/@isOptional.js +0 -21
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatMemory.js +0 -23
- package/dist/src/pre-made/repository/chat/sqlite/SqliteChatRepository.js +0 -30
- package/dist/src/pre-made/repository/user/sqlite/SqliteUserRepository.js +0 -23
- package/dist/src/repository/sqlite/SqliteCrudRepository.js +0 -85
- package/dist/src/repository/sqlite/SqlitePersistentMapper.js +0 -17
- /package/dist/src/channels/{socket-io → socket}/SocketChannelConfig.js +0 -0
package/dist/src/index.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
export { OpenaiChatBotAdapter } from './ai/openia/OpenaiChatBotAdapter.js';
|
|
2
1
|
export { DeepSeekChatBotAdapter } from './ai/deepseek/DeepSeekChatBotAdapter.js';
|
|
2
|
+
export { OpenaiChatBotAdapter } from './ai/openia/OpenaiChatBotAdapter.js';
|
|
3
3
|
export { cmd } from './channels/cmd/@cmd.js';
|
|
4
4
|
export { CmdChannel } from './channels/cmd/CmdChannel.js';
|
|
5
|
+
export { ExpressProvider } from './channels/express/ExpressProvider.js';
|
|
6
|
+
export { HttpServerProvider } from './channels/http/HttpServerProvider.js';
|
|
7
|
+
export { socket } from './channels/socket/@socket.js';
|
|
8
|
+
export { SocketChannel } from './channels/socket/SocketChannel.js';
|
|
9
|
+
export { SocketChannelConfig } from './channels/socket/SocketChannelConfig.js';
|
|
10
|
+
export { SocketServerProvider } from './channels/socket/SocketServerProvider.js';
|
|
5
11
|
export { telegram } from './channels/telegram/@telegram.js';
|
|
6
12
|
export { TelegramChannelConfig } from './channels/telegram/TelegramChannelConfig.js';
|
|
7
13
|
export { TelegramChannel } from './channels/telegram/TelegramChannel.js';
|
|
8
14
|
export { whatsapp } from './channels/whatsapp/@whatsapp.js';
|
|
15
|
+
export { WhatsApp } from './channels/whatsapp/WhatsApp.js';
|
|
9
16
|
export { WhatsAppChannel } from './channels/whatsapp/WhatsAppChannel.js';
|
|
10
17
|
export { WhatsappChannelConfig } from './channels/whatsapp/WhatsAppChannelConfig.js';
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
18
|
+
export { WhatsAppReceiver } from './channels/whatsapp/WhatsAppReceiver.js';
|
|
19
|
+
export { WhatsAppReceiverByDevConnection } from './channels/whatsapp/WhatsAppReceiverByDevConnection.js';
|
|
20
|
+
export { WhatsAppReceiverByWebHook } from './channels/whatsapp/WhatsAppReceiverByWebHook.js';
|
|
21
|
+
export { WhatsAppRepository } from './channels/whatsapp/WhatsAppRepository.js';
|
|
15
22
|
export { WhatsAppSender } from './channels/whatsapp/WhatsAppSender.js';
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
23
|
+
export { WhatsAppSenderByDevConnection } from './channels/whatsapp/WhatsAppSenderByDevConnection.js';
|
|
24
|
+
export { WhatsAppSenderByCloudApi } from './channels/whatsapp/WhatsAppSenderByCloudApi.js';
|
|
25
|
+
export { PgWhatsAppRepository } from './channels/whatsapp/PgWhatsAppRepository.js';
|
|
26
|
+
export { EnvWhatsAppRepository } from './channels/whatsapp/EnvWhatsAppRepository.js';
|
|
19
27
|
export { chatBot } from './chatbot/metadata/@chatBot.js';
|
|
20
28
|
export { ChatBotMetadataStore } from './chatbot/metadata/ChatBotMetadataStore.js';
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
29
|
+
export { ChatBot } from './chatbot/ChatBot.js';
|
|
30
|
+
export { ChatBotAdapter } from './chatbot/ChatBotAdapter.js';
|
|
31
|
+
export { ChatResolver } from './controller/channel/ChatResolver.js';
|
|
32
|
+
export { UserResolver } from './controller/channel/UserResolver.js';
|
|
33
|
+
export { chatController } from './controller/metadata/controller/@chatController.js';
|
|
34
|
+
export { ControllerMetadataStore } from './controller/metadata/ControllerMetadataStore.js';
|
|
25
35
|
export { ChatMemory } from './core/chat/repository/IChatMemory.js';
|
|
26
36
|
export { ChatRepository } from './core/chat/repository/IChatRepository.js';
|
|
27
37
|
export { Chat } from './core/chat/Chat.js';
|
|
@@ -30,23 +40,18 @@ export { User } from './core/user/User.js';
|
|
|
30
40
|
export { UserRepository } from './core/user/IUserRepository.js';
|
|
31
41
|
export { MessageContext } from './core/IMessageContext.js';
|
|
32
42
|
export { Persistent } from './core/Persistent.js';
|
|
43
|
+
export { container, inject, injectable, singleton } from './injection/index.js';
|
|
44
|
+
export { mindsetFunction } from './mindset/metadata/functions/@mindsetFunction.js';
|
|
45
|
+
export { MINDSET_FUNCTION_DECORATION_FUNCTION } from './mindset/metadata/functions/decoratorNames.js';
|
|
46
|
+
export { mindset } from './mindset/metadata/mindsets/@mindset.js';
|
|
47
|
+
export { MINDSET_DECORATION_MINDSET } from './mindset/metadata/mindsets/decoratorNames.js';
|
|
33
48
|
export { mindsetModule } from './mindset/metadata/modules/@mindsetModule.js';
|
|
34
49
|
export { MINDSET_MODULE_DECORATION_MODULE } from './mindset/metadata/modules/decoratorNames.js';
|
|
35
|
-
export { isOptional } from './mindset/metadata/params/@isOptional.js';
|
|
36
50
|
export { param } from './mindset/metadata/params/@param.js';
|
|
37
51
|
export { PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM } from './mindset/metadata/params/decoratorNames.js';
|
|
38
|
-
export { Mindset } from './mindset/IMindset.js';
|
|
39
52
|
export { MindsetMetadataStore } from './mindset/metadata/MindsetMetadataStore.js';
|
|
53
|
+
export { Mindset } from './mindset/IMindset.js';
|
|
40
54
|
export { MindsetOperator } from './mindset/MindsetOperator.js';
|
|
41
|
-
export { ChatBot } from './chatbot/ChatBot.js';
|
|
42
|
-
export { ChatBotAdapter } from './chatbot/ChatBotAdapter.js';
|
|
43
|
-
export { ChatResolver } from './controller/channel/ChatResolver.js';
|
|
44
|
-
export { UserResolver } from './controller/channel/UserResolver.js';
|
|
45
|
-
export { chatController } from './controller/metadata/controller/@chatController.js';
|
|
46
|
-
export { ControllerMetadataStore } from './controller/metadata/ControllerMetadataStore.js';
|
|
47
|
-
export { ExpressApp } from './controller/express/Express.js';
|
|
48
|
-
export { SocketIoApp } from './controller/socket.io/SocketIO.js';
|
|
49
|
-
export { container, inject, injectable, singleton } from './injection/index.js';
|
|
50
55
|
export { prepareChatContainer } from './server/prepareChatContainer.js';
|
|
51
56
|
export { runChannel } from './server/runChannel.js';
|
|
52
57
|
export { runServer } from './server/runServer.js';
|
|
@@ -55,21 +60,43 @@ export { ValidateOneTimePasswordRequest } from './pre-made/module/authentication
|
|
|
55
60
|
export { AuthenticationModule } from './pre-made/module/authentication/AuthenticationModule.js';
|
|
56
61
|
export { RegisterUserWithEmailRequest } from './pre-made/module/register-user/requests/RegisterUserWithEmailRequest.js';
|
|
57
62
|
export { RegisterUserModule } from './pre-made/module/register-user/RegisterUserModule.js';
|
|
63
|
+
export { HtmlModule } from './pre-made/module/html/HtmlModule.js';
|
|
58
64
|
export { EmailService } from './pre-made/service/EmailService.js';
|
|
59
65
|
export { OtpService } from './pre-made/service/OtpService.js';
|
|
60
66
|
export { PgUserRepository } from './pre-made/repository/user/pg/PgUserRepository.js';
|
|
61
67
|
export { RamUserRepository } from './pre-made/repository/user/ram/RamUserRepository.js';
|
|
62
|
-
export { SqliteUserRepository } from './pre-made/repository/user/sqlite/SqliteUserRepository.js';
|
|
63
68
|
export { PgChatRepository } from './pre-made/repository/chat/pg/PgChatRepository.js';
|
|
64
69
|
export { PgChatMemory } from './pre-made/repository/chat/pg/PgChatMemory.js';
|
|
65
|
-
export { SqliteChatMemory } from './pre-made/repository/chat/sqlite/SqliteChatMemory.js';
|
|
66
|
-
export { SqliteChatRepository } from './pre-made/repository/chat/sqlite/SqliteChatRepository.js';
|
|
67
70
|
export { RamChatMemory } from './pre-made/repository/chat/ram/RamChatMemory.js';
|
|
68
71
|
export { RamChatRepository } from './pre-made/repository/chat/ram/RamChatRepository.js';
|
|
69
72
|
export { PgCrudRepository } from './repository/pg/PgCrudRepository.js';
|
|
70
73
|
export { PgRepositoryBase } from './repository/pg/PgRepositoryBase.js';
|
|
71
|
-
export { SqliteCrudRepository } from './repository/sqlite/SqliteCrudRepository.js';
|
|
72
|
-
export { SqlitePersistentMapper, sqliteMapperFor } from './repository/sqlite/SqlitePersistentMapper.js';
|
|
73
74
|
export { Logger } from './logger/Logger.js';
|
|
74
75
|
export { WabotEnv } from './env/WabotEnv.js';
|
|
76
|
+
export { get } from './rest-controller/metadata/@get.js';
|
|
77
|
+
export { post } from './rest-controller/metadata/@post.js';
|
|
78
|
+
export { restController } from './rest-controller/metadata/@restController.js';
|
|
79
|
+
export { RestControllerMetadataStore } from './rest-controller/metadata/RestControllerMetadataStore.js';
|
|
80
|
+
export { runRestControllers } from './rest-controller/runRestControllers.js';
|
|
81
|
+
export { isBoolean } from './validation/metadata/@isBoolean.js';
|
|
82
|
+
export { isDate } from './validation/metadata/@isDate.js';
|
|
83
|
+
export { isNotEmpty } from './validation/metadata/@isNotEmpty.js';
|
|
84
|
+
export { isNumber } from './validation/metadata/@isNumber.js';
|
|
85
|
+
export { isOptional } from './validation/metadata/@isOptional.js';
|
|
86
|
+
export { isPresent } from './validation/metadata/@isPresent.js';
|
|
87
|
+
export { isString } from './validation/metadata/@isString.js';
|
|
88
|
+
export { max } from './validation/metadata/@max.js';
|
|
89
|
+
export { min } from './validation/metadata/@min.js';
|
|
90
|
+
export { validable } from './validation/metadata/@validable.js';
|
|
91
|
+
export { ValidationMetadataStore } from './validation/metadata/ValidationMetadataStore.js';
|
|
92
|
+
export { validateIsBoolean } from './validation/validators/validateIsBoolean.js';
|
|
93
|
+
export { validateIsDate } from './validation/validators/validateIsDate.js';
|
|
94
|
+
export { validateIsNotEmpty } from './validation/validators/validateIsNotEmpty.js';
|
|
95
|
+
export { validateIsNumber } from './validation/validators/validateIsNumber.js';
|
|
96
|
+
export { validateIsString } from './validation/validators/validateIsString.js';
|
|
97
|
+
export { validateMax } from './validation/validators/validateMax.js';
|
|
98
|
+
export { validateMin } from './validation/validators/validateMin.js';
|
|
99
|
+
export { validateIsPresent } from './validation/validators/validateIsPresent.js';
|
|
100
|
+
export { validateModel } from './validation/validators/validateModel.js';
|
|
101
|
+
export { validateModel2 } from './validation/validateModel2.js';
|
|
75
102
|
export { Container } from './injection/Container.js';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import { injectable } from '../injection/index.js';
|
|
3
3
|
import { Mindset } from './IMindset.js';
|
|
4
|
-
import '../core/chat/repository/IChatRepository.js';
|
|
5
|
-
import '../core/user/IUserRepository.js';
|
|
6
4
|
import { MindsetMetadataStore } from './metadata/MindsetMetadataStore.js';
|
|
7
5
|
import { Container } from '../injection/Container.js';
|
|
8
6
|
|
|
@@ -62,7 +60,7 @@ let MindsetOperator = class MindsetOperator {
|
|
|
62
60
|
...prev,
|
|
63
61
|
[param.name]: this.toolParam(param),
|
|
64
62
|
}), {}),
|
|
65
|
-
required: fn.params.filter((param) => !param.config.optional).map((param) => param.name)
|
|
63
|
+
required: fn.params.filter((param) => !param.config.optional).map((param) => param.name),
|
|
66
64
|
},
|
|
67
65
|
};
|
|
68
66
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { singleton } from '../../injection/index.js';
|
|
3
|
-
import '../../core/chat/repository/IChatRepository.js';
|
|
4
|
-
import '../../core/user/IUserRepository.js';
|
|
5
3
|
import { MINDSET_FUNCTION_DECORATION_FUNCTION } from './functions/decoratorNames.js';
|
|
6
4
|
import { MINDSET_DECORATION_MINDSET } from './mindsets/decoratorNames.js';
|
|
7
5
|
import { MINDSET_MODULE_DECORATION_MODULE } from './modules/decoratorNames.js';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import '../../../core/chat/repository/IChatRepository.js';
|
|
3
|
-
import '../../../core/user/IUserRepository.js';
|
|
4
2
|
import { container, injectable } from '../../../injection/index.js';
|
|
5
3
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
6
4
|
import { MINDSET_DECORATION_MINDSET } from './decoratorNames.js';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { container, injectable } from '../../../injection/index.js';
|
|
3
|
-
import '../../../core/chat/repository/IChatRepository.js';
|
|
4
|
-
import '../../../core/user/IUserRepository.js';
|
|
5
3
|
import { MindsetMetadataStore } from '../MindsetMetadataStore.js';
|
|
6
4
|
import { MINDSET_MODULE_DECORATION_MODULE } from './decoratorNames.js';
|
|
7
5
|
|
|
@@ -0,0 +1,90 @@
|
|
|
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 };
|
|
@@ -0,0 +1,142 @@
|
|
|
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 };
|
|
@@ -0,0 +1,102 @@
|
|
|
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 };
|