@brandup/ui-app 1.0.1 → 1.0.2
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 +32 -69
- package/dist/cjs/index.js.map +1 -1
- package/dist/mjs/index.js +32 -69
- 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
|
@@ -67,15 +67,6 @@ class UIElement {
|
|
|
67
67
|
isExecuting: false
|
|
68
68
|
};
|
|
69
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
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
70
|
hasCommand(name) {
|
|
80
71
|
return name.toLowerCase() in this.__commandHandlers;
|
|
81
72
|
}
|
|
@@ -83,71 +74,48 @@ class UIElement {
|
|
|
83
74
|
if (!this.__element)
|
|
84
75
|
throw new Error("UIElement is not set HTMLElement.");
|
|
85
76
|
const key = name.toLowerCase();
|
|
86
|
-
|
|
77
|
+
const handler = this.__commandHandlers[key];
|
|
78
|
+
if (!handler)
|
|
87
79
|
throw new Error(`Command "${name}" is not registered.`);
|
|
88
80
|
const context = {
|
|
89
81
|
target: elem,
|
|
90
82
|
uiElem: this,
|
|
91
83
|
transparent: false
|
|
92
84
|
};
|
|
93
|
-
const handler = this.__commandHandlers[key];
|
|
94
85
|
if (handler.isExecuting)
|
|
95
|
-
return {
|
|
86
|
+
return { status: "already", context };
|
|
96
87
|
handler.isExecuting = true;
|
|
97
88
|
if (!this._onCanExecCommand(name, elem)) {
|
|
98
89
|
handler.isExecuting = false;
|
|
99
|
-
return {
|
|
90
|
+
return { status: "disallow", context };
|
|
100
91
|
}
|
|
101
|
-
if (handler.canExecute && !handler.canExecute(
|
|
92
|
+
if (handler.canExecute && !handler.canExecute(context)) {
|
|
102
93
|
handler.isExecuting = false;
|
|
103
|
-
return {
|
|
94
|
+
return { status: "disallow", context };
|
|
104
95
|
}
|
|
105
96
|
this.raiseEvent("command", {
|
|
106
97
|
name: handler.name,
|
|
107
98
|
uiElem: this,
|
|
108
99
|
elem: this.__element
|
|
109
100
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
let isAsync;
|
|
102
|
+
try {
|
|
103
|
+
const handlerResult = handler.execute(context);
|
|
104
|
+
if (handlerResult && handlerResult instanceof Promise) {
|
|
105
|
+
isAsync = true;
|
|
106
|
+
elem.classList.add(CommandExecutingCssClassName);
|
|
107
|
+
handlerResult
|
|
108
|
+
.finally(() => {
|
|
109
|
+
elem.classList.remove(CommandExecutingCssClassName);
|
|
110
|
+
handler.isExecuting = false;
|
|
111
|
+
});
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
elem.classList.add(CommandExecutingCssClassName);
|
|
122
|
-
let timeoutId = 0;
|
|
123
|
-
const endFunc = () => {
|
|
114
|
+
finally {
|
|
115
|
+
if (!isAsync)
|
|
124
116
|
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;
|
|
147
117
|
}
|
|
148
|
-
|
|
149
|
-
throw new Error("Not set command execute flow.");
|
|
150
|
-
return { result: CommandsExecStatus.Success, context: context };
|
|
118
|
+
return { status: "success", context: context };
|
|
151
119
|
}
|
|
152
120
|
verifyCommandName(name) {
|
|
153
121
|
const key = name.toLowerCase();
|
|
@@ -170,12 +138,6 @@ class UIElement {
|
|
|
170
138
|
delete elem[ElemPropertyName];
|
|
171
139
|
}
|
|
172
140
|
}
|
|
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
141
|
const fundUiElementByCommand = (elem, commandName) => {
|
|
180
142
|
while (elem) {
|
|
181
143
|
if (elem.dataset[ElemAttributeName]) {
|
|
@@ -207,14 +169,13 @@ const commandClickHandler = (e) => {
|
|
|
207
169
|
if (!commandName)
|
|
208
170
|
throw new Error("Command data attribute is not have value.");
|
|
209
171
|
const uiElem = fundUiElementByCommand(commandElem, commandName);
|
|
210
|
-
if (uiElem
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
else {
|
|
214
|
-
const commandResult = uiElem.execCommand(commandName, commandElem);
|
|
215
|
-
if (commandResult.context.transparent)
|
|
172
|
+
if (uiElem) {
|
|
173
|
+
const result = uiElem.execCommand(commandName, commandElem);
|
|
174
|
+
if (result.status == "success" && result.context.transparent)
|
|
216
175
|
return;
|
|
217
176
|
}
|
|
177
|
+
else
|
|
178
|
+
console.warn(`Not find handler for command "${commandName}".`);
|
|
218
179
|
e.preventDefault();
|
|
219
180
|
e.stopPropagation();
|
|
220
181
|
e.stopImmediatePropagation();
|
|
@@ -638,7 +599,7 @@ class Application extends UIElement {
|
|
|
638
599
|
__isDestroy = false;
|
|
639
600
|
__middlewares = {};
|
|
640
601
|
__lastNav = null;
|
|
641
|
-
constructor(env, model) {
|
|
602
|
+
constructor(env, model, ...args) {
|
|
642
603
|
super();
|
|
643
604
|
this.env = env;
|
|
644
605
|
this.model = model;
|
|
@@ -848,8 +809,12 @@ class Application extends UIElement {
|
|
|
848
809
|
}
|
|
849
810
|
|
|
850
811
|
class ApplicationBuilder {
|
|
812
|
+
__model;
|
|
851
813
|
__appType = (Application);
|
|
852
814
|
__middlewares = [];
|
|
815
|
+
constructor(model) {
|
|
816
|
+
this.__model = model;
|
|
817
|
+
}
|
|
853
818
|
useApp(appType) {
|
|
854
819
|
this.__appType = appType;
|
|
855
820
|
return this;
|
|
@@ -865,14 +830,12 @@ class ApplicationBuilder {
|
|
|
865
830
|
this.__middlewares.push(midl);
|
|
866
831
|
return this;
|
|
867
832
|
}
|
|
868
|
-
build(env,
|
|
833
|
+
build(env, ...args) {
|
|
869
834
|
if (!env)
|
|
870
835
|
throw new Error("Parameter env is required.");
|
|
871
|
-
if (!model)
|
|
872
|
-
throw new Error("Parameter model is required.");
|
|
873
836
|
if (!env.basePath)
|
|
874
837
|
env.basePath = "/";
|
|
875
|
-
const app = new this.__appType(env,
|
|
838
|
+
const app = new this.__appType(env, this.__model, ...args);
|
|
876
839
|
app.initialize(this.__middlewares);
|
|
877
840
|
return app;
|
|
878
841
|
}
|
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,SA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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 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 const handler = this.__commandHandlers[key];\n if (!handler)\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target: elem,\n uiElem: this,\n transparent: false\n };\n if (handler.isExecuting)\n return { status: \"already\", context };\n handler.isExecuting = true;\n if (!this._onCanExecCommand(name, elem)) {\n handler.isExecuting = false;\n return { status: \"disallow\", context };\n }\n if (handler.canExecute && !handler.canExecute(context)) {\n handler.isExecuting = false;\n return { status: \"disallow\", context };\n }\n this.raiseEvent(\"command\", {\n name: handler.name,\n uiElem: this,\n elem: this.__element\n });\n let isAsync;\n try {\n const handlerResult = handler.execute(context);\n if (handlerResult && handlerResult instanceof Promise) {\n isAsync = true;\n elem.classList.add(CommandExecutingCssClassName);\n handlerResult\n .finally(() => {\n elem.classList.remove(CommandExecutingCssClassName);\n handler.isExecuting = false;\n });\n }\n }\n finally {\n if (!isAsync)\n handler.isExecuting = false;\n }\n return { status: \"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}\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) {\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\nexport { CommandAttributeName, CommandExecutingCssClassName, 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,SA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/mjs/index.js
CHANGED
|
@@ -65,15 +65,6 @@ class UIElement {
|
|
|
65
65
|
isExecuting: false
|
|
66
66
|
};
|
|
67
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
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
68
|
hasCommand(name) {
|
|
78
69
|
return name.toLowerCase() in this.__commandHandlers;
|
|
79
70
|
}
|
|
@@ -81,71 +72,48 @@ class UIElement {
|
|
|
81
72
|
if (!this.__element)
|
|
82
73
|
throw new Error("UIElement is not set HTMLElement.");
|
|
83
74
|
const key = name.toLowerCase();
|
|
84
|
-
|
|
75
|
+
const handler = this.__commandHandlers[key];
|
|
76
|
+
if (!handler)
|
|
85
77
|
throw new Error(`Command "${name}" is not registered.`);
|
|
86
78
|
const context = {
|
|
87
79
|
target: elem,
|
|
88
80
|
uiElem: this,
|
|
89
81
|
transparent: false
|
|
90
82
|
};
|
|
91
|
-
const handler = this.__commandHandlers[key];
|
|
92
83
|
if (handler.isExecuting)
|
|
93
|
-
return {
|
|
84
|
+
return { status: "already", context };
|
|
94
85
|
handler.isExecuting = true;
|
|
95
86
|
if (!this._onCanExecCommand(name, elem)) {
|
|
96
87
|
handler.isExecuting = false;
|
|
97
|
-
return {
|
|
88
|
+
return { status: "disallow", context };
|
|
98
89
|
}
|
|
99
|
-
if (handler.canExecute && !handler.canExecute(
|
|
90
|
+
if (handler.canExecute && !handler.canExecute(context)) {
|
|
100
91
|
handler.isExecuting = false;
|
|
101
|
-
return {
|
|
92
|
+
return { status: "disallow", context };
|
|
102
93
|
}
|
|
103
94
|
this.raiseEvent("command", {
|
|
104
95
|
name: handler.name,
|
|
105
96
|
uiElem: this,
|
|
106
97
|
elem: this.__element
|
|
107
98
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
99
|
+
let isAsync;
|
|
100
|
+
try {
|
|
101
|
+
const handlerResult = handler.execute(context);
|
|
102
|
+
if (handlerResult && handlerResult instanceof Promise) {
|
|
103
|
+
isAsync = true;
|
|
104
|
+
elem.classList.add(CommandExecutingCssClassName);
|
|
105
|
+
handlerResult
|
|
106
|
+
.finally(() => {
|
|
107
|
+
elem.classList.remove(CommandExecutingCssClassName);
|
|
108
|
+
handler.isExecuting = false;
|
|
109
|
+
});
|
|
115
110
|
}
|
|
116
111
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
elem.classList.add(CommandExecutingCssClassName);
|
|
120
|
-
let timeoutId = 0;
|
|
121
|
-
const endFunc = () => {
|
|
112
|
+
finally {
|
|
113
|
+
if (!isAsync)
|
|
122
114
|
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;
|
|
145
115
|
}
|
|
146
|
-
|
|
147
|
-
throw new Error("Not set command execute flow.");
|
|
148
|
-
return { result: CommandsExecStatus.Success, context: context };
|
|
116
|
+
return { status: "success", context: context };
|
|
149
117
|
}
|
|
150
118
|
verifyCommandName(name) {
|
|
151
119
|
const key = name.toLowerCase();
|
|
@@ -168,12 +136,6 @@ class UIElement {
|
|
|
168
136
|
delete elem[ElemPropertyName];
|
|
169
137
|
}
|
|
170
138
|
}
|
|
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
139
|
const fundUiElementByCommand = (elem, commandName) => {
|
|
178
140
|
while (elem) {
|
|
179
141
|
if (elem.dataset[ElemAttributeName]) {
|
|
@@ -205,14 +167,13 @@ const commandClickHandler = (e) => {
|
|
|
205
167
|
if (!commandName)
|
|
206
168
|
throw new Error("Command data attribute is not have value.");
|
|
207
169
|
const uiElem = fundUiElementByCommand(commandElem, commandName);
|
|
208
|
-
if (uiElem
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
else {
|
|
212
|
-
const commandResult = uiElem.execCommand(commandName, commandElem);
|
|
213
|
-
if (commandResult.context.transparent)
|
|
170
|
+
if (uiElem) {
|
|
171
|
+
const result = uiElem.execCommand(commandName, commandElem);
|
|
172
|
+
if (result.status == "success" && result.context.transparent)
|
|
214
173
|
return;
|
|
215
174
|
}
|
|
175
|
+
else
|
|
176
|
+
console.warn(`Not find handler for command "${commandName}".`);
|
|
216
177
|
e.preventDefault();
|
|
217
178
|
e.stopPropagation();
|
|
218
179
|
e.stopImmediatePropagation();
|
|
@@ -636,7 +597,7 @@ class Application extends UIElement {
|
|
|
636
597
|
__isDestroy = false;
|
|
637
598
|
__middlewares = {};
|
|
638
599
|
__lastNav = null;
|
|
639
|
-
constructor(env, model) {
|
|
600
|
+
constructor(env, model, ...args) {
|
|
640
601
|
super();
|
|
641
602
|
this.env = env;
|
|
642
603
|
this.model = model;
|
|
@@ -846,8 +807,12 @@ class Application extends UIElement {
|
|
|
846
807
|
}
|
|
847
808
|
|
|
848
809
|
class ApplicationBuilder {
|
|
810
|
+
__model;
|
|
849
811
|
__appType = (Application);
|
|
850
812
|
__middlewares = [];
|
|
813
|
+
constructor(model) {
|
|
814
|
+
this.__model = model;
|
|
815
|
+
}
|
|
851
816
|
useApp(appType) {
|
|
852
817
|
this.__appType = appType;
|
|
853
818
|
return this;
|
|
@@ -863,14 +828,12 @@ class ApplicationBuilder {
|
|
|
863
828
|
this.__middlewares.push(midl);
|
|
864
829
|
return this;
|
|
865
830
|
}
|
|
866
|
-
build(env,
|
|
831
|
+
build(env, ...args) {
|
|
867
832
|
if (!env)
|
|
868
833
|
throw new Error("Parameter env is required.");
|
|
869
|
-
if (!model)
|
|
870
|
-
throw new Error("Parameter model is required.");
|
|
871
834
|
if (!env.basePath)
|
|
872
835
|
env.basePath = "/";
|
|
873
|
-
const app = new this.__appType(env,
|
|
836
|
+
const app = new this.__appType(env, this.__model, ...args);
|
|
874
837
|
app.initialize(this.__middlewares);
|
|
875
838
|
return app;
|
|
876
839
|
}
|
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 { Command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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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 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 const handler = this.__commandHandlers[key];\n if (!handler)\n throw new Error(`Command \"${name}\" is not registered.`);\n const context = {\n target: elem,\n uiElem: this,\n transparent: false\n };\n if (handler.isExecuting)\n return { status: \"already\", context };\n handler.isExecuting = true;\n if (!this._onCanExecCommand(name, elem)) {\n handler.isExecuting = false;\n return { status: \"disallow\", context };\n }\n if (handler.canExecute && !handler.canExecute(context)) {\n handler.isExecuting = false;\n return { status: \"disallow\", context };\n }\n this.raiseEvent(\"command\", {\n name: handler.name,\n uiElem: this,\n elem: this.__element\n });\n let isAsync;\n try {\n const handlerResult = handler.execute(context);\n if (handlerResult && handlerResult instanceof Promise) {\n isAsync = true;\n elem.classList.add(CommandExecutingCssClassName);\n handlerResult\n .finally(() => {\n elem.classList.remove(CommandExecutingCssClassName);\n handler.isExecuting = false;\n });\n }\n }\n finally {\n if (!isAsync)\n handler.isExecuting = false;\n }\n return { status: \"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}\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) {\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\nexport { CommandAttributeName, CommandExecutingCssClassName, 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,IAA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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.2",
|
|
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.2"
|
|
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
|
}
|