@jinntec/fore 1.7.1 → 1.8.0
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/README.md +7 -7
- package/dist/fore-dev.js +2 -2
- package/dist/fore-dev.js.map +1 -1
- package/dist/fore.js +2 -2
- package/dist/fore.js.map +1 -1
- package/index.js +2 -1
- package/package.json +3 -2
- package/src/actions/abstract-action.js +1 -1
- package/src/actions/fx-call.js +74 -0
- package/src/actions/fx-load.js +2 -2
- package/src/fx-fore.js +5 -0
- package/src/fx-instance.js +5 -2
- package/src/fx-submission.js +17 -4
- package/src/tools/fx-action-log.js +1 -2
package/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import './src/tools/fx-devtools.js';
|
|
|
30
30
|
import './src/tools/fx-dom-inspector.js';
|
|
31
31
|
import './src/lab/fore-component.js';
|
|
32
32
|
import './src/tools/fx-json-instance.js';
|
|
33
|
-
import './src/tools/fx-minimap.js';
|
|
33
|
+
// import './src/tools/fx-minimap.js';
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
// import './src/ui/fx-checkbox-group.js';
|
|
@@ -56,6 +56,7 @@ import './src/actions/fx-reload.js';
|
|
|
56
56
|
import './src/actions/fx-reset.js';
|
|
57
57
|
import './src/actions/fx-load.js';
|
|
58
58
|
import './src/actions/fx-toggleboolean.js';
|
|
59
|
+
import './src/actions/fx-call.js';
|
|
59
60
|
|
|
60
61
|
import './src/functions/fx-function.js';
|
|
61
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jinntec/fore",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Fore - declarative user interfaces in plain HTML",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"rollup": "^2.75.4",
|
|
61
61
|
"rollup-plugin-babel": "^4.4.0",
|
|
62
62
|
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
63
|
+
"rollup-plugin-version-injector": "^1.3.3",
|
|
63
64
|
"typescript": "^4.7.2",
|
|
64
65
|
"web-component-analyzer": "^1.1.6",
|
|
65
66
|
"xmlserializer": "^0.6.1"
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"start:build": "cd dist && es-dev-server --open",
|
|
82
83
|
"build": "rimraf dist && rollup -c rollup.config.js",
|
|
83
84
|
"start": "es-dev-server --app-index doc/index.html --node-resolve --watch --open",
|
|
84
|
-
"
|
|
85
|
+
"install-demos": "cd demo && npm i"
|
|
85
86
|
},
|
|
86
87
|
"keywords": [
|
|
87
88
|
"Fore",
|
|
@@ -187,7 +187,7 @@ export class AbstractAction extends foreElementMixin(HTMLElement) {
|
|
|
187
187
|
// console.log('execute', this.event);
|
|
188
188
|
|
|
189
189
|
|
|
190
|
-
if (e && e.target.nodeType !== Node.DOCUMENT_NODE ){
|
|
190
|
+
if (e && e.target.nodeType !== Node.DOCUMENT_NODE && e.target !== window ){
|
|
191
191
|
/*
|
|
192
192
|
### ignore event if there's a parent fore and the current element is NOT part of it. This avoids
|
|
193
193
|
### an event to fire twice on an inner one and the surrounding one(s).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import '../fx-model.js';
|
|
2
|
+
import {AbstractAction} from './abstract-action.js';
|
|
3
|
+
import {evaluateXPath, evaluateXPathToString} from "../xpath-evaluation.js";
|
|
4
|
+
import {Fore} from "../fore";
|
|
5
|
+
import getInScopeContext from "../getInScopeContext";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `fx-call`
|
|
9
|
+
*
|
|
10
|
+
* @customElement
|
|
11
|
+
*/
|
|
12
|
+
export default class FxCall extends AbstractAction {
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
...super.properties,
|
|
16
|
+
action: {
|
|
17
|
+
type: String,
|
|
18
|
+
},
|
|
19
|
+
fn: {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.action = '';
|
|
28
|
+
this.fn = '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
if (super.connectedCallback) {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
}
|
|
35
|
+
if (this.hasAttribute('action')) {
|
|
36
|
+
this.action = this.getAttribute('action');
|
|
37
|
+
} else if(this.hasAttribute('function')){
|
|
38
|
+
this.fn = this.getAttribute('function');
|
|
39
|
+
|
|
40
|
+
}else{
|
|
41
|
+
throw new Error('fx-call must specify an "action" or "function" attribute');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async perform() {
|
|
46
|
+
super.perform();
|
|
47
|
+
if(this.action){
|
|
48
|
+
await this._callAction();
|
|
49
|
+
}
|
|
50
|
+
// execute function
|
|
51
|
+
if(this.fn){
|
|
52
|
+
this._callFunction();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* find action and execute it
|
|
58
|
+
*/
|
|
59
|
+
async _callAction(){
|
|
60
|
+
const action = document.querySelector(`#${this.action}`);
|
|
61
|
+
if(action){
|
|
62
|
+
await action.perform();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_callFunction(){
|
|
67
|
+
const inscope = getInScopeContext(this, 'instance()',this);
|
|
68
|
+
evaluateXPath(this.fn, inscope, this);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!customElements.get('fx-call')) {
|
|
73
|
+
window.customElements.define('fx-call', FxCall);
|
|
74
|
+
}
|
package/src/actions/fx-load.js
CHANGED
|
@@ -122,7 +122,7 @@ class FxLoad extends AbstractAction {
|
|
|
122
122
|
);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
const resolvedUrl = this.evaluateAttributeTemplateExpression(this.url,this);
|
|
126
126
|
if (this.attachTo === '_blank') {
|
|
127
127
|
window.open(this.url);
|
|
128
128
|
}
|
|
@@ -132,7 +132,7 @@ class FxLoad extends AbstractAction {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
try {
|
|
135
|
-
const response = await fetch(
|
|
135
|
+
const response = await fetch(resolvedUrl, {
|
|
136
136
|
method: 'GET',
|
|
137
137
|
mode: 'cors',
|
|
138
138
|
credentials: 'same-origin',
|
package/src/fx-fore.js
CHANGED
|
@@ -55,6 +55,9 @@ export class FxFore extends HTMLElement {
|
|
|
55
55
|
*/
|
|
56
56
|
validateOn: {
|
|
57
57
|
type: String
|
|
58
|
+
},
|
|
59
|
+
version: {
|
|
60
|
+
type: String
|
|
58
61
|
}
|
|
59
62
|
};
|
|
60
63
|
}
|
|
@@ -69,6 +72,8 @@ export class FxFore extends HTMLElement {
|
|
|
69
72
|
*/
|
|
70
73
|
constructor() {
|
|
71
74
|
super();
|
|
75
|
+
this.version = '[VI]Version: {version} - built on {date}[/VI]';
|
|
76
|
+
|
|
72
77
|
this.model = {};
|
|
73
78
|
this.inited=false;
|
|
74
79
|
// this.addEventListener('model-construct-done', this._handleModelConstructDone);
|
package/src/fx-instance.js
CHANGED
|
@@ -20,8 +20,7 @@ async function handleResponse(response) {
|
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
if (
|
|
23
|
-
responseContentType.startsWith('text/
|
|
24
|
-
responseContentType.startsWith('text/markdown')
|
|
23
|
+
responseContentType.startsWith('text/')
|
|
25
24
|
) {
|
|
26
25
|
// console.log("********** inside res plain *********");
|
|
27
26
|
return response.text();
|
|
@@ -207,6 +206,10 @@ export class FxInstance extends HTMLElement {
|
|
|
207
206
|
this.instanceData = {};
|
|
208
207
|
this.originalInstance = [...this.instanceData];
|
|
209
208
|
}
|
|
209
|
+
if(this.type === 'text'){
|
|
210
|
+
this.instanceData = '';
|
|
211
|
+
this.originalInstance = '';
|
|
212
|
+
}
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
async _loadData() {
|
package/src/fx-submission.js
CHANGED
|
@@ -242,6 +242,9 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
242
242
|
if (serialized && instance.getAttribute('type') === 'json') {
|
|
243
243
|
data = JSON.parse(serialized);
|
|
244
244
|
}
|
|
245
|
+
if (serialized && instance.getAttribute('type') === 'text') {
|
|
246
|
+
data = serialized;
|
|
247
|
+
}
|
|
245
248
|
return data;
|
|
246
249
|
}
|
|
247
250
|
|
|
@@ -263,6 +266,9 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
263
266
|
// console.warn('JSON serialization is not yet supported')
|
|
264
267
|
return JSON.stringify(relevantNodes);
|
|
265
268
|
}
|
|
269
|
+
if (instanceType === 'text') {
|
|
270
|
+
return relevantNodes;
|
|
271
|
+
}
|
|
266
272
|
throw new Error('unknown instance type ', instanceType);
|
|
267
273
|
}
|
|
268
274
|
|
|
@@ -394,10 +400,17 @@ export class FxSubmission extends foreElementMixin(HTMLElement) {
|
|
|
394
400
|
}
|
|
395
401
|
|
|
396
402
|
if (this.replace === 'all') {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
const target = this._getProperty('target');
|
|
404
|
+
if(target && target === '_blank'){
|
|
405
|
+
const win = window.open("", "_blank");
|
|
406
|
+
win.document.write(data);
|
|
407
|
+
win.document.close();
|
|
408
|
+
}else{
|
|
409
|
+
document.open();
|
|
410
|
+
document.write(data);
|
|
411
|
+
document.close();
|
|
412
|
+
window.location.href = resolvedUrl;
|
|
413
|
+
}
|
|
401
414
|
// document.getElementsByTagName('html')[0].innerHTML = data;
|
|
402
415
|
}
|
|
403
416
|
if (this.replace === 'target' && contentType.startsWith('text/html')) {
|
|
@@ -459,10 +459,9 @@ export class FxActionLog extends HTMLElement {
|
|
|
459
459
|
*/
|
|
460
460
|
_logDetails(e) {
|
|
461
461
|
const eventType = e.type;
|
|
462
|
-
// console.log('>>>> event type', type)
|
|
463
462
|
const path = XPathUtil.getPath(e.target);
|
|
463
|
+
// console.log('>>>> _logDetails', path);
|
|
464
464
|
const cut = path.substring(path.indexOf('/fx-fore'), path.length);
|
|
465
|
-
;
|
|
466
465
|
const xpath = `/${cut}`;
|
|
467
466
|
const short = cut.replaceAll('fx-', '');
|
|
468
467
|
|