@brandup/ui-app 1.0.1 → 1.0.3
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/cjs/index.js +118 -124
- package/dist/cjs/index.js.map +1 -1
- package/dist/mjs/index.js +118 -124
- package/dist/mjs/index.js.map +1 -1
- package/dist/types.d.ts +4 -2
- package/package.json +3 -18
package/dist/cjs/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const constants$1 = {
|
|
4
|
+
ElemAttributeName: "uiElement",
|
|
5
|
+
ElemPropertyName: "uielement",
|
|
6
|
+
CommandAttributeName: "command",
|
|
7
|
+
CommandExecutingCssClassName: "executing",
|
|
8
|
+
CommandEventName: "uicommand"
|
|
9
|
+
};
|
|
10
|
+
|
|
7
11
|
class UIElement {
|
|
8
|
-
__element
|
|
9
|
-
__events
|
|
10
|
-
|
|
12
|
+
__element;
|
|
13
|
+
__events;
|
|
14
|
+
__commands;
|
|
15
|
+
__destroyCallbacks;
|
|
11
16
|
// Element members
|
|
12
17
|
get element() { return this.__element; }
|
|
13
18
|
setElement(elem) {
|
|
@@ -16,35 +21,33 @@ class UIElement {
|
|
|
16
21
|
if (this.__element || UIElement.hasElement(elem))
|
|
17
22
|
throw "UIElement already defined";
|
|
18
23
|
this.__element = elem;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.defineEvent(
|
|
24
|
+
elem[constants$1.ElemPropertyName] = this;
|
|
25
|
+
elem.dataset[constants$1.ElemAttributeName] = this.typeName;
|
|
26
|
+
this.defineEvent(constants$1.CommandEventName, { cancelable: false, bubbles: true });
|
|
22
27
|
this._onRenderElement(elem);
|
|
23
28
|
}
|
|
24
29
|
// static members
|
|
25
30
|
static hasElement(elem) {
|
|
26
|
-
return !!elem.dataset[ElemAttributeName];
|
|
31
|
+
return !!elem.dataset[constants$1.ElemAttributeName];
|
|
27
32
|
}
|
|
28
33
|
// HTMLElement event members
|
|
29
34
|
defineEvent(eventName, eventOptions) {
|
|
35
|
+
if (!this.__events)
|
|
36
|
+
this.__events = {};
|
|
30
37
|
this.__events[eventName] = eventOptions ? eventOptions : null;
|
|
31
38
|
}
|
|
32
39
|
raiseEvent(eventName, eventArgs) {
|
|
33
|
-
if (!(eventName in this.__events))
|
|
40
|
+
if (!this.__events || !(eventName in this.__events))
|
|
34
41
|
throw new Error(`Not found event "${eventName}".`);
|
|
35
42
|
const eventOptions = this.__events[eventName];
|
|
36
43
|
const eventInit = {};
|
|
37
44
|
if (eventOptions) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
eventInit.cancelable = eventOptions.cancelable;
|
|
42
|
-
if (eventOptions.composed)
|
|
43
|
-
eventInit.composed = eventOptions.composed;
|
|
45
|
+
eventInit.bubbles = eventOptions.bubbles;
|
|
46
|
+
eventInit.cancelable = eventOptions.cancelable;
|
|
47
|
+
eventInit.composed = eventOptions.composed;
|
|
44
48
|
}
|
|
45
|
-
eventInit.detail = eventArgs
|
|
46
|
-
|
|
47
|
-
return this.dispatchEvent(event);
|
|
49
|
+
eventInit.detail = eventArgs;
|
|
50
|
+
return this.dispatchEvent(new CustomEvent(eventName, eventInit));
|
|
48
51
|
}
|
|
49
52
|
addEventListener(type, listener, options) {
|
|
50
53
|
this.__element?.addEventListener(type, listener, options);
|
|
@@ -59,127 +62,112 @@ class UIElement {
|
|
|
59
62
|
}
|
|
60
63
|
// Command members
|
|
61
64
|
registerCommand(name, execute, canExecute) {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
if (!this.__commands)
|
|
66
|
+
this.__commands = {};
|
|
67
|
+
const nornalizedName = name.toLowerCase();
|
|
68
|
+
if (nornalizedName in this.__commands)
|
|
69
|
+
throw new Error(`Command "${name}" already registered.`);
|
|
70
|
+
this.__commands[nornalizedName] = {
|
|
64
71
|
name: name,
|
|
65
72
|
execute,
|
|
66
|
-
canExecute
|
|
67
|
-
isExecuting: false
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
registerAsyncCommand(name, delegate, canExecute) {
|
|
71
|
-
name = this.verifyCommandName(name);
|
|
72
|
-
this.__commandHandlers[name] = {
|
|
73
|
-
name: name,
|
|
74
|
-
delegate,
|
|
75
|
-
canExecute,
|
|
76
|
-
isExecuting: false
|
|
73
|
+
canExecute
|
|
77
74
|
};
|
|
78
75
|
}
|
|
79
76
|
hasCommand(name) {
|
|
80
|
-
return name.toLowerCase() in this.
|
|
77
|
+
return this.__commands && name.toLowerCase() in this.__commands;
|
|
81
78
|
}
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
/** @internal */
|
|
80
|
+
__execCommand(name, target) {
|
|
81
|
+
if (!this.__element || !this.__commands)
|
|
84
82
|
throw new Error("UIElement is not set HTMLElement.");
|
|
85
83
|
const key = name.toLowerCase();
|
|
86
|
-
|
|
84
|
+
const command = this.__commands[key];
|
|
85
|
+
if (!command)
|
|
87
86
|
throw new Error(`Command "${name}" is not registered.`);
|
|
88
87
|
const context = {
|
|
89
|
-
target
|
|
90
|
-
uiElem: this
|
|
91
|
-
transparent: false
|
|
88
|
+
target,
|
|
89
|
+
uiElem: this
|
|
92
90
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return { result: CommandsExecStatus.NotAllow, context };
|
|
91
|
+
if (command.isExecuting)
|
|
92
|
+
return { status: "already", context };
|
|
93
|
+
command.isExecuting = true;
|
|
94
|
+
if (!this._onCanExecCommand(name, target)) {
|
|
95
|
+
delete command.isExecuting;
|
|
96
|
+
return { status: "disallow", context };
|
|
100
97
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
return {
|
|
98
|
+
if (command.canExecute && !command.canExecute(context)) {
|
|
99
|
+
delete command.isExecuting;
|
|
100
|
+
return { status: "disallow", context };
|
|
104
101
|
}
|
|
105
|
-
this.raiseEvent(
|
|
106
|
-
name:
|
|
102
|
+
this.raiseEvent(constants$1.CommandEventName, {
|
|
103
|
+
name: command.name,
|
|
107
104
|
uiElem: this,
|
|
108
105
|
elem: this.__element
|
|
109
106
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
let isAsync;
|
|
108
|
+
try {
|
|
109
|
+
const commandResult = command.execute(context);
|
|
110
|
+
if (commandResult && commandResult instanceof Promise) {
|
|
111
|
+
isAsync = true;
|
|
112
|
+
target.classList.add(constants$1.CommandExecutingCssClassName);
|
|
113
|
+
commandResult
|
|
114
|
+
.finally(() => {
|
|
115
|
+
target.classList.remove(constants$1.CommandExecutingCssClassName);
|
|
116
|
+
delete command.isExecuting;
|
|
117
|
+
});
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let timeoutId = 0;
|
|
123
|
-
const endFunc = () => {
|
|
124
|
-
handler.isExecuting = false;
|
|
125
|
-
elem.classList.remove(CommandExecutingCssClassName);
|
|
126
|
-
};
|
|
127
|
-
const asyncContext = {
|
|
128
|
-
target: elem,
|
|
129
|
-
uiElem: this,
|
|
130
|
-
transparent: context.transparent,
|
|
131
|
-
complate: () => {
|
|
132
|
-
clearTimeout(timeoutId);
|
|
133
|
-
endFunc();
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const handlerResult = handler.delegate(asyncContext);
|
|
137
|
-
if (handlerResult && handlerResult instanceof Promise)
|
|
138
|
-
handlerResult.finally(() => asyncContext.complate());
|
|
139
|
-
if (handler.isExecuting && asyncContext.timeout) {
|
|
140
|
-
timeoutId = window.setTimeout(() => {
|
|
141
|
-
if (asyncContext.timeoutCallback)
|
|
142
|
-
asyncContext.timeoutCallback();
|
|
143
|
-
endFunc();
|
|
144
|
-
}, asyncContext.timeout);
|
|
145
|
-
}
|
|
146
|
-
context.transparent = asyncContext.transparent;
|
|
120
|
+
finally {
|
|
121
|
+
if (!isAsync)
|
|
122
|
+
delete command.isExecuting;
|
|
147
123
|
}
|
|
148
|
-
|
|
149
|
-
throw new Error("Not set command execute flow.");
|
|
150
|
-
return { result: CommandsExecStatus.Success, context: context };
|
|
151
|
-
}
|
|
152
|
-
verifyCommandName(name) {
|
|
153
|
-
const key = name.toLowerCase();
|
|
154
|
-
if (key in this.__commandHandlers)
|
|
155
|
-
throw new Error(`Command "${name}" already registered.`);
|
|
156
|
-
return key;
|
|
157
|
-
}
|
|
158
|
-
_onRenderElement(_elem) {
|
|
159
|
-
return;
|
|
124
|
+
return { status: "success", context: context };
|
|
160
125
|
}
|
|
126
|
+
_onRenderElement(_elem) { }
|
|
161
127
|
_onCanExecCommand(_name, _elem) {
|
|
162
128
|
return true;
|
|
163
129
|
}
|
|
130
|
+
onDestroy(callback) {
|
|
131
|
+
if (!this.__element)
|
|
132
|
+
return;
|
|
133
|
+
if (!this.__destroyCallbacks)
|
|
134
|
+
this.__destroyCallbacks = [];
|
|
135
|
+
if (callback instanceof UIElement)
|
|
136
|
+
this.__destroyCallbacks.push(() => callback.destroy());
|
|
137
|
+
else if (callback instanceof Element)
|
|
138
|
+
this.__destroyCallbacks.push(() => callback.remove());
|
|
139
|
+
else
|
|
140
|
+
this.__destroyCallbacks.push(callback);
|
|
141
|
+
}
|
|
142
|
+
toString() {
|
|
143
|
+
return this.typeName;
|
|
144
|
+
}
|
|
164
145
|
destroy() {
|
|
165
146
|
const elem = this.__element;
|
|
166
147
|
if (!elem)
|
|
167
148
|
return;
|
|
168
|
-
|
|
169
|
-
delete elem.
|
|
170
|
-
delete
|
|
149
|
+
delete elem.dataset[constants$1.ElemAttributeName];
|
|
150
|
+
delete elem[constants$1.ElemPropertyName];
|
|
151
|
+
delete this.__element;
|
|
152
|
+
delete this.__events;
|
|
153
|
+
delete this.__commands;
|
|
154
|
+
if (this.__destroyCallbacks) {
|
|
155
|
+
this.__destroyCallbacks.map(callback => {
|
|
156
|
+
try {
|
|
157
|
+
callback();
|
|
158
|
+
}
|
|
159
|
+
catch (reason) {
|
|
160
|
+
console.error(`Error in call "${this.typeName}" destroy callback.`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
delete this.__destroyCallbacks;
|
|
164
|
+
}
|
|
171
165
|
}
|
|
172
166
|
}
|
|
173
|
-
var CommandsExecStatus;
|
|
174
|
-
(function (CommandsExecStatus) {
|
|
175
|
-
CommandsExecStatus[CommandsExecStatus["NotAllow"] = 1] = "NotAllow";
|
|
176
|
-
CommandsExecStatus[CommandsExecStatus["AlreadyExecuting"] = 2] = "AlreadyExecuting";
|
|
177
|
-
CommandsExecStatus[CommandsExecStatus["Success"] = 3] = "Success";
|
|
178
|
-
})(CommandsExecStatus || (CommandsExecStatus = {}));
|
|
179
167
|
const fundUiElementByCommand = (elem, commandName) => {
|
|
180
168
|
while (elem) {
|
|
181
|
-
if (elem.dataset[ElemAttributeName]) {
|
|
182
|
-
const uiElem = elem[ElemPropertyName];
|
|
169
|
+
if (elem.dataset[constants$1.ElemAttributeName]) {
|
|
170
|
+
const uiElem = elem[constants$1.ElemPropertyName];
|
|
183
171
|
if (uiElem.hasCommand(commandName))
|
|
184
172
|
return uiElem;
|
|
185
173
|
}
|
|
@@ -195,7 +183,7 @@ const fundUiElementByCommand = (elem, commandName) => {
|
|
|
195
183
|
const commandClickHandler = (e) => {
|
|
196
184
|
let commandElem = e.target;
|
|
197
185
|
while (commandElem) {
|
|
198
|
-
if (commandElem.dataset[CommandAttributeName])
|
|
186
|
+
if (commandElem.dataset[constants$1.CommandAttributeName])
|
|
199
187
|
break;
|
|
200
188
|
if (commandElem === e.currentTarget)
|
|
201
189
|
return;
|
|
@@ -203,24 +191,28 @@ const commandClickHandler = (e) => {
|
|
|
203
191
|
}
|
|
204
192
|
if (!commandElem)
|
|
205
193
|
return;
|
|
206
|
-
const commandName = commandElem.dataset[CommandAttributeName];
|
|
194
|
+
const commandName = commandElem.dataset[constants$1.CommandAttributeName];
|
|
207
195
|
if (!commandName)
|
|
208
196
|
throw new Error("Command data attribute is not have value.");
|
|
209
197
|
const uiElem = fundUiElementByCommand(commandElem, commandName);
|
|
210
|
-
if (uiElem
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
else {
|
|
214
|
-
const commandResult = uiElem.execCommand(commandName, commandElem);
|
|
215
|
-
if (commandResult.context.transparent)
|
|
198
|
+
if (uiElem) {
|
|
199
|
+
const result = uiElem.__execCommand(commandName, commandElem);
|
|
200
|
+
if (result.status == "success" && result.context.transparent)
|
|
216
201
|
return;
|
|
217
202
|
}
|
|
203
|
+
else
|
|
204
|
+
console.warn(`Not find handler for command "${commandName}".`);
|
|
218
205
|
e.preventDefault();
|
|
219
206
|
e.stopPropagation();
|
|
220
207
|
e.stopImmediatePropagation();
|
|
221
208
|
};
|
|
222
209
|
window.addEventListener("click", commandClickHandler, false);
|
|
223
210
|
|
|
211
|
+
HTMLElement.prototype.ui = function (factory) {
|
|
212
|
+
factory(this);
|
|
213
|
+
return this;
|
|
214
|
+
};
|
|
215
|
+
|
|
224
216
|
class MiddlewareInvoker {
|
|
225
217
|
middleware;
|
|
226
218
|
__next = null;
|
|
@@ -638,7 +630,7 @@ class Application extends UIElement {
|
|
|
638
630
|
__isDestroy = false;
|
|
639
631
|
__middlewares = {};
|
|
640
632
|
__lastNav = null;
|
|
641
|
-
constructor(env, model) {
|
|
633
|
+
constructor(env, model, ...args) {
|
|
642
634
|
super();
|
|
643
635
|
this.env = env;
|
|
644
636
|
this.model = model;
|
|
@@ -848,8 +840,12 @@ class Application extends UIElement {
|
|
|
848
840
|
}
|
|
849
841
|
|
|
850
842
|
class ApplicationBuilder {
|
|
843
|
+
__model;
|
|
851
844
|
__appType = (Application);
|
|
852
845
|
__middlewares = [];
|
|
846
|
+
constructor(model) {
|
|
847
|
+
this.__model = model;
|
|
848
|
+
}
|
|
853
849
|
useApp(appType) {
|
|
854
850
|
this.__appType = appType;
|
|
855
851
|
return this;
|
|
@@ -865,14 +861,12 @@ class ApplicationBuilder {
|
|
|
865
861
|
this.__middlewares.push(midl);
|
|
866
862
|
return this;
|
|
867
863
|
}
|
|
868
|
-
build(env,
|
|
864
|
+
build(env, ...args) {
|
|
869
865
|
if (!env)
|
|
870
866
|
throw new Error("Parameter env is required.");
|
|
871
|
-
if (!model)
|
|
872
|
-
throw new Error("Parameter model is required.");
|
|
873
867
|
if (!env.basePath)
|
|
874
868
|
env.basePath = "/";
|
|
875
|
-
const app = new this.__appType(env,
|
|
869
|
+
const app = new this.__appType(env, this.__model, ...args);
|
|
876
870
|
app.initialize(this.__middlewares);
|
|
877
871
|
return app;
|
|
878
872
|
}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../brandup-ui/dist/mjs/index.js"],"sourcesContent":["const ElemAttributeName = \"uiElement\";\nconst ElemPropertyName = \"brandupUiElement\";\nconst CommandAttributeName = \"command\";\nconst CommandExecutingCssClassName = \"executing\";\nclass UIElement {\n __element = null;\n __events = {};\n __commandHandlers = {};\n // Element members\n get element() { return this.__element; }\n setElement(elem) {\n if (!elem)\n throw \"Not set value elem.\";\n if (this.__element || UIElement.hasElement(elem))\n throw \"UIElement already defined\";\n this.__element = elem;\n this.__element[ElemPropertyName] = this;\n this.__element.dataset[ElemAttributeName] = this.typeName;\n this.defineEvent(\"command\", { cancelable: false, bubbles: true });\n this._onRenderElement(elem);\n }\n // static members\n static hasElement(elem) {\n return !!elem.dataset[ElemAttributeName];\n }\n // HTMLElement event members\n defineEvent(eventName, eventOptions) {\n this.__events[eventName] = eventOptions ? eventOptions : null;\n }\n raiseEvent(eventName, eventArgs) {\n if (!(eventName in this.__events))\n throw new Error(`Not found event \"${eventName}\".`);\n const eventOptions = this.__events[eventName];\n const eventInit = {};\n if (eventOptions) {\n if (eventOptions.bubbles)\n eventInit.bubbles = eventOptions.bubbles;\n if (eventOptions.cancelable)\n eventInit.cancelable = eventOptions.cancelable;\n if (eventOptions.composed)\n eventInit.composed = eventOptions.composed;\n }\n eventInit.detail = eventArgs ? eventArgs : {};\n const event = new CustomEvent(eventName, eventInit);\n return this.dispatchEvent(event);\n }\n addEventListener(type, listener, options) {\n this.__element?.addEventListener(type, listener, options);\n }\n removeEventListener(type, listener, options) {\n this.__element?.removeEventListener(type, listener, options);\n }\n dispatchEvent(event) {\n if (!this.__element)\n throw new Error(\"HTMLElement is not defined.\");\n return this.__element.dispatchEvent(event);\n }\n // Command members\n registerCommand(name, execute, canExecute) {\n name = this.verifyCommandName(name);\n this.__commandHandlers[name] = {\n name: name,\n execute,\n canExecute,\n isExecuting: false\n };\n }\n registerAsyncCommand(name, delegate, canExecute) {\n name = this.verifyCommandName(name);\n this.__commandHandlers[name] = {\n name: name,\n delegate,\n canExecute,\n isExecuting: false\n };\n }\n hasCommand(name) {\n return name.toLowerCase() in this.__commandHandlers;\n }\n execCommand(name, elem) {\n if (!this.__element)\n throw new Error(\"UIElement is not set HTMLElement.\");\n const key = name.toLowerCase();\n if (!(key in this.__commandHandlers))\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target: elem,\n uiElem: this,\n transparent: false\n };\n const handler = this.__commandHandlers[key];\n if (handler.isExecuting)\n return { result: CommandsExecStatus.AlreadyExecuting, context };\n handler.isExecuting = true;\n if (!this._onCanExecCommand(name, elem)) {\n handler.isExecuting = false;\n return { result: CommandsExecStatus.NotAllow, context };\n }\n if (handler.canExecute && !handler.canExecute(elem, context)) {\n handler.isExecuting = false;\n return { result: CommandsExecStatus.NotAllow, context };\n }\n this.raiseEvent(\"command\", {\n name: handler.name,\n uiElem: this,\n elem: this.__element\n });\n if (handler.execute) {\n // Если команда синхронная.\n try {\n handler.execute(elem, context);\n }\n finally {\n handler.isExecuting = false;\n }\n }\n else if (handler.delegate) {\n // Если команда асинхронная.\n elem.classList.add(CommandExecutingCssClassName);\n let timeoutId = 0;\n const endFunc = () => {\n handler.isExecuting = false;\n elem.classList.remove(CommandExecutingCssClassName);\n };\n const asyncContext = {\n target: elem,\n uiElem: this,\n transparent: context.transparent,\n complate: () => {\n clearTimeout(timeoutId);\n endFunc();\n }\n };\n const handlerResult = handler.delegate(asyncContext);\n if (handlerResult && handlerResult instanceof Promise)\n handlerResult.finally(() => asyncContext.complate());\n if (handler.isExecuting && asyncContext.timeout) {\n timeoutId = window.setTimeout(() => {\n if (asyncContext.timeoutCallback)\n asyncContext.timeoutCallback();\n endFunc();\n }, asyncContext.timeout);\n }\n context.transparent = asyncContext.transparent;\n }\n else\n throw new Error(\"Not set command execute flow.\");\n return { result: CommandsExecStatus.Success, context: context };\n }\n verifyCommandName(name) {\n const key = name.toLowerCase();\n if (key in this.__commandHandlers)\n throw new Error(`Command \"${name}\" already registered.`);\n return key;\n }\n _onRenderElement(_elem) {\n return;\n }\n _onCanExecCommand(_name, _elem) {\n return true;\n }\n destroy() {\n const elem = this.__element;\n if (!elem)\n return;\n this.__element = null;\n delete elem.dataset[ElemAttributeName];\n delete elem[ElemPropertyName];\n }\n}\nvar CommandsExecStatus;\n(function (CommandsExecStatus) {\n CommandsExecStatus[CommandsExecStatus[\"NotAllow\"] = 1] = \"NotAllow\";\n CommandsExecStatus[CommandsExecStatus[\"AlreadyExecuting\"] = 2] = \"AlreadyExecuting\";\n CommandsExecStatus[CommandsExecStatus[\"Success\"] = 3] = \"Success\";\n})(CommandsExecStatus || (CommandsExecStatus = {}));\nconst fundUiElementByCommand = (elem, commandName) => {\n while (elem) {\n if (elem.dataset[ElemAttributeName]) {\n const uiElem = elem[ElemPropertyName];\n if (uiElem.hasCommand(commandName))\n return uiElem;\n }\n if (typeof elem.parentElement === \"undefined\")\n elem = elem.parentNode;\n else if (elem.parentElement)\n elem = elem.parentElement;\n else\n break;\n }\n return null;\n};\nconst commandClickHandler = (e) => {\n let commandElem = e.target;\n while (commandElem) {\n if (commandElem.dataset[CommandAttributeName])\n break;\n if (commandElem === e.currentTarget)\n return;\n commandElem = commandElem.parentElement;\n }\n if (!commandElem)\n return;\n const commandName = commandElem.dataset[CommandAttributeName];\n if (!commandName)\n throw new Error(\"Command data attribute is not have value.\");\n const uiElem = fundUiElementByCommand(commandElem, commandName);\n if (uiElem === null) {\n console.warn(`Not find handler for command \"${commandName}\".`);\n }\n else {\n const commandResult = uiElem.execCommand(commandName, commandElem);\n if (commandResult.context.transparent)\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n};\nwindow.addEventListener(\"click\", commandClickHandler, false);\n\nexport { CommandAttributeName, CommandExecutingCssClassName, CommandsExecStatus, ElemAttributeName, ElemPropertyName, UIElement };\n//# sourceMappingURL=index.js.map\n"],"names":[],"mappings":";;AAAA,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,WAAW,CAAC;AACjD,MAAM,SAAS,CAAC;AAChB,IAAI,SAAS,GAAG,IAAI,CAAC;AACrB,IAAI,QAAQ,GAAG,EAAE,CAAC;AAClB,IAAI,iBAAiB,GAAG,EAAE,CAAC;AAC3B;AACA,IAAI,IAAI,OAAO,GAAG,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE;AAC5C,IAAI,UAAU,CAAC,IAAI,EAAE;AACrB,QAAQ,IAAI,CAAC,IAAI;AACjB,YAAY,MAAM,qBAAqB,CAAC;AACxC,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;AACxD,YAAY,MAAM,2BAA2B,CAAC;AAC9C,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC9B,QAAQ,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;AAChD,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC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,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../brandup-ui/dist/mjs/index.js"],"sourcesContent":["const constants = {\n ElemAttributeName: \"uiElement\",\n ElemPropertyName: \"uielement\",\n CommandAttributeName: \"command\",\n CommandExecutingCssClassName: \"executing\",\n CommandEventName: \"uicommand\"\n};\n\nclass UIElement {\n __element;\n __events;\n __commands;\n __destroyCallbacks;\n // Element members\n get element() { return this.__element; }\n setElement(elem) {\n if (!elem)\n throw \"Not set value elem.\";\n if (this.__element || UIElement.hasElement(elem))\n throw \"UIElement already defined\";\n this.__element = elem;\n elem[constants.ElemPropertyName] = this;\n elem.dataset[constants.ElemAttributeName] = this.typeName;\n this.defineEvent(constants.CommandEventName, { cancelable: false, bubbles: true });\n this._onRenderElement(elem);\n }\n // static members\n static hasElement(elem) {\n return !!elem.dataset[constants.ElemAttributeName];\n }\n // HTMLElement event members\n defineEvent(eventName, eventOptions) {\n if (!this.__events)\n this.__events = {};\n this.__events[eventName] = eventOptions ? eventOptions : null;\n }\n raiseEvent(eventName, eventArgs) {\n if (!this.__events || !(eventName in this.__events))\n throw new Error(`Not found event \"${eventName}\".`);\n const eventOptions = this.__events[eventName];\n const eventInit = {};\n if (eventOptions) {\n eventInit.bubbles = eventOptions.bubbles;\n eventInit.cancelable = eventOptions.cancelable;\n eventInit.composed = eventOptions.composed;\n }\n eventInit.detail = eventArgs;\n return this.dispatchEvent(new CustomEvent(eventName, eventInit));\n }\n addEventListener(type, listener, options) {\n this.__element?.addEventListener(type, listener, options);\n }\n removeEventListener(type, listener, options) {\n this.__element?.removeEventListener(type, listener, options);\n }\n dispatchEvent(event) {\n if (!this.__element)\n throw new Error(\"HTMLElement is not defined.\");\n return this.__element.dispatchEvent(event);\n }\n // Command members\n registerCommand(name, execute, canExecute) {\n if (!this.__commands)\n this.__commands = {};\n const nornalizedName = name.toLowerCase();\n if (nornalizedName in this.__commands)\n throw new Error(`Command \"${name}\" already registered.`);\n this.__commands[nornalizedName] = {\n name: name,\n execute,\n canExecute\n };\n }\n hasCommand(name) {\n return this.__commands && name.toLowerCase() in this.__commands;\n }\n /** @internal */\n __execCommand(name, target) {\n if (!this.__element || !this.__commands)\n throw new Error(\"UIElement is not set HTMLElement.\");\n const key = name.toLowerCase();\n const command = this.__commands[key];\n if (!command)\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target,\n uiElem: this\n };\n if (command.isExecuting)\n return { status: \"already\", context };\n command.isExecuting = true;\n if (!this._onCanExecCommand(name, target)) {\n delete command.isExecuting;\n return { status: \"disallow\", context };\n }\n if (command.canExecute && !command.canExecute(context)) {\n delete command.isExecuting;\n return { status: \"disallow\", context };\n }\n this.raiseEvent(constants.CommandEventName, {\n name: command.name,\n uiElem: this,\n elem: this.__element\n });\n let isAsync;\n try {\n const commandResult = command.execute(context);\n if (commandResult && commandResult instanceof Promise) {\n isAsync = true;\n target.classList.add(constants.CommandExecutingCssClassName);\n commandResult\n .finally(() => {\n target.classList.remove(constants.CommandExecutingCssClassName);\n delete command.isExecuting;\n });\n }\n }\n finally {\n if (!isAsync)\n delete command.isExecuting;\n }\n return { status: \"success\", context: context };\n }\n _onRenderElement(_elem) { }\n _onCanExecCommand(_name, _elem) {\n return true;\n }\n onDestroy(callback) {\n if (!this.__element)\n return;\n if (!this.__destroyCallbacks)\n this.__destroyCallbacks = [];\n if (callback instanceof UIElement)\n this.__destroyCallbacks.push(() => callback.destroy());\n else if (callback instanceof Element)\n this.__destroyCallbacks.push(() => callback.remove());\n else\n this.__destroyCallbacks.push(callback);\n }\n toString() {\n return this.typeName;\n }\n destroy() {\n const elem = this.__element;\n if (!elem)\n return;\n delete elem.dataset[constants.ElemAttributeName];\n delete elem[constants.ElemPropertyName];\n delete this.__element;\n delete this.__events;\n delete this.__commands;\n if (this.__destroyCallbacks) {\n this.__destroyCallbacks.map(callback => {\n try {\n callback();\n }\n catch (reason) {\n console.error(`Error in call \"${this.typeName}\" destroy callback.`);\n }\n });\n delete this.__destroyCallbacks;\n }\n }\n}\nconst fundUiElementByCommand = (elem, commandName) => {\n while (elem) {\n if (elem.dataset[constants.ElemAttributeName]) {\n const uiElem = elem[constants.ElemPropertyName];\n if (uiElem.hasCommand(commandName))\n return uiElem;\n }\n if (typeof elem.parentElement === \"undefined\")\n elem = elem.parentNode;\n else if (elem.parentElement)\n elem = elem.parentElement;\n else\n break;\n }\n return null;\n};\nconst commandClickHandler = (e) => {\n let commandElem = e.target;\n while (commandElem) {\n if (commandElem.dataset[constants.CommandAttributeName])\n break;\n if (commandElem === e.currentTarget)\n return;\n commandElem = commandElem.parentElement;\n }\n if (!commandElem)\n return;\n const commandName = commandElem.dataset[constants.CommandAttributeName];\n if (!commandName)\n throw new Error(\"Command data attribute is not have value.\");\n const uiElem = fundUiElementByCommand(commandElem, commandName);\n if (uiElem) {\n const result = uiElem.__execCommand(commandName, commandElem);\n if (result.status == \"success\" && result.context.transparent)\n return;\n }\n else\n console.warn(`Not find handler for command \"${commandName}\".`);\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n};\nwindow.addEventListener(\"click\", commandClickHandler, false);\n\nHTMLElement.prototype.ui = function (factory) {\n factory(this);\n return this;\n};\n\nconst UICONSTANTS = constants;\n\nexport { UICONSTANTS, UIElement };\n//# sourceMappingURL=index.js.map\n"],"names":["constants"],"mappings":";;AAAA,MAAMA,WAAS,GAAG;AAClB,IAAI,iBAAiB,EAAE,WAAW;AAClC,IAAI,gBAAgB,EAAE,WAAW;AACjC,IAAI,oBAAoB,EAAE,SAAS;AACnC,IAAI,4BAA4B,EAAE,WAAW;AAC7C,IAAI,gBAAgB,EAAE,WAAW;AACjC,CAAC,CAAC;AACF;AACA,MAAM,SAAS,CAAC;AAChB,IAAI,SAAS,CAAC;AACd,IAAI,QAAQ,CAAC;AACb,IAAI,UAAU,CAAC;AACf,IAAI,kBAAkB,CAAC;AACvB;AACA,IAAI,IAAI,OAAO,GAAG,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE;AAC5C,IAAI,UAAU,CAAC,IAAI,EAAE;AACrB,QAAQ,IAAI,CAAC,IAAI;AACjB,YAAY,MAAM,qBAAqB,CAAC;AACxC,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;AACxD,YAAY,MAAM,2BAA2B,CAAC;AAC9C,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC9B,QAAQ,IAAI,CAACA,WAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;AAChD,QAAQ,IAAI,CAAC,OAAO,CAACA,WAAS,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const constants$1 = {
|
|
2
|
+
ElemAttributeName: "uiElement",
|
|
3
|
+
ElemPropertyName: "uielement",
|
|
4
|
+
CommandAttributeName: "command",
|
|
5
|
+
CommandExecutingCssClassName: "executing",
|
|
6
|
+
CommandEventName: "uicommand"
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
class UIElement {
|
|
6
|
-
__element
|
|
7
|
-
__events
|
|
8
|
-
|
|
10
|
+
__element;
|
|
11
|
+
__events;
|
|
12
|
+
__commands;
|
|
13
|
+
__destroyCallbacks;
|
|
9
14
|
// Element members
|
|
10
15
|
get element() { return this.__element; }
|
|
11
16
|
setElement(elem) {
|
|
@@ -14,35 +19,33 @@ class UIElement {
|
|
|
14
19
|
if (this.__element || UIElement.hasElement(elem))
|
|
15
20
|
throw "UIElement already defined";
|
|
16
21
|
this.__element = elem;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.defineEvent(
|
|
22
|
+
elem[constants$1.ElemPropertyName] = this;
|
|
23
|
+
elem.dataset[constants$1.ElemAttributeName] = this.typeName;
|
|
24
|
+
this.defineEvent(constants$1.CommandEventName, { cancelable: false, bubbles: true });
|
|
20
25
|
this._onRenderElement(elem);
|
|
21
26
|
}
|
|
22
27
|
// static members
|
|
23
28
|
static hasElement(elem) {
|
|
24
|
-
return !!elem.dataset[ElemAttributeName];
|
|
29
|
+
return !!elem.dataset[constants$1.ElemAttributeName];
|
|
25
30
|
}
|
|
26
31
|
// HTMLElement event members
|
|
27
32
|
defineEvent(eventName, eventOptions) {
|
|
33
|
+
if (!this.__events)
|
|
34
|
+
this.__events = {};
|
|
28
35
|
this.__events[eventName] = eventOptions ? eventOptions : null;
|
|
29
36
|
}
|
|
30
37
|
raiseEvent(eventName, eventArgs) {
|
|
31
|
-
if (!(eventName in this.__events))
|
|
38
|
+
if (!this.__events || !(eventName in this.__events))
|
|
32
39
|
throw new Error(`Not found event "${eventName}".`);
|
|
33
40
|
const eventOptions = this.__events[eventName];
|
|
34
41
|
const eventInit = {};
|
|
35
42
|
if (eventOptions) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
eventInit.cancelable = eventOptions.cancelable;
|
|
40
|
-
if (eventOptions.composed)
|
|
41
|
-
eventInit.composed = eventOptions.composed;
|
|
43
|
+
eventInit.bubbles = eventOptions.bubbles;
|
|
44
|
+
eventInit.cancelable = eventOptions.cancelable;
|
|
45
|
+
eventInit.composed = eventOptions.composed;
|
|
42
46
|
}
|
|
43
|
-
eventInit.detail = eventArgs
|
|
44
|
-
|
|
45
|
-
return this.dispatchEvent(event);
|
|
47
|
+
eventInit.detail = eventArgs;
|
|
48
|
+
return this.dispatchEvent(new CustomEvent(eventName, eventInit));
|
|
46
49
|
}
|
|
47
50
|
addEventListener(type, listener, options) {
|
|
48
51
|
this.__element?.addEventListener(type, listener, options);
|
|
@@ -57,127 +60,112 @@ class UIElement {
|
|
|
57
60
|
}
|
|
58
61
|
// Command members
|
|
59
62
|
registerCommand(name, execute, canExecute) {
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
if (!this.__commands)
|
|
64
|
+
this.__commands = {};
|
|
65
|
+
const nornalizedName = name.toLowerCase();
|
|
66
|
+
if (nornalizedName in this.__commands)
|
|
67
|
+
throw new Error(`Command "${name}" already registered.`);
|
|
68
|
+
this.__commands[nornalizedName] = {
|
|
62
69
|
name: name,
|
|
63
70
|
execute,
|
|
64
|
-
canExecute
|
|
65
|
-
isExecuting: false
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
registerAsyncCommand(name, delegate, canExecute) {
|
|
69
|
-
name = this.verifyCommandName(name);
|
|
70
|
-
this.__commandHandlers[name] = {
|
|
71
|
-
name: name,
|
|
72
|
-
delegate,
|
|
73
|
-
canExecute,
|
|
74
|
-
isExecuting: false
|
|
71
|
+
canExecute
|
|
75
72
|
};
|
|
76
73
|
}
|
|
77
74
|
hasCommand(name) {
|
|
78
|
-
return name.toLowerCase() in this.
|
|
75
|
+
return this.__commands && name.toLowerCase() in this.__commands;
|
|
79
76
|
}
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
/** @internal */
|
|
78
|
+
__execCommand(name, target) {
|
|
79
|
+
if (!this.__element || !this.__commands)
|
|
82
80
|
throw new Error("UIElement is not set HTMLElement.");
|
|
83
81
|
const key = name.toLowerCase();
|
|
84
|
-
|
|
82
|
+
const command = this.__commands[key];
|
|
83
|
+
if (!command)
|
|
85
84
|
throw new Error(`Command "${name}" is not registered.`);
|
|
86
85
|
const context = {
|
|
87
|
-
target
|
|
88
|
-
uiElem: this
|
|
89
|
-
transparent: false
|
|
86
|
+
target,
|
|
87
|
+
uiElem: this
|
|
90
88
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return { result: CommandsExecStatus.NotAllow, context };
|
|
89
|
+
if (command.isExecuting)
|
|
90
|
+
return { status: "already", context };
|
|
91
|
+
command.isExecuting = true;
|
|
92
|
+
if (!this._onCanExecCommand(name, target)) {
|
|
93
|
+
delete command.isExecuting;
|
|
94
|
+
return { status: "disallow", context };
|
|
98
95
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
return {
|
|
96
|
+
if (command.canExecute && !command.canExecute(context)) {
|
|
97
|
+
delete command.isExecuting;
|
|
98
|
+
return { status: "disallow", context };
|
|
102
99
|
}
|
|
103
|
-
this.raiseEvent(
|
|
104
|
-
name:
|
|
100
|
+
this.raiseEvent(constants$1.CommandEventName, {
|
|
101
|
+
name: command.name,
|
|
105
102
|
uiElem: this,
|
|
106
103
|
elem: this.__element
|
|
107
104
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
let isAsync;
|
|
106
|
+
try {
|
|
107
|
+
const commandResult = command.execute(context);
|
|
108
|
+
if (commandResult && commandResult instanceof Promise) {
|
|
109
|
+
isAsync = true;
|
|
110
|
+
target.classList.add(constants$1.CommandExecutingCssClassName);
|
|
111
|
+
commandResult
|
|
112
|
+
.finally(() => {
|
|
113
|
+
target.classList.remove(constants$1.CommandExecutingCssClassName);
|
|
114
|
+
delete command.isExecuting;
|
|
115
|
+
});
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
let timeoutId = 0;
|
|
121
|
-
const endFunc = () => {
|
|
122
|
-
handler.isExecuting = false;
|
|
123
|
-
elem.classList.remove(CommandExecutingCssClassName);
|
|
124
|
-
};
|
|
125
|
-
const asyncContext = {
|
|
126
|
-
target: elem,
|
|
127
|
-
uiElem: this,
|
|
128
|
-
transparent: context.transparent,
|
|
129
|
-
complate: () => {
|
|
130
|
-
clearTimeout(timeoutId);
|
|
131
|
-
endFunc();
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
const handlerResult = handler.delegate(asyncContext);
|
|
135
|
-
if (handlerResult && handlerResult instanceof Promise)
|
|
136
|
-
handlerResult.finally(() => asyncContext.complate());
|
|
137
|
-
if (handler.isExecuting && asyncContext.timeout) {
|
|
138
|
-
timeoutId = window.setTimeout(() => {
|
|
139
|
-
if (asyncContext.timeoutCallback)
|
|
140
|
-
asyncContext.timeoutCallback();
|
|
141
|
-
endFunc();
|
|
142
|
-
}, asyncContext.timeout);
|
|
143
|
-
}
|
|
144
|
-
context.transparent = asyncContext.transparent;
|
|
118
|
+
finally {
|
|
119
|
+
if (!isAsync)
|
|
120
|
+
delete command.isExecuting;
|
|
145
121
|
}
|
|
146
|
-
|
|
147
|
-
throw new Error("Not set command execute flow.");
|
|
148
|
-
return { result: CommandsExecStatus.Success, context: context };
|
|
149
|
-
}
|
|
150
|
-
verifyCommandName(name) {
|
|
151
|
-
const key = name.toLowerCase();
|
|
152
|
-
if (key in this.__commandHandlers)
|
|
153
|
-
throw new Error(`Command "${name}" already registered.`);
|
|
154
|
-
return key;
|
|
155
|
-
}
|
|
156
|
-
_onRenderElement(_elem) {
|
|
157
|
-
return;
|
|
122
|
+
return { status: "success", context: context };
|
|
158
123
|
}
|
|
124
|
+
_onRenderElement(_elem) { }
|
|
159
125
|
_onCanExecCommand(_name, _elem) {
|
|
160
126
|
return true;
|
|
161
127
|
}
|
|
128
|
+
onDestroy(callback) {
|
|
129
|
+
if (!this.__element)
|
|
130
|
+
return;
|
|
131
|
+
if (!this.__destroyCallbacks)
|
|
132
|
+
this.__destroyCallbacks = [];
|
|
133
|
+
if (callback instanceof UIElement)
|
|
134
|
+
this.__destroyCallbacks.push(() => callback.destroy());
|
|
135
|
+
else if (callback instanceof Element)
|
|
136
|
+
this.__destroyCallbacks.push(() => callback.remove());
|
|
137
|
+
else
|
|
138
|
+
this.__destroyCallbacks.push(callback);
|
|
139
|
+
}
|
|
140
|
+
toString() {
|
|
141
|
+
return this.typeName;
|
|
142
|
+
}
|
|
162
143
|
destroy() {
|
|
163
144
|
const elem = this.__element;
|
|
164
145
|
if (!elem)
|
|
165
146
|
return;
|
|
166
|
-
|
|
167
|
-
delete elem.
|
|
168
|
-
delete
|
|
147
|
+
delete elem.dataset[constants$1.ElemAttributeName];
|
|
148
|
+
delete elem[constants$1.ElemPropertyName];
|
|
149
|
+
delete this.__element;
|
|
150
|
+
delete this.__events;
|
|
151
|
+
delete this.__commands;
|
|
152
|
+
if (this.__destroyCallbacks) {
|
|
153
|
+
this.__destroyCallbacks.map(callback => {
|
|
154
|
+
try {
|
|
155
|
+
callback();
|
|
156
|
+
}
|
|
157
|
+
catch (reason) {
|
|
158
|
+
console.error(`Error in call "${this.typeName}" destroy callback.`);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
delete this.__destroyCallbacks;
|
|
162
|
+
}
|
|
169
163
|
}
|
|
170
164
|
}
|
|
171
|
-
var CommandsExecStatus;
|
|
172
|
-
(function (CommandsExecStatus) {
|
|
173
|
-
CommandsExecStatus[CommandsExecStatus["NotAllow"] = 1] = "NotAllow";
|
|
174
|
-
CommandsExecStatus[CommandsExecStatus["AlreadyExecuting"] = 2] = "AlreadyExecuting";
|
|
175
|
-
CommandsExecStatus[CommandsExecStatus["Success"] = 3] = "Success";
|
|
176
|
-
})(CommandsExecStatus || (CommandsExecStatus = {}));
|
|
177
165
|
const fundUiElementByCommand = (elem, commandName) => {
|
|
178
166
|
while (elem) {
|
|
179
|
-
if (elem.dataset[ElemAttributeName]) {
|
|
180
|
-
const uiElem = elem[ElemPropertyName];
|
|
167
|
+
if (elem.dataset[constants$1.ElemAttributeName]) {
|
|
168
|
+
const uiElem = elem[constants$1.ElemPropertyName];
|
|
181
169
|
if (uiElem.hasCommand(commandName))
|
|
182
170
|
return uiElem;
|
|
183
171
|
}
|
|
@@ -193,7 +181,7 @@ const fundUiElementByCommand = (elem, commandName) => {
|
|
|
193
181
|
const commandClickHandler = (e) => {
|
|
194
182
|
let commandElem = e.target;
|
|
195
183
|
while (commandElem) {
|
|
196
|
-
if (commandElem.dataset[CommandAttributeName])
|
|
184
|
+
if (commandElem.dataset[constants$1.CommandAttributeName])
|
|
197
185
|
break;
|
|
198
186
|
if (commandElem === e.currentTarget)
|
|
199
187
|
return;
|
|
@@ -201,24 +189,28 @@ const commandClickHandler = (e) => {
|
|
|
201
189
|
}
|
|
202
190
|
if (!commandElem)
|
|
203
191
|
return;
|
|
204
|
-
const commandName = commandElem.dataset[CommandAttributeName];
|
|
192
|
+
const commandName = commandElem.dataset[constants$1.CommandAttributeName];
|
|
205
193
|
if (!commandName)
|
|
206
194
|
throw new Error("Command data attribute is not have value.");
|
|
207
195
|
const uiElem = fundUiElementByCommand(commandElem, commandName);
|
|
208
|
-
if (uiElem
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
else {
|
|
212
|
-
const commandResult = uiElem.execCommand(commandName, commandElem);
|
|
213
|
-
if (commandResult.context.transparent)
|
|
196
|
+
if (uiElem) {
|
|
197
|
+
const result = uiElem.__execCommand(commandName, commandElem);
|
|
198
|
+
if (result.status == "success" && result.context.transparent)
|
|
214
199
|
return;
|
|
215
200
|
}
|
|
201
|
+
else
|
|
202
|
+
console.warn(`Not find handler for command "${commandName}".`);
|
|
216
203
|
e.preventDefault();
|
|
217
204
|
e.stopPropagation();
|
|
218
205
|
e.stopImmediatePropagation();
|
|
219
206
|
};
|
|
220
207
|
window.addEventListener("click", commandClickHandler, false);
|
|
221
208
|
|
|
209
|
+
HTMLElement.prototype.ui = function (factory) {
|
|
210
|
+
factory(this);
|
|
211
|
+
return this;
|
|
212
|
+
};
|
|
213
|
+
|
|
222
214
|
class MiddlewareInvoker {
|
|
223
215
|
middleware;
|
|
224
216
|
__next = null;
|
|
@@ -636,7 +628,7 @@ class Application extends UIElement {
|
|
|
636
628
|
__isDestroy = false;
|
|
637
629
|
__middlewares = {};
|
|
638
630
|
__lastNav = null;
|
|
639
|
-
constructor(env, model) {
|
|
631
|
+
constructor(env, model, ...args) {
|
|
640
632
|
super();
|
|
641
633
|
this.env = env;
|
|
642
634
|
this.model = model;
|
|
@@ -846,8 +838,12 @@ class Application extends UIElement {
|
|
|
846
838
|
}
|
|
847
839
|
|
|
848
840
|
class ApplicationBuilder {
|
|
841
|
+
__model;
|
|
849
842
|
__appType = (Application);
|
|
850
843
|
__middlewares = [];
|
|
844
|
+
constructor(model) {
|
|
845
|
+
this.__model = model;
|
|
846
|
+
}
|
|
851
847
|
useApp(appType) {
|
|
852
848
|
this.__appType = appType;
|
|
853
849
|
return this;
|
|
@@ -863,14 +859,12 @@ class ApplicationBuilder {
|
|
|
863
859
|
this.__middlewares.push(midl);
|
|
864
860
|
return this;
|
|
865
861
|
}
|
|
866
|
-
build(env,
|
|
862
|
+
build(env, ...args) {
|
|
867
863
|
if (!env)
|
|
868
864
|
throw new Error("Parameter env is required.");
|
|
869
|
-
if (!model)
|
|
870
|
-
throw new Error("Parameter model is required.");
|
|
871
865
|
if (!env.basePath)
|
|
872
866
|
env.basePath = "/";
|
|
873
|
-
const app = new this.__appType(env,
|
|
867
|
+
const app = new this.__appType(env, this.__model, ...args);
|
|
874
868
|
app.initialize(this.__middlewares);
|
|
875
869
|
return app;
|
|
876
870
|
}
|
package/dist/mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../brandup-ui/dist/mjs/index.js"],"sourcesContent":["const ElemAttributeName = \"uiElement\";\nconst ElemPropertyName = \"brandupUiElement\";\nconst CommandAttributeName = \"command\";\nconst CommandExecutingCssClassName = \"executing\";\nclass UIElement {\n __element = null;\n __events = {};\n __commandHandlers = {};\n // Element members\n get element() { return this.__element; }\n setElement(elem) {\n if (!elem)\n throw \"Not set value elem.\";\n if (this.__element || UIElement.hasElement(elem))\n throw \"UIElement already defined\";\n this.__element = elem;\n this.__element[ElemPropertyName] = this;\n this.__element.dataset[ElemAttributeName] = this.typeName;\n this.defineEvent(\"command\", { cancelable: false, bubbles: true });\n this._onRenderElement(elem);\n }\n // static members\n static hasElement(elem) {\n return !!elem.dataset[ElemAttributeName];\n }\n // HTMLElement event members\n defineEvent(eventName, eventOptions) {\n this.__events[eventName] = eventOptions ? eventOptions : null;\n }\n raiseEvent(eventName, eventArgs) {\n if (!(eventName in this.__events))\n throw new Error(`Not found event \"${eventName}\".`);\n const eventOptions = this.__events[eventName];\n const eventInit = {};\n if (eventOptions) {\n if (eventOptions.bubbles)\n eventInit.bubbles = eventOptions.bubbles;\n if (eventOptions.cancelable)\n eventInit.cancelable = eventOptions.cancelable;\n if (eventOptions.composed)\n eventInit.composed = eventOptions.composed;\n }\n eventInit.detail = eventArgs ? eventArgs : {};\n const event = new CustomEvent(eventName, eventInit);\n return this.dispatchEvent(event);\n }\n addEventListener(type, listener, options) {\n this.__element?.addEventListener(type, listener, options);\n }\n removeEventListener(type, listener, options) {\n this.__element?.removeEventListener(type, listener, options);\n }\n dispatchEvent(event) {\n if (!this.__element)\n throw new Error(\"HTMLElement is not defined.\");\n return this.__element.dispatchEvent(event);\n }\n // Command members\n registerCommand(name, execute, canExecute) {\n name = this.verifyCommandName(name);\n this.__commandHandlers[name] = {\n name: name,\n execute,\n canExecute,\n isExecuting: false\n };\n }\n registerAsyncCommand(name, delegate, canExecute) {\n name = this.verifyCommandName(name);\n this.__commandHandlers[name] = {\n name: name,\n delegate,\n canExecute,\n isExecuting: false\n };\n }\n hasCommand(name) {\n return name.toLowerCase() in this.__commandHandlers;\n }\n execCommand(name, elem) {\n if (!this.__element)\n throw new Error(\"UIElement is not set HTMLElement.\");\n const key = name.toLowerCase();\n if (!(key in this.__commandHandlers))\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target: elem,\n uiElem: this,\n transparent: false\n };\n const handler = this.__commandHandlers[key];\n if (handler.isExecuting)\n return { result: CommandsExecStatus.AlreadyExecuting, context };\n handler.isExecuting = true;\n if (!this._onCanExecCommand(name, elem)) {\n handler.isExecuting = false;\n return { result: CommandsExecStatus.NotAllow, context };\n }\n if (handler.canExecute && !handler.canExecute(elem, context)) {\n handler.isExecuting = false;\n return { result: CommandsExecStatus.NotAllow, context };\n }\n this.raiseEvent(\"command\", {\n name: handler.name,\n uiElem: this,\n elem: this.__element\n });\n if (handler.execute) {\n // Если команда синхронная.\n try {\n handler.execute(elem, context);\n }\n finally {\n handler.isExecuting = false;\n }\n }\n else if (handler.delegate) {\n // Если команда асинхронная.\n elem.classList.add(CommandExecutingCssClassName);\n let timeoutId = 0;\n const endFunc = () => {\n handler.isExecuting = false;\n elem.classList.remove(CommandExecutingCssClassName);\n };\n const asyncContext = {\n target: elem,\n uiElem: this,\n transparent: context.transparent,\n complate: () => {\n clearTimeout(timeoutId);\n endFunc();\n }\n };\n const handlerResult = handler.delegate(asyncContext);\n if (handlerResult && handlerResult instanceof Promise)\n handlerResult.finally(() => asyncContext.complate());\n if (handler.isExecuting && asyncContext.timeout) {\n timeoutId = window.setTimeout(() => {\n if (asyncContext.timeoutCallback)\n asyncContext.timeoutCallback();\n endFunc();\n }, asyncContext.timeout);\n }\n context.transparent = asyncContext.transparent;\n }\n else\n throw new Error(\"Not set command execute flow.\");\n return { result: CommandsExecStatus.Success, context: context };\n }\n verifyCommandName(name) {\n const key = name.toLowerCase();\n if (key in this.__commandHandlers)\n throw new Error(`Command \"${name}\" already registered.`);\n return key;\n }\n _onRenderElement(_elem) {\n return;\n }\n _onCanExecCommand(_name, _elem) {\n return true;\n }\n destroy() {\n const elem = this.__element;\n if (!elem)\n return;\n this.__element = null;\n delete elem.dataset[ElemAttributeName];\n delete elem[ElemPropertyName];\n }\n}\nvar CommandsExecStatus;\n(function (CommandsExecStatus) {\n CommandsExecStatus[CommandsExecStatus[\"NotAllow\"] = 1] = \"NotAllow\";\n CommandsExecStatus[CommandsExecStatus[\"AlreadyExecuting\"] = 2] = \"AlreadyExecuting\";\n CommandsExecStatus[CommandsExecStatus[\"Success\"] = 3] = \"Success\";\n})(CommandsExecStatus || (CommandsExecStatus = {}));\nconst fundUiElementByCommand = (elem, commandName) => {\n while (elem) {\n if (elem.dataset[ElemAttributeName]) {\n const uiElem = elem[ElemPropertyName];\n if (uiElem.hasCommand(commandName))\n return uiElem;\n }\n if (typeof elem.parentElement === \"undefined\")\n elem = elem.parentNode;\n else if (elem.parentElement)\n elem = elem.parentElement;\n else\n break;\n }\n return null;\n};\nconst commandClickHandler = (e) => {\n let commandElem = e.target;\n while (commandElem) {\n if (commandElem.dataset[CommandAttributeName])\n break;\n if (commandElem === e.currentTarget)\n return;\n commandElem = commandElem.parentElement;\n }\n if (!commandElem)\n return;\n const commandName = commandElem.dataset[CommandAttributeName];\n if (!commandName)\n throw new Error(\"Command data attribute is not have value.\");\n const uiElem = fundUiElementByCommand(commandElem, commandName);\n if (uiElem === null) {\n console.warn(`Not find handler for command \"${commandName}\".`);\n }\n else {\n const commandResult = uiElem.execCommand(commandName, commandElem);\n if (commandResult.context.transparent)\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n};\nwindow.addEventListener(\"click\", commandClickHandler, false);\n\nexport { CommandAttributeName, CommandExecutingCssClassName, CommandsExecStatus, ElemAttributeName, ElemPropertyName, UIElement };\n//# sourceMappingURL=index.js.map\n"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,4BAA4B,GAAG,WAAW,CAAC;AACjD,MAAM,SAAS,CAAC;AAChB,IAAI,SAAS,GAAG,IAAI,CAAC;AACrB,IAAI,QAAQ,GAAG,EAAE,CAAC;AAClB,IAAI,iBAAiB,GAAG,EAAE,CAAC;AAC3B;AACA,IAAI,IAAI,OAAO,GAAG,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE;AAC5C,IAAI,UAAU,CAAC,IAAI,EAAE;AACrB,QAAQ,IAAI,CAAC,IAAI;AACjB,YAAY,MAAM,qBAAqB,CAAC;AACxC,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;AACxD,YAAY,MAAM,2BAA2B,CAAC;AAC9C,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC9B,QAAQ,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;AAChD,QAAQ,IAAI,C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AC;AACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../brandup-ui/dist/mjs/index.js"],"sourcesContent":["const constants = {\n ElemAttributeName: \"uiElement\",\n ElemPropertyName: \"uielement\",\n CommandAttributeName: \"command\",\n CommandExecutingCssClassName: \"executing\",\n CommandEventName: \"uicommand\"\n};\n\nclass UIElement {\n __element;\n __events;\n __commands;\n __destroyCallbacks;\n // Element members\n get element() { return this.__element; }\n setElement(elem) {\n if (!elem)\n throw \"Not set value elem.\";\n if (this.__element || UIElement.hasElement(elem))\n throw \"UIElement already defined\";\n this.__element = elem;\n elem[constants.ElemPropertyName] = this;\n elem.dataset[constants.ElemAttributeName] = this.typeName;\n this.defineEvent(constants.CommandEventName, { cancelable: false, bubbles: true });\n this._onRenderElement(elem);\n }\n // static members\n static hasElement(elem) {\n return !!elem.dataset[constants.ElemAttributeName];\n }\n // HTMLElement event members\n defineEvent(eventName, eventOptions) {\n if (!this.__events)\n this.__events = {};\n this.__events[eventName] = eventOptions ? eventOptions : null;\n }\n raiseEvent(eventName, eventArgs) {\n if (!this.__events || !(eventName in this.__events))\n throw new Error(`Not found event \"${eventName}\".`);\n const eventOptions = this.__events[eventName];\n const eventInit = {};\n if (eventOptions) {\n eventInit.bubbles = eventOptions.bubbles;\n eventInit.cancelable = eventOptions.cancelable;\n eventInit.composed = eventOptions.composed;\n }\n eventInit.detail = eventArgs;\n return this.dispatchEvent(new CustomEvent(eventName, eventInit));\n }\n addEventListener(type, listener, options) {\n this.__element?.addEventListener(type, listener, options);\n }\n removeEventListener(type, listener, options) {\n this.__element?.removeEventListener(type, listener, options);\n }\n dispatchEvent(event) {\n if (!this.__element)\n throw new Error(\"HTMLElement is not defined.\");\n return this.__element.dispatchEvent(event);\n }\n // Command members\n registerCommand(name, execute, canExecute) {\n if (!this.__commands)\n this.__commands = {};\n const nornalizedName = name.toLowerCase();\n if (nornalizedName in this.__commands)\n throw new Error(`Command \"${name}\" already registered.`);\n this.__commands[nornalizedName] = {\n name: name,\n execute,\n canExecute\n };\n }\n hasCommand(name) {\n return this.__commands && name.toLowerCase() in this.__commands;\n }\n /** @internal */\n __execCommand(name, target) {\n if (!this.__element || !this.__commands)\n throw new Error(\"UIElement is not set HTMLElement.\");\n const key = name.toLowerCase();\n const command = this.__commands[key];\n if (!command)\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target,\n uiElem: this\n };\n if (command.isExecuting)\n return { status: \"already\", context };\n command.isExecuting = true;\n if (!this._onCanExecCommand(name, target)) {\n delete command.isExecuting;\n return { status: \"disallow\", context };\n }\n if (command.canExecute && !command.canExecute(context)) {\n delete command.isExecuting;\n return { status: \"disallow\", context };\n }\n this.raiseEvent(constants.CommandEventName, {\n name: command.name,\n uiElem: this,\n elem: this.__element\n });\n let isAsync;\n try {\n const commandResult = command.execute(context);\n if (commandResult && commandResult instanceof Promise) {\n isAsync = true;\n target.classList.add(constants.CommandExecutingCssClassName);\n commandResult\n .finally(() => {\n target.classList.remove(constants.CommandExecutingCssClassName);\n delete command.isExecuting;\n });\n }\n }\n finally {\n if (!isAsync)\n delete command.isExecuting;\n }\n return { status: \"success\", context: context };\n }\n _onRenderElement(_elem) { }\n _onCanExecCommand(_name, _elem) {\n return true;\n }\n onDestroy(callback) {\n if (!this.__element)\n return;\n if (!this.__destroyCallbacks)\n this.__destroyCallbacks = [];\n if (callback instanceof UIElement)\n this.__destroyCallbacks.push(() => callback.destroy());\n else if (callback instanceof Element)\n this.__destroyCallbacks.push(() => callback.remove());\n else\n this.__destroyCallbacks.push(callback);\n }\n toString() {\n return this.typeName;\n }\n destroy() {\n const elem = this.__element;\n if (!elem)\n return;\n delete elem.dataset[constants.ElemAttributeName];\n delete elem[constants.ElemPropertyName];\n delete this.__element;\n delete this.__events;\n delete this.__commands;\n if (this.__destroyCallbacks) {\n this.__destroyCallbacks.map(callback => {\n try {\n callback();\n }\n catch (reason) {\n console.error(`Error in call \"${this.typeName}\" destroy callback.`);\n }\n });\n delete this.__destroyCallbacks;\n }\n }\n}\nconst fundUiElementByCommand = (elem, commandName) => {\n while (elem) {\n if (elem.dataset[constants.ElemAttributeName]) {\n const uiElem = elem[constants.ElemPropertyName];\n if (uiElem.hasCommand(commandName))\n return uiElem;\n }\n if (typeof elem.parentElement === \"undefined\")\n elem = elem.parentNode;\n else if (elem.parentElement)\n elem = elem.parentElement;\n else\n break;\n }\n return null;\n};\nconst commandClickHandler = (e) => {\n let commandElem = e.target;\n while (commandElem) {\n if (commandElem.dataset[constants.CommandAttributeName])\n break;\n if (commandElem === e.currentTarget)\n return;\n commandElem = commandElem.parentElement;\n }\n if (!commandElem)\n return;\n const commandName = commandElem.dataset[constants.CommandAttributeName];\n if (!commandName)\n throw new Error(\"Command data attribute is not have value.\");\n const uiElem = fundUiElementByCommand(commandElem, commandName);\n if (uiElem) {\n const result = uiElem.__execCommand(commandName, commandElem);\n if (result.status == \"success\" && result.context.transparent)\n return;\n }\n else\n console.warn(`Not find handler for command \"${commandName}\".`);\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n};\nwindow.addEventListener(\"click\", commandClickHandler, false);\n\nHTMLElement.prototype.ui = function (factory) {\n factory(this);\n return this;\n};\n\nconst UICONSTANTS = constants;\n\nexport { UICONSTANTS, UIElement };\n//# sourceMappingURL=index.js.map\n"],"names":["constants"],"mappings":"AAAA,MAAMA,WAAS,GAAG;AAClB,IAAI,iBAAiB,EAAE,WAAW;AAClC,IAAI,gBAAgB,EAAE,WAAW;AACjC,IAAI,oBAAoB,EAAE,SAAS;AACnC,IAAI,4BAA4B,EAAE,WAAW;AAC7C,IAAI,gBAAgB,EAAE,WAAW;AACjC,CAAC,CAAC;AACF;AACA,MAAM,SAAS,CAAC;AAChB,IAAI,SAAS,CAAC;AACd,IAAI,QAAQ,CAAC;AACb,IAAI,UAAU,CAAC;AACf,IAAI,kBAAkB,CAAC;AACvB;AACA,IAAI,IAAI,OAAO,GAAG,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE;AAC5C,IAAI,UAAU,CAAC,IAAI,EAAE;AACrB,QAAQ,IAAI,CAAC,IAAI;AACjB,YAAY,MAAM,qBAAqB,CAAC;AACxC,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;AACxD,YAAY,MAAM,2BAA2B,CAAC;AAC9C,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;AAC9B,QAAQ,IAAI,CAACA,WAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;AAChD,QAAQ,IAAI,CAAC,OAAO,CAACA,WAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ declare class Application<TModel extends ApplicationModel = ApplicationModel> ex
|
|
|
92
92
|
private __isDestroy;
|
|
93
93
|
private __middlewares;
|
|
94
94
|
private __lastNav;
|
|
95
|
-
constructor(env: EnvironmentModel, model: TModel);
|
|
95
|
+
constructor(env: EnvironmentModel, model: TModel, ...args: any[]);
|
|
96
96
|
get typeName(): string;
|
|
97
97
|
/** Middleware methods invoker. */
|
|
98
98
|
get invoker(): MiddlewareInvoker;
|
|
@@ -165,11 +165,13 @@ interface CallbackResult<TContext extends InvokeContext> {
|
|
|
165
165
|
type CallbackStatus = "success" | "error";
|
|
166
166
|
|
|
167
167
|
declare class ApplicationBuilder<TModel extends ApplicationModel> {
|
|
168
|
+
private __model;
|
|
168
169
|
private __appType;
|
|
169
170
|
private __middlewares;
|
|
171
|
+
constructor(model: TModel);
|
|
170
172
|
useApp(appType: typeof Application<TModel>): this;
|
|
171
173
|
useMiddleware(middleware: ((...params: Array<any>) => Middleware) | Middleware, ...params: Array<any>): this;
|
|
172
|
-
build(env: EnvironmentModel,
|
|
174
|
+
build(env: EnvironmentModel, ...args: any[]): Application<TModel>;
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
interface ParsedUrl {
|
package/package.json
CHANGED
|
@@ -24,27 +24,12 @@
|
|
|
24
24
|
"module": "dist/mjs/index.js",
|
|
25
25
|
"types": "dist/types.d.ts",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
|
-
"version": "1.0.
|
|
27
|
+
"version": "1.0.3",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@brandup/ui": "^1.0.
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@rollup/plugin-commonjs": "^25.0.8",
|
|
33
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
34
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
35
|
-
"rollup": "^4.19.0",
|
|
36
|
-
"rollup-plugin-dts": "^6.1.1",
|
|
37
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
38
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
39
|
-
"tslib": "^2.6.3",
|
|
40
|
-
"typescript": "^5.5.3"
|
|
29
|
+
"@brandup/ui": "^1.0.3"
|
|
41
30
|
},
|
|
42
31
|
"files": [
|
|
43
32
|
"dist",
|
|
44
33
|
"README.md"
|
|
45
|
-
]
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "rollup -c --bundleConfigAsCjs",
|
|
48
|
-
"watch": "rollup -c -w --bundleConfigAsCjs"
|
|
49
|
-
}
|
|
34
|
+
]
|
|
50
35
|
}
|