🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@jinntec/fore

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jinntec/fore - npm Package Compare versions

Comparing version
2.7.1
to
2.7.2
+1
-1
package.json
{
"name": "@jinntec/fore",
"version": "2.7.1",
"version": "2.7.2",
"description": "Fore - declarative user interfaces in plain HTML",

@@ -5,0 +5,0 @@ "module": "./index.js",

@@ -163,7 +163,7 @@ import { XPathUtil } from './xpath-util.js';

if (!inscopeContext) return;
const { nodeType } = inscopeContext;
if (nodeType && !XPathUtil.isAbsolutePath(this.ref)) {
this.nodeset = evaluateXPathToFirstNode(this.ref, inscopeContext, this);
if (this.nodeName === 'FX-REPEAT') {
// Repeats are special: they have multiple nodes in their nodeset
this.nodeset = evaluateXPath(this.ref, inscopeContext, this);
} else {
[this.nodeset] = evaluateXPath(this.ref, inscopeContext, this);
this.nodeset = evaluateXPath(this.ref, inscopeContext, this)[0] || null;
}

@@ -170,0 +170,0 @@ }

@@ -446,3 +446,3 @@ import { Fore } from './fore.js';

this.style.visibility = 'hidden';
console.time('init');
// console.time('init');
this.strict = !!this.hasAttribute('strict');

@@ -549,2 +549,3 @@ /*

this.dirtyState = dirtyStates.DIRTY;
this.classList.toggle('fx-modified')
},

@@ -554,2 +555,3 @@ { once: true },

this.dirtyState = dirtyStates.CLEAN;
this.classList.remove('fx-modified');
}

@@ -825,3 +827,3 @@

_processTemplateExpressions() {
console.log('processing template expressions ', this.storedTemplateExpressionByNode);
// console.log('processing template expressions ', this.storedTemplateExpressionByNode);
for (const node of Array.from(this.storedTemplateExpressionByNode.keys())) {

@@ -938,4 +940,2 @@ if (node.nodeType === Node.ATTRIBUTE_NODE) {

_handleModelConstructDone() {
this.markAsClean();
if (this.showConfirmation) {

@@ -1104,2 +1104,3 @@ window.addEventListener('beforeunload', event => {

// console.log('dataChanged', FxModel.dataChanged);
this.markAsClean();

@@ -1227,3 +1228,3 @@ this.addEventListener('dragstart', this._handleDragStart);

// const created = new Promise(resolve => {
console.log('INIT');
// console.log('INIT');
// const boundControls = Array.from(root.querySelectorAll('[ref]:not(fx-model *),fx-repeatitem'));

@@ -1253,7 +1254,7 @@

}
if (bound.nodeset !== null && !(Array.isArray(bound.nodeset) && bound.nodeset.length > 0)) {
console.log('Node exists', bound.nodeset);
if (bound.nodeset !== null && !(Array.isArray(bound.nodeset) && bound.nodeset.length === 0)) {
// console.log('Node exists', bound.nodeset);
continue;
}
console.log('Node does not exists', bound.ref);
// console.log('Node does not exists', bound.ref);

@@ -1267,4 +1268,4 @@ // We need to create that node!

// Parent is here.
console.log('insert into', bound, previousControl);
console.log('insert into nodeset', bound.nodeset);
// console.log('insert into', bound, previousControl);
// console.log('insert into nodeset', bound.nodeset);
/**

@@ -1300,3 +1301,6 @@ * @type {ParentNode}

bound.evalInContext();
if (bound.nodeName !== 'FX-REPEAT') {
// Do not try to get a bind for a nodeSET of a repeat. there are multiple.
bound.getModelItem().bind?.evalInContext();
}

@@ -1314,13 +1318,8 @@ // console.log('CREATED child', newElement);

let siblingControl = null;
/*
for (let j = i - 1; j >= 0; --j) {
const potentialSibling = boundControls[j];
if (XPathUtil.getParentBindingElement(potentialSibling) === ourParent) {
siblingControl = potentialSibling;
break; // Exit once the sibling is found
}
}
*/
for (let j = i - 1; j > 0; --j) {
const siblingOrDescendant = boundControls[j];
if (siblingOrDescendant.nodeset && !('nodeType' in siblingOrDescendant.nodeset)) {
continue;
}
if (XPathUtil.getParentBindingElement(siblingOrDescendant) === ourParent) {

@@ -1332,3 +1331,3 @@ siblingControl = siblingOrDescendant;

if (!siblingControl) {
console.log('No sibling found for', bound);
// console.log('No sibling found for', bound);
}

@@ -1350,2 +1349,7 @@ // console.log('sibling', siblingControl);

const newNode = this._createNodes(ref, parentNodeset);
if (!newNode) {
// We could not make the node for some reason. Maybe it's something like `instance('XXX')`?
continue;
}
if (newNode.nodeType === Node.ATTRIBUTE_NODE) {

@@ -1419,3 +1423,3 @@ parentNodeset.setAttributeNode(newNode);

this.originalDraggedItem = draggedItem;
console.log('DRAG START', this);
// console.log('DRAG START', this);
if (draggedItem.getAttribute('drop-action') === 'copy') {

@@ -1435,3 +1439,3 @@ event.dataTransfer.dropEffect = 'copy';

_handleDrop(event) {
console.log('DROP ON BODY', this);
// console.log('DROP ON BODY', this);
if (!this.draggedItem) {

@@ -1438,0 +1442,0 @@ return;

@@ -253,9 +253,9 @@ import { Fore } from './fore.js';

const contentType = response.headers
.get('content-type')
.split(';')[0]
.trim()
.toLowerCase();
if (contentType.startsWith('text/')) {
const contentType = response.headers.get('content-type').split(';')[0].trim().toLowerCase();
if (contentType.endsWith('/xml') || contentType.endsWith('+xml')) {
const text = await response.text();
const xml = new DOMParser().parseFromString(text, 'application/xml');
this._handleResponse(xml, resolvedUrl, contentType);
} else if (contentType.startsWith('text/')) {
const text = await response.text();
this._handleResponse(text, resolvedUrl, contentType);

@@ -265,6 +265,2 @@ } else if (contentType.endsWith('/json') || contentType.endsWith('+json')) {

this._handleResponse(json, resolvedUrl, contentType);
} else if (contentType.endsWith('/xml') || contentType.endsWith('+xml')) {
const text = await response.text();
const xml = new DOMParser().parseFromString(text, 'application/xml');
this._handleResponse(xml, resolvedUrl, contentType);
} else {

@@ -271,0 +267,0 @@ const blob = await response.blob();

@@ -6,7 +6,5 @@ import XfAbstractControl from './abstract-control.js';

evaluateXPathToFirstNode,
evaluateXPathToBoolean,
} from '../xpath-evaluation.js';
import getInScopeContext from '../getInScopeContext.js';
import { Fore } from '../fore.js';
import { ModelItem } from '../modelitem.js';
import { debounce } from '../events.js';

@@ -46,2 +44,7 @@ import { FxModel } from '../fx-model.js';

this.attachShadow({ mode: 'open' });
/**
* Flag that is raised while refreshing, to ignore any updates from the widget inside of us
*/
this._isRefreshing = false;
}

@@ -69,2 +72,9 @@

}
if (this.getAttribute('as') === 'xml') {
// We are setting serialized XML here, so when roundtripping, parse it
const value = this.widget[this.valueProp];
const parser = new DOMParser();
const doc = parser.parseFromString(value, 'application/xml');
return doc.documentElement;
}
return this.widget[this.valueProp];

@@ -180,2 +190,6 @@ }

listenOn.addEventListener(this.updateEvent, event => {
if (this._isRefreshing) {
// We are refreshing. No use in updating
return;
}
this.setValue(this._getValueOfWidget());

@@ -217,3 +231,3 @@ });

activate() {
console.log('fx-control.activate() called');
// console.log('fx-control.activate() called');
this.removeAttribute('on-demand');

@@ -249,3 +263,3 @@ this.style.display = '';

setValue(val) {
console.log('Control.setValue', val, 'on', this);
// console.log('Control.setValue', val, 'on', this);
const modelitem = this.getModelItem();

@@ -266,6 +280,5 @@

const replace = this.shadowRoot.getElementById('replace');
const widgetValue = this.getWidget()[this.valueProp];
replace.replace(this.nodeset, widgetValue);
if (modelitem && widgetValue && widgetValue !== modelitem.value) {
modelitem.value = widgetValue;
replace.replace(this.nodeset, val);
if (modelitem && val && val !== modelitem.value) {
modelitem.value = val;
FxModel.dataChanged = true;

@@ -408,7 +421,10 @@ replace.actionPerformed();

// ### when there's an `as=text` attribute serialize nodeset to prettified string
if (as === 'text') {
// ### when there's an `as="xml"` attribute serialize nodeset to prettified string
if (as === 'xml') {
const serializer = new XMLSerializer();
const pretty = Fore.prettifyXml(serializer.serializeToString(this.nodeset));
widget.value = pretty;
const pretty = serializer.serializeToString(this.nodeset);
if (widget[this.valueProp] === pretty) {
return;
}
widget[this.valueProp] = pretty;
}

@@ -558,11 +574,16 @@ if (as === 'node' && this.nodeset !== widget.value) {

async refresh(force = false) {
console.log('🔄 fx-control refresh', this);
super.refresh(force);
// console.log('refresh template', this.template);
// const {widget} = this;
try {
this._isRefreshing = true;
// console.log('🔄 fx-control refresh', this);
super.refresh(force);
// console.log('refresh template', this.template);
// const {widget} = this;
// ### if we find a ref on control we have a 'select' control of some kind
const widget = this.getWidget();
this._handleBoundWidget(widget, force);
this._handleDataAttributeBinding();
// ### if we find a ref on control we have a 'select' control of some kind
const widget = this.getWidget();
this._handleBoundWidget(widget, force);
this._handleDataAttributeBinding();
} finally {
this._isRefreshing = false;
}
Fore.refreshChildren(this, force);

@@ -569,0 +590,0 @@ }

@@ -5,3 +5,2 @@ import { Fore } from '../fore.js';

import getInScopeContext from '../getInScopeContext.js';
// import {markdown} from '../drawdown.js';

@@ -50,3 +49,3 @@ /**

<slot name="label"></slot>
<span id="value">

@@ -53,0 +52,0 @@ <slot name="default"></slot>

@@ -635,7 +635,9 @@ import './fx-repeatitem.js';

this.getOwnerForm().initData(repeatItem);
const repeatItemClone = repeatItem.nodeset.cloneNode(true);
this.clearTextValues(repeatItemClone);
// this.createdNodeset = repeatItem.nodeset.cloneNode(true);
this.createdNodeset = repeatItemClone;
if (repeatItem.nodeset.nodeType) {
// Do not try to d things with repeats that do not reason over nodes
const repeatItemClone = repeatItem.nodeset.cloneNode(true);
this.clearTextValues(repeatItemClone);
// this.createdNodeset = repeatItem.nodeset.cloneNode(true);
this.createdNodeset = repeatItemClone;
}
// console.log('createdNodeset', this.createdNodeset)

@@ -642,0 +644,0 @@ }

@@ -16,3 +16,2 @@ import {

import { prettifyXml } from './functions/common-function.js';
import * as fx from 'fontoxpath';

@@ -493,2 +492,3 @@ const XFORMS_NAMESPACE_URI = 'http://www.w3.org/2002/xforms';

{
xmlSerializer: new XMLSerializer(),
debug: true,

@@ -558,2 +558,3 @@ currentContext: { formElement, variables },

namespaceResolver,
xmlSerializer: new XMLSerializer(),
});

@@ -576,2 +577,3 @@ // console.log('evaluateXPathToFirstNode',xpath, result);

}
return null;
}

@@ -599,2 +601,3 @@

namespaceResolver,
xmlSerializer: new XMLSerializer(),
});

@@ -639,2 +642,3 @@ // console.log('evaluateXPathToNodes',xpath, result);

namespaceResolver,
xmlSerializer: new XMLSerializer(),
});

@@ -680,2 +684,3 @@ } catch (e) {

namespaceResolver,
xmlSerializer: new XMLSerializer(),
});

@@ -724,2 +729,3 @@ } catch (e) {

namespaceResolver,
xmlSerializer: new XMLSerializer(),
},

@@ -766,2 +772,3 @@ );

namespaceResolver,
xmlSerializer: new XMLSerializer(),
});

@@ -768,0 +775,0 @@ } catch (e) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display