@digipair/skill-keycloak 0.48.1 → 0.48.3

Sign up to get free protection for your applications and to get access to all the features.
package/index.cjs.js CHANGED
@@ -5657,37 +5657,26 @@ let KeycloakService = class KeycloakService {
5657
5657
  }
5658
5658
  return output;
5659
5659
  }
5660
- async pins2html(pins) {
5660
+ async pins2html(pins, context) {
5661
5661
  const dom = new jsdom.JSDOM();
5662
5662
  const element = dom.window.document.createElement('section');
5663
- await this.generateElementsFromPins(pins, element, dom);
5663
+ await this.generateElementsFromPins(pins, element, {
5664
+ config: {
5665
+ VERSIONS: context.config.VERSIONS || {}
5666
+ },
5667
+ variables: context.variables || {},
5668
+ request: context.request || {}
5669
+ }, dom.window.document);
5664
5670
  return element.innerHTML;
5665
5671
  }
5666
- async generateElementsFromPins(pinsList, parent, dom) {
5672
+ async generateElementsFromPins(pinsList, parent, context, document) {
5667
5673
  for(let i = 0; i < pinsList.length; i++){
5668
5674
  const item = pinsList[i];
5669
- await this.generateElementFromPins(item, parent, dom);
5675
+ await engine.generateElementFromPins(item, parent, context, document, {
5676
+ import: false
5677
+ });
5670
5678
  }
5671
5679
  }
5672
- async generateElementFromPins(pinsSettings, parent, dom) {
5673
- const element = dom.window.document.createElement(pinsSettings.element);
5674
- element.setAttribute('data-ssr', '1');
5675
- const settings = pinsSettings;
5676
- Object.entries(settings.properties || {}).forEach(([key, value])=>{
5677
- if (key === 'textContent') {
5678
- element.textContent = value;
5679
- } else if (key === 'innerHTML') {
5680
- element.innerHTML = value;
5681
- } else if (typeof value === 'string') {
5682
- element.setAttribute(key, value);
5683
- } else {
5684
- element[key] = value;
5685
- }
5686
- });
5687
- const pinsList = settings.pins || [];
5688
- await this.generateElementsFromPins(pinsList, element, dom);
5689
- parent.appendChild(element);
5690
- }
5691
5680
  async page(params, _pinsSettingsList, context) {
5692
5681
  var _context_request_body;
5693
5682
  const { body, head, ssr = false, styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM, clientId = context.privates.KEYCLOAK_CLIENTID, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [], factoryUrl = context.privates.FACTORY_URL || process.env['FACTORY_URL'] || 'https://factory.digipair.ai' } = params;
@@ -5719,7 +5708,7 @@ let KeycloakService = class KeycloakService {
5719
5708
  <!DOCTYPE html>
5720
5709
  <html style="${styleHtml}">
5721
5710
  <head>
5722
- ${head ? await this.pins2html(head) : `
5711
+ ${head ? await this.pins2html(head, context) : `
5723
5712
  <meta charset="UTF-8" />
5724
5713
  <title>Digipair</title>
5725
5714
  <meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -5799,7 +5788,7 @@ let KeycloakService = class KeycloakService {
5799
5788
  await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
5800
5789
 
5801
5790
  const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
5802
- document.querySelectorAll('body > [data-ssr]').forEach((element) => element.remove()); // Remove SSR elements
5791
+ document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
5803
5792
  for (let i = 0; i < pinsList.length; i++) {
5804
5793
  const item = pinsList[i];
5805
5794
  await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
@@ -5810,7 +5799,7 @@ let KeycloakService = class KeycloakService {
5810
5799
  }, 1);
5811
5800
  </script>
5812
5801
 
5813
- ${ssr ? await this.pins2html(body) : ''}
5802
+ ${ssr ? await this.pins2html(body, context) : ''}
5814
5803
  </body>
5815
5804
  </html>
5816
5805
  `;
package/index.esm.js CHANGED
@@ -23905,14 +23905,14 @@ function indent(str, spaces) {
23905
23905
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23906
23906
  // match is required
23907
23907
  if (!match) {
23908
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
23908
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23909
23909
  v: nextMatch1
23910
23910
  };
23911
23911
  }
23912
23912
  var token = match.token, offset = match.offset;
23913
23913
  i1 += offset;
23914
23914
  if (token === " ") {
23915
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23915
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23916
23916
  }
23917
23917
  tokens1 = _to_consumable_array$3(tokens1).concat([
23918
23918
  token
@@ -23931,7 +23931,7 @@ function indent(str, spaces) {
23931
23931
  if (contextKeys.some(function(el) {
23932
23932
  return el.startsWith(name);
23933
23933
  })) {
23934
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23934
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23935
23935
  }
23936
23936
  if (dateTimeIdentifiers.some(function(el) {
23937
23937
  return el === name;
@@ -23950,9 +23950,9 @@ function indent(str, spaces) {
23950
23950
  if (dateTimeIdentifiers.some(function(el) {
23951
23951
  return el.startsWith(name);
23952
23952
  })) {
23953
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23953
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23954
23954
  }
23955
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
23955
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23956
23956
  v: nextMatch1
23957
23957
  };
23958
23958
  };
@@ -27940,6 +27940,74 @@ const executePinsList = async (pinsSettingsList, context)=>{
27940
27940
  }
27941
27941
  return previous;
27942
27942
  };
27943
+ const generateElementFromPins = async (pinsSettings, parent, context, document = typeof window !== 'undefined' ? window.document : global.document, options = {
27944
+ import: true
27945
+ })=>{
27946
+ var _settings_conditions, _settings_conditions1;
27947
+ let settings = await preparePinsSettings(pinsSettings, context);
27948
+ const alias = _config.ALIAS.find((alias)=>settings.library.split(':')[0] === alias.name);
27949
+ if (alias) {
27950
+ settings = await preparePinsSettings(_extends({}, settings, alias), {
27951
+ settings
27952
+ });
27953
+ }
27954
+ if ((_settings_conditions = settings.conditions) == null ? void 0 : _settings_conditions.each) {
27955
+ for(let index = 0; index < settings.conditions.each.length; index++){
27956
+ const item = settings.conditions.each[index];
27957
+ await generateElementFromPins(_extends({}, pinsSettings, {
27958
+ conditions: _extends({}, pinsSettings.conditions, {
27959
+ each: undefined
27960
+ })
27961
+ }), parent, _extends({}, context, {
27962
+ item,
27963
+ index,
27964
+ parent: {
27965
+ item: context.item,
27966
+ index: context.index,
27967
+ parent: context.parent
27968
+ }
27969
+ }), document, options);
27970
+ }
27971
+ return;
27972
+ }
27973
+ if (typeof ((_settings_conditions1 = settings.conditions) == null ? void 0 : _settings_conditions1.if) !== 'undefined' && !settings.conditions.if) {
27974
+ return;
27975
+ }
27976
+ const element = document.createElement(pinsSettings.element);
27977
+ element.setAttribute('data-digipair-pins', '');
27978
+ const library = pinsSettings.library;
27979
+ if (options.import && library !== 'web' && !_config.LIBRARIES[library]) {
27980
+ const config = context.config || {};
27981
+ const version = (config.VERSIONS || {})[library] || 'latest';
27982
+ import(isRemoteVersion.test(version) ? `${version}` : `${_config.BASE_URL}/${library}@${version}/index.esm.js`);
27983
+ }
27984
+ Object.entries(settings.properties || {}).forEach(([key, value])=>{
27985
+ if (key === 'textContent') {
27986
+ element.textContent = value;
27987
+ } else if (key === 'innerHTML') {
27988
+ element.innerHTML = value;
27989
+ } else if (typeof value === 'string') {
27990
+ element.setAttribute(key, value);
27991
+ } else {
27992
+ element[key] = value;
27993
+ }
27994
+ });
27995
+ Object.entries(settings.events || {}).forEach(([key, pinsList])=>{
27996
+ element.addEventListener(key, (_event)=>{
27997
+ const event = _event;
27998
+ executePinsList(pinsList, _extends({}, context, {
27999
+ event: event.detail
28000
+ }));
28001
+ });
28002
+ });
28003
+ const pinsList = settings.pins || [];
28004
+ for(let i = 0; i < pinsList.length; i++){
28005
+ const item = pinsList[i];
28006
+ await generateElementFromPins(item, element, context, document, options);
28007
+ }
28008
+ parent == null ? void 0 : parent.appendChild(element);
28009
+ return element;
28010
+ };
27943
28011
  const preparePinsSettings = async (settings, context)=>{
27944
28012
  const localContext = _extends({}, context, {
27945
28013
  variables: context.variables || {},
@@ -33589,36 +33657,25 @@ let KeycloakService = class KeycloakService {
33589
33657
  }
33590
33658
  return output;
33591
33659
  }
33592
- async pins2html(pins) {
33660
+ async pins2html(pins, context) {
33593
33661
  const dom = new JSDOM();
33594
33662
  const element = dom.window.document.createElement('section');
33595
- await this.generateElementsFromPins(pins, element, dom);
33663
+ await this.generateElementsFromPins(pins, element, {
33664
+ config: {
33665
+ VERSIONS: context.config.VERSIONS || {}
33666
+ },
33667
+ variables: context.variables || {},
33668
+ request: context.request || {}
33669
+ }, dom.window.document);
33596
33670
  return element.innerHTML;
33597
33671
  }
33598
- async generateElementsFromPins(pinsList, parent, dom) {
33672
+ async generateElementsFromPins(pinsList, parent, context, document) {
33599
33673
  for(let i = 0; i < pinsList.length; i++){
33600
33674
  const item = pinsList[i];
33601
- await this.generateElementFromPins(item, parent, dom);
33602
- }
33603
- }
33604
- async generateElementFromPins(pinsSettings, parent, dom) {
33605
- const element = dom.window.document.createElement(pinsSettings.element);
33606
- element.setAttribute('data-ssr', '1');
33607
- const settings = pinsSettings;
33608
- Object.entries(settings.properties || {}).forEach(([key, value])=>{
33609
- if (key === 'textContent') {
33610
- element.textContent = value;
33611
- } else if (key === 'innerHTML') {
33612
- element.innerHTML = value;
33613
- } else if (typeof value === 'string') {
33614
- element.setAttribute(key, value);
33615
- } else {
33616
- element[key] = value;
33617
- }
33618
- });
33619
- const pinsList = settings.pins || [];
33620
- await this.generateElementsFromPins(pinsList, element, dom);
33621
- parent.appendChild(element);
33675
+ await generateElementFromPins(item, parent, context, document, {
33676
+ import: false
33677
+ });
33678
+ }
33622
33679
  }
33623
33680
  async page(params, _pinsSettingsList, context) {
33624
33681
  var _context_request_body;
@@ -33651,7 +33708,7 @@ let KeycloakService = class KeycloakService {
33651
33708
  <!DOCTYPE html>
33652
33709
  <html style="${styleHtml}">
33653
33710
  <head>
33654
- ${head ? await this.pins2html(head) : `
33711
+ ${head ? await this.pins2html(head, context) : `
33655
33712
  <meta charset="UTF-8" />
33656
33713
  <title>Digipair</title>
33657
33714
  <meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -33731,7 +33788,7 @@ let KeycloakService = class KeycloakService {
33731
33788
  await executePinsList(${JSON.stringify(this.prepareBrowserPinsSettings('browserInitialize', browserInitialize))}, context);
33732
33789
 
33733
33790
  const pinsList = ${JSON.stringify(this.prepareBrowserPinsSettings('body', body))};
33734
- document.querySelectorAll('body > [data-ssr]').forEach((element) => element.remove()); // Remove SSR elements
33791
+ document.querySelectorAll('body > [data-digipair-pins]').forEach((element) => element.remove()); // Remove SSR elements
33735
33792
  for (let i = 0; i < pinsList.length; i++) {
33736
33793
  const item = pinsList[i];
33737
33794
  await generateElementFromPins(item, document.body, { ...context, data: ${JSON.stringify(preparedData)} });
@@ -33742,7 +33799,7 @@ let KeycloakService = class KeycloakService {
33742
33799
  }, 1);
33743
33800
  </script>
33744
33801
 
33745
- ${ssr ? await this.pins2html(body) : ''}
33802
+ ${ssr ? await this.pins2html(body, context) : ''}
33746
33803
  </body>
33747
33804
  </html>
33748
33805
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-keycloak",
3
- "version": "0.48.1",
3
+ "version": "0.48.3",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
File without changes