@digipair/skill-web 0.48.1 → 0.48.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/index.cjs.js
CHANGED
|
@@ -68,37 +68,26 @@ let WebService = class WebService {
|
|
|
68
68
|
}
|
|
69
69
|
return output;
|
|
70
70
|
}
|
|
71
|
-
async pins2html(pins) {
|
|
71
|
+
async pins2html(pins, context) {
|
|
72
72
|
const dom = new jsdom.JSDOM();
|
|
73
73
|
const element = dom.window.document.createElement('section');
|
|
74
|
-
await this.generateElementsFromPins(pins, element,
|
|
74
|
+
await this.generateElementsFromPins(pins, element, {
|
|
75
|
+
config: {
|
|
76
|
+
VERSIONS: context.config.VERSIONS || {}
|
|
77
|
+
},
|
|
78
|
+
variables: context.variables || {},
|
|
79
|
+
request: context.request || {}
|
|
80
|
+
}, dom.window.document);
|
|
75
81
|
return element.innerHTML;
|
|
76
82
|
}
|
|
77
|
-
async generateElementsFromPins(pinsList, parent,
|
|
83
|
+
async generateElementsFromPins(pinsList, parent, context, document) {
|
|
78
84
|
for(let i = 0; i < pinsList.length; i++){
|
|
79
85
|
const item = pinsList[i];
|
|
80
|
-
await
|
|
86
|
+
await engine.generateElementFromPins(item, parent, context, document, {
|
|
87
|
+
import: false
|
|
88
|
+
});
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
|
-
async generateElementFromPins(pinsSettings, parent, dom) {
|
|
84
|
-
const element = dom.window.document.createElement(pinsSettings.element);
|
|
85
|
-
element.setAttribute('data-ssr', '1');
|
|
86
|
-
const settings = pinsSettings;
|
|
87
|
-
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
|
88
|
-
if (key === 'textContent') {
|
|
89
|
-
element.textContent = value;
|
|
90
|
-
} else if (key === 'innerHTML') {
|
|
91
|
-
element.innerHTML = value;
|
|
92
|
-
} else if (typeof value === 'string') {
|
|
93
|
-
element.setAttribute(key, value);
|
|
94
|
-
} else {
|
|
95
|
-
element[key] = value;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
const pinsList = settings.pins || [];
|
|
99
|
-
await this.generateElementsFromPins(pinsList, element, dom);
|
|
100
|
-
parent.appendChild(element);
|
|
101
|
-
}
|
|
102
91
|
async page(params, _pinsSettingsList, context) {
|
|
103
92
|
var _context_request_body;
|
|
104
93
|
const { body, head, ssr = true, styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', factoryInitialize = [], browserInitialize = [], browserLoad = [] } = params;
|
|
@@ -114,7 +103,7 @@ let WebService = class WebService {
|
|
|
114
103
|
<!DOCTYPE html>
|
|
115
104
|
<html style="${styleHtml}">
|
|
116
105
|
<head>
|
|
117
|
-
${head ? await this.pins2html(head) : `
|
|
106
|
+
${head ? await this.pins2html(head, context) : `
|
|
118
107
|
<meta charset="UTF-8" />
|
|
119
108
|
<title>Digipair</title>
|
|
120
109
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
@@ -153,7 +142,7 @@ let WebService = class WebService {
|
|
|
153
142
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
|
154
143
|
|
|
155
144
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
|
156
|
-
document.querySelectorAll('body > [data-
|
|
145
|
+
document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
|
|
157
146
|
for (let i = 0; i < pinsList.length; i++) {
|
|
158
147
|
const item = pinsList[i];
|
|
159
148
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
|
@@ -164,7 +153,7 @@ let WebService = class WebService {
|
|
|
164
153
|
}, 1);
|
|
165
154
|
</script>
|
|
166
155
|
|
|
167
|
-
${ssr ? await this.pins2html(body) : ''}
|
|
156
|
+
${ssr ? await this.pins2html(body, context) : ''}
|
|
168
157
|
</body>
|
|
169
158
|
</html>
|
|
170
159
|
`;
|
package/index.esm.js
CHANGED
|
@@ -23901,14 +23901,14 @@ function indent(str, spaces) {
|
|
|
23901
23901
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
23902
23902
|
// match is required
|
|
23903
23903
|
if (!match) {
|
|
23904
|
-
return
|
|
23904
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
|
|
23905
23905
|
v: nextMatch1
|
|
23906
23906
|
};
|
|
23907
23907
|
}
|
|
23908
23908
|
var token = match.token, offset = match.offset;
|
|
23909
23909
|
i1 += offset;
|
|
23910
23910
|
if (token === " ") {
|
|
23911
|
-
return
|
|
23911
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23912
23912
|
}
|
|
23913
23913
|
tokens1 = _to_consumable_array$1(tokens1).concat([
|
|
23914
23914
|
token
|
|
@@ -23927,7 +23927,7 @@ function indent(str, spaces) {
|
|
|
23927
23927
|
if (contextKeys.some(function(el) {
|
|
23928
23928
|
return el.startsWith(name);
|
|
23929
23929
|
})) {
|
|
23930
|
-
return
|
|
23930
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23931
23931
|
}
|
|
23932
23932
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23933
23933
|
return el === name;
|
|
@@ -23946,9 +23946,9 @@ function indent(str, spaces) {
|
|
|
23946
23946
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23947
23947
|
return el.startsWith(name);
|
|
23948
23948
|
})) {
|
|
23949
|
-
return
|
|
23949
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23950
23950
|
}
|
|
23951
|
-
return
|
|
23951
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
|
|
23952
23952
|
v: nextMatch1
|
|
23953
23953
|
};
|
|
23954
23954
|
};
|
|
@@ -27936,6 +27936,74 @@ const executePinsList = async (pinsSettingsList, context)=>{
|
|
|
27936
27936
|
}
|
|
27937
27937
|
return previous;
|
|
27938
27938
|
};
|
|
27939
|
+
const generateElementFromPins = async (pinsSettings, parent, context, document = typeof window !== 'undefined' ? window.document : global.document, options = {
|
|
27940
|
+
import: true
|
|
27941
|
+
})=>{
|
|
27942
|
+
var _settings_conditions, _settings_conditions1;
|
|
27943
|
+
let settings = await preparePinsSettings(pinsSettings, context);
|
|
27944
|
+
const alias = _config.ALIAS.find((alias)=>settings.library.split(':')[0] === alias.name);
|
|
27945
|
+
if (alias) {
|
|
27946
|
+
settings = await preparePinsSettings(_extends({}, settings, alias), {
|
|
27947
|
+
settings
|
|
27948
|
+
});
|
|
27949
|
+
}
|
|
27950
|
+
if ((_settings_conditions = settings.conditions) == null ? void 0 : _settings_conditions.each) {
|
|
27951
|
+
for(let index = 0; index < settings.conditions.each.length; index++){
|
|
27952
|
+
const item = settings.conditions.each[index];
|
|
27953
|
+
await generateElementFromPins(_extends({}, pinsSettings, {
|
|
27954
|
+
conditions: _extends({}, pinsSettings.conditions, {
|
|
27955
|
+
each: undefined
|
|
27956
|
+
})
|
|
27957
|
+
}), parent, _extends({}, context, {
|
|
27958
|
+
item,
|
|
27959
|
+
index,
|
|
27960
|
+
parent: {
|
|
27961
|
+
item: context.item,
|
|
27962
|
+
index: context.index,
|
|
27963
|
+
parent: context.parent
|
|
27964
|
+
}
|
|
27965
|
+
}), document, options);
|
|
27966
|
+
}
|
|
27967
|
+
return;
|
|
27968
|
+
}
|
|
27969
|
+
if (typeof ((_settings_conditions1 = settings.conditions) == null ? void 0 : _settings_conditions1.if) !== 'undefined' && !settings.conditions.if) {
|
|
27970
|
+
return;
|
|
27971
|
+
}
|
|
27972
|
+
const element = document.createElement(pinsSettings.element);
|
|
27973
|
+
element.setAttribute('data-digipair-pins', '');
|
|
27974
|
+
const library = pinsSettings.library;
|
|
27975
|
+
if (options.import && library !== 'web' && !_config.LIBRARIES[library]) {
|
|
27976
|
+
const config = context.config || {};
|
|
27977
|
+
const version = (config.VERSIONS || {})[library] || 'latest';
|
|
27978
|
+
import(isRemoteVersion.test(version) ? `${version}` : `${_config.BASE_URL}/${library}@${version}/index.esm.js`);
|
|
27979
|
+
}
|
|
27980
|
+
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
|
27981
|
+
if (key === 'textContent') {
|
|
27982
|
+
element.textContent = value;
|
|
27983
|
+
} else if (key === 'innerHTML') {
|
|
27984
|
+
element.innerHTML = value;
|
|
27985
|
+
} else if (typeof value === 'string') {
|
|
27986
|
+
element.setAttribute(key, value);
|
|
27987
|
+
} else {
|
|
27988
|
+
element[key] = value;
|
|
27989
|
+
}
|
|
27990
|
+
});
|
|
27991
|
+
Object.entries(settings.events || {}).forEach(([key, pinsList])=>{
|
|
27992
|
+
element.addEventListener(key, (_event)=>{
|
|
27993
|
+
const event = _event;
|
|
27994
|
+
executePinsList(pinsList, _extends({}, context, {
|
|
27995
|
+
event: event.detail
|
|
27996
|
+
}));
|
|
27997
|
+
});
|
|
27998
|
+
});
|
|
27999
|
+
const pinsList = settings.pins || [];
|
|
28000
|
+
for(let i = 0; i < pinsList.length; i++){
|
|
28001
|
+
const item = pinsList[i];
|
|
28002
|
+
await generateElementFromPins(item, element, context, document, options);
|
|
28003
|
+
}
|
|
28004
|
+
parent == null ? void 0 : parent.appendChild(element);
|
|
28005
|
+
return element;
|
|
28006
|
+
};
|
|
27939
28007
|
const preparePinsSettings = async (settings, context)=>{
|
|
27940
28008
|
const localContext = _extends({}, context, {
|
|
27941
28009
|
variables: context.variables || {},
|
|
@@ -28007,36 +28075,25 @@ let WebService = class WebService {
|
|
|
28007
28075
|
}
|
|
28008
28076
|
return output;
|
|
28009
28077
|
}
|
|
28010
|
-
async pins2html(pins) {
|
|
28078
|
+
async pins2html(pins, context) {
|
|
28011
28079
|
const dom = new JSDOM();
|
|
28012
28080
|
const element = dom.window.document.createElement('section');
|
|
28013
|
-
await this.generateElementsFromPins(pins, element,
|
|
28081
|
+
await this.generateElementsFromPins(pins, element, {
|
|
28082
|
+
config: {
|
|
28083
|
+
VERSIONS: context.config.VERSIONS || {}
|
|
28084
|
+
},
|
|
28085
|
+
variables: context.variables || {},
|
|
28086
|
+
request: context.request || {}
|
|
28087
|
+
}, dom.window.document);
|
|
28014
28088
|
return element.innerHTML;
|
|
28015
28089
|
}
|
|
28016
|
-
async generateElementsFromPins(pinsList, parent,
|
|
28090
|
+
async generateElementsFromPins(pinsList, parent, context, document) {
|
|
28017
28091
|
for(let i = 0; i < pinsList.length; i++){
|
|
28018
28092
|
const item = pinsList[i];
|
|
28019
|
-
await
|
|
28020
|
-
|
|
28021
|
-
|
|
28022
|
-
|
|
28023
|
-
const element = dom.window.document.createElement(pinsSettings.element);
|
|
28024
|
-
element.setAttribute('data-ssr', '1');
|
|
28025
|
-
const settings = pinsSettings;
|
|
28026
|
-
Object.entries(settings.properties || {}).forEach(([key, value])=>{
|
|
28027
|
-
if (key === 'textContent') {
|
|
28028
|
-
element.textContent = value;
|
|
28029
|
-
} else if (key === 'innerHTML') {
|
|
28030
|
-
element.innerHTML = value;
|
|
28031
|
-
} else if (typeof value === 'string') {
|
|
28032
|
-
element.setAttribute(key, value);
|
|
28033
|
-
} else {
|
|
28034
|
-
element[key] = value;
|
|
28035
|
-
}
|
|
28036
|
-
});
|
|
28037
|
-
const pinsList = settings.pins || [];
|
|
28038
|
-
await this.generateElementsFromPins(pinsList, element, dom);
|
|
28039
|
-
parent.appendChild(element);
|
|
28093
|
+
await generateElementFromPins(item, parent, context, document, {
|
|
28094
|
+
import: false
|
|
28095
|
+
});
|
|
28096
|
+
}
|
|
28040
28097
|
}
|
|
28041
28098
|
async page(params, _pinsSettingsList, context) {
|
|
28042
28099
|
var _context_request_body;
|
|
@@ -28053,7 +28110,7 @@ let WebService = class WebService {
|
|
|
28053
28110
|
<!DOCTYPE html>
|
|
28054
28111
|
<html style="${styleHtml}">
|
|
28055
28112
|
<head>
|
|
28056
|
-
${head ? await this.pins2html(head) : `
|
|
28113
|
+
${head ? await this.pins2html(head, context) : `
|
|
28057
28114
|
<meta charset="UTF-8" />
|
|
28058
28115
|
<title>Digipair</title>
|
|
28059
28116
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
@@ -28092,7 +28149,7 @@ let WebService = class WebService {
|
|
|
28092
28149
|
await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
|
|
28093
28150
|
|
|
28094
28151
|
const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
|
|
28095
|
-
document.querySelectorAll('body > [data-
|
|
28152
|
+
document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
|
|
28096
28153
|
for (let i = 0; i < pinsList.length; i++) {
|
|
28097
28154
|
const item = pinsList[i];
|
|
28098
28155
|
await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
|
|
@@ -28103,7 +28160,7 @@ let WebService = class WebService {
|
|
|
28103
28160
|
}, 1);
|
|
28104
28161
|
</script>
|
|
28105
28162
|
|
|
28106
|
-
${ssr ? await this.pins2html(body) : ''}
|
|
28163
|
+
${ssr ? await this.pins2html(body, context) : ''}
|
|
28107
28164
|
</body>
|
|
28108
28165
|
</html>
|
|
28109
28166
|
`;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|