@digipair/skill-web 0.64.9 → 0.65.0-alpha3
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
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var engine = require('@digipair/engine');
|
|
6
6
|
var jsdom = require('jsdom');
|
|
7
|
+
var promises = require('fs/promises');
|
|
7
8
|
|
|
8
9
|
function _extends() {
|
|
9
10
|
_extends = Object.assign || function assign(target) {
|
|
@@ -90,14 +91,61 @@ let WebService = class WebService {
|
|
|
90
91
|
}
|
|
91
92
|
async page(params, _pinsSettingsList, context) {
|
|
92
93
|
var _context_request_body;
|
|
93
|
-
const { body, head, ssr = true, styleHtml = '', styleBody = '',
|
|
94
|
+
const { body, head, ssr = true, styleHtml = '', styleBody = '', factoryInitialize = [], browserInitialize = [], browserLoad = [] } = params;
|
|
94
95
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
|
95
96
|
const preparedData = {};
|
|
97
|
+
if (context.request.params[0] === '__digipair_www__') {
|
|
98
|
+
let result;
|
|
99
|
+
try {
|
|
100
|
+
var _infos_keywords, _infos_keywords1;
|
|
101
|
+
const fileUrl = context.protected.req.path.split('__digipair_www__/')[1];
|
|
102
|
+
if (!fileUrl) {
|
|
103
|
+
context.protected.res.status(404);
|
|
104
|
+
return {
|
|
105
|
+
status: 'not found'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const regex = /^(.*?[^@]+)@(.*?[^\/]+)\/(.*?.+)$/;
|
|
109
|
+
const match = fileUrl.match(regex);
|
|
110
|
+
if (!match) {
|
|
111
|
+
context.protected.res.status(404);
|
|
112
|
+
console.log('ici', match, fileUrl);
|
|
113
|
+
return {
|
|
114
|
+
status: 'not found'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const library = match[1];
|
|
118
|
+
if (!context.config.VERSIONS[library]) {
|
|
119
|
+
context.protected.res.status(404);
|
|
120
|
+
return {
|
|
121
|
+
status: 'not found'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const infos = require(`${library}/package.json`);
|
|
125
|
+
if (((_infos_keywords = infos.keywords) == null ? void 0 : _infos_keywords.indexOf('digipair')) === -1 || ((_infos_keywords1 = infos.keywords) == null ? void 0 : _infos_keywords1.indexOf('web')) === -1) {
|
|
126
|
+
context.protected.res.status(404);
|
|
127
|
+
return {
|
|
128
|
+
status: 'not found'
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const path = match[3];
|
|
132
|
+
let filePath = require.resolve(`${library}/${path}`);
|
|
133
|
+
result = await promises.readFile(filePath, 'utf8');
|
|
134
|
+
} catch (error) {
|
|
135
|
+
context.protected.res.status(404);
|
|
136
|
+
result = {
|
|
137
|
+
status: 'not found'
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
96
142
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
97
143
|
const param = context.request.body.params.path.split('[')[0];
|
|
98
144
|
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, params[param]);
|
|
99
145
|
return JSON.stringify(await engine.executePinsList(pinsSettingsList, this.mergeConttext(context.request.body.context, context)));
|
|
100
146
|
}
|
|
147
|
+
const path = context.protected.req.path.replace(/\/$/g, '');
|
|
148
|
+
const baseUrl = context.protected.req.protocol + '//' + context.protected.req.hostname + (context.request.params.length <= 0 || context.request.params[0] === '' ? path : path.substring(0, path.length - context.request.params.join('/').length - 1)) + '/__digipair_www__';
|
|
101
149
|
await engine.executePinsList(factoryInitialize, context);
|
|
102
150
|
const html = `
|
|
103
151
|
<!DOCTYPE html>
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
2
3
|
|
|
3
4
|
function _extends() {
|
|
4
5
|
_extends = Object.assign || function assign(target) {
|
|
@@ -23901,14 +23902,14 @@ function indent(str, spaces) {
|
|
|
23901
23902
|
var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
|
|
23902
23903
|
// match is required
|
|
23903
23904
|
if (!match) {
|
|
23904
|
-
return tokens = tokens1,
|
|
23905
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
|
|
23905
23906
|
v: nextMatch1
|
|
23906
23907
|
};
|
|
23907
23908
|
}
|
|
23908
23909
|
var token = match.token, offset = match.offset;
|
|
23909
23910
|
i1 += offset;
|
|
23910
23911
|
if (token === " ") {
|
|
23911
|
-
return tokens = tokens1,
|
|
23912
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23912
23913
|
}
|
|
23913
23914
|
tokens1 = _to_consumable_array$1(tokens1).concat([
|
|
23914
23915
|
token
|
|
@@ -23927,7 +23928,7 @@ function indent(str, spaces) {
|
|
|
23927
23928
|
if (contextKeys.some(function(el) {
|
|
23928
23929
|
return el.startsWith(name);
|
|
23929
23930
|
})) {
|
|
23930
|
-
return tokens = tokens1,
|
|
23931
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23931
23932
|
}
|
|
23932
23933
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23933
23934
|
return el === name;
|
|
@@ -23946,9 +23947,9 @@ function indent(str, spaces) {
|
|
|
23946
23947
|
if (dateTimeIdentifiers.some(function(el) {
|
|
23947
23948
|
return el.startsWith(name);
|
|
23948
23949
|
})) {
|
|
23949
|
-
return tokens = tokens1,
|
|
23950
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
|
|
23950
23951
|
}
|
|
23951
|
-
return tokens = tokens1,
|
|
23952
|
+
return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
|
|
23952
23953
|
v: nextMatch1
|
|
23953
23954
|
};
|
|
23954
23955
|
};
|
|
@@ -28126,14 +28127,61 @@ let WebService = class WebService {
|
|
|
28126
28127
|
}
|
|
28127
28128
|
async page(params, _pinsSettingsList, context) {
|
|
28128
28129
|
var _context_request_body;
|
|
28129
|
-
const { body, head, ssr = true, styleHtml = '', styleBody = '',
|
|
28130
|
+
const { body, head, ssr = true, styleHtml = '', styleBody = '', factoryInitialize = [], browserInitialize = [], browserLoad = [] } = params;
|
|
28130
28131
|
const engineVersion = context.config.VERSIONS['@digipair/engine'] || 'latest';
|
|
28131
28132
|
const preparedData = {};
|
|
28133
|
+
if (context.request.params[0] === '__digipair_www__') {
|
|
28134
|
+
let result;
|
|
28135
|
+
try {
|
|
28136
|
+
var _infos_keywords, _infos_keywords1;
|
|
28137
|
+
const fileUrl = context.protected.req.path.split('__digipair_www__/')[1];
|
|
28138
|
+
if (!fileUrl) {
|
|
28139
|
+
context.protected.res.status(404);
|
|
28140
|
+
return {
|
|
28141
|
+
status: 'not found'
|
|
28142
|
+
};
|
|
28143
|
+
}
|
|
28144
|
+
const regex = /^(.*?[^@]+)@(.*?[^\/]+)\/(.*?.+)$/;
|
|
28145
|
+
const match = fileUrl.match(regex);
|
|
28146
|
+
if (!match) {
|
|
28147
|
+
context.protected.res.status(404);
|
|
28148
|
+
console.log('ici', match, fileUrl);
|
|
28149
|
+
return {
|
|
28150
|
+
status: 'not found'
|
|
28151
|
+
};
|
|
28152
|
+
}
|
|
28153
|
+
const library = match[1];
|
|
28154
|
+
if (!context.config.VERSIONS[library]) {
|
|
28155
|
+
context.protected.res.status(404);
|
|
28156
|
+
return {
|
|
28157
|
+
status: 'not found'
|
|
28158
|
+
};
|
|
28159
|
+
}
|
|
28160
|
+
const infos = require(`${library}/package.json`);
|
|
28161
|
+
if (((_infos_keywords = infos.keywords) == null ? void 0 : _infos_keywords.indexOf('digipair')) === -1 || ((_infos_keywords1 = infos.keywords) == null ? void 0 : _infos_keywords1.indexOf('web')) === -1) {
|
|
28162
|
+
context.protected.res.status(404);
|
|
28163
|
+
return {
|
|
28164
|
+
status: 'not found'
|
|
28165
|
+
};
|
|
28166
|
+
}
|
|
28167
|
+
const path = match[3];
|
|
28168
|
+
let filePath = require.resolve(`${library}/${path}`);
|
|
28169
|
+
result = await readFile(filePath, 'utf8');
|
|
28170
|
+
} catch (error) {
|
|
28171
|
+
context.protected.res.status(404);
|
|
28172
|
+
result = {
|
|
28173
|
+
status: 'not found'
|
|
28174
|
+
};
|
|
28175
|
+
}
|
|
28176
|
+
return result;
|
|
28177
|
+
}
|
|
28132
28178
|
if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
|
|
28133
28179
|
const param = context.request.body.params.path.split('[')[0];
|
|
28134
28180
|
const pinsSettingsList = this.findFactoryPinsSettings(context.request.body.params.path, params[param]);
|
|
28135
28181
|
return JSON.stringify(await executePinsList(pinsSettingsList, this.mergeConttext(context.request.body.context, context)));
|
|
28136
28182
|
}
|
|
28183
|
+
const path = context.protected.req.path.replace(/\/$/g, '');
|
|
28184
|
+
const baseUrl = context.protected.req.protocol + '//' + context.protected.req.hostname + (context.request.params.length <= 0 || context.request.params[0] === '' ? path : path.substring(0, path.length - context.request.params.join('/').length - 1)) + '/__digipair_www__';
|
|
28137
28185
|
await executePinsList(factoryInitialize, context);
|
|
28138
28186
|
const html = `
|
|
28139
28187
|
<!DOCTYPE html>
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|