@sitecore-feaas/clientside 0.1.15 → 0.1.17
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 +5 -5
- package/build/basic.js +10 -0
- package/build/basic.js.map +1 -0
- package/build/cloud.js +22 -0
- package/build/cloud.js.map +1 -0
- package/build/components/FEAASBase.js +229 -0
- package/build/components/FEAASBase.js.map +1 -0
- package/build/components/FEAASComponent.js +84 -0
- package/build/components/FEAASComponent.js.map +1 -0
- package/build/components/FEAASLoader.js +100 -0
- package/build/components/FEAASLoader.js.map +1 -0
- package/build/components/FEAASStylesheet.js +31 -0
- package/build/components/FEAASStylesheet.js.map +1 -0
- package/build/dom.js +301 -0
- package/build/dom.js.map +1 -0
- package/build/fetch.js +56 -0
- package/build/fetch.js.map +1 -0
- package/build/ui/FEAASContext.js +68 -0
- package/build/ui/FEAASContext.js.map +1 -0
- package/build/ui/FEAASEditor.js +180 -0
- package/build/ui/FEAASEditor.js.map +1 -0
- package/build/ui/FEAASPicker.js +81 -0
- package/build/ui/FEAASPicker.js.map +1 -0
- package/build/ui/index.js +5 -0
- package/build/ui/index.js.map +1 -0
- package/dist/browser/basic.esm.js +68 -0
- package/dist/browser/basic.esm.js.map +1 -0
- package/dist/browser/basic.js +5 -4
- package/dist/browser/basic.js.map +1 -0
- package/dist/browser/index.esm.js +73 -0
- package/dist/browser/index.esm.js.map +1 -0
- package/dist/browser/index.js +8 -7
- package/dist/browser/index.js.map +1 -0
- package/dist/node/basic.esm.js +66 -0
- package/dist/node/basic.esm.js.map +1 -0
- package/dist/node/basic.js +4 -1458
- package/dist/node/basic.js.map +1 -0
- package/dist/node/index.esm.js +71 -0
- package/dist/node/index.esm.js.map +1 -0
- package/dist/node/index.js +7 -1858
- package/dist/node/index.js.map +1 -0
- package/package.json +25 -36
- package/scripts/build.js +77 -0
- package/src/basic.ts +10 -1
- package/src/components/FEAASBase.tsx +4 -2
- package/src/components/FEAASComponent.ts +7 -2
- package/src/components/FEAASLoader.ts +2 -0
- package/src/components/FEAASStylesheet.ts +2 -1
- package/src/dom.ts +9 -2
- package/src/{components → ui}/FEAASContext.tsx +3 -5
- package/src/{components → ui}/FEAASEditor.tsx +4 -4
- package/src/{components → ui}/FEAASPicker.tsx +3 -4
- package/src/ui/index.ts +4 -0
- package/src/ui/tsconfig.json +22 -0
- package/test/render.ts +35 -1
- package/test/tsconfig.json +10 -0
- package/tsconfig.json +3 -3
- package/tsconfig.test.json +0 -0
- package/types/basic.d.ts +8 -1
- package/types/basic.d.ts.map +1 -0
- package/types/cloud.d.ts +1 -0
- package/types/cloud.d.ts.map +1 -0
- package/types/components/FEAASBase.d.ts +7 -1
- package/types/components/FEAASBase.d.ts.map +1 -0
- package/types/components/FEAASComponent.d.ts +7 -1
- package/types/components/FEAASComponent.d.ts.map +1 -0
- package/types/components/FEAASLoader.d.ts +2 -1
- package/types/components/FEAASLoader.d.ts.map +1 -0
- package/types/components/FEAASStylesheet.d.ts +7 -3
- package/types/components/FEAASStylesheet.d.ts.map +1 -0
- package/types/dom.d.ts +1 -0
- package/types/dom.d.ts.map +1 -0
- package/types/fetch.d.ts +1 -0
- package/types/fetch.d.ts.map +1 -0
- package/types/tsbuildinfo +1 -1
- package/types/tsbuildinfo_ui +1 -0
- package/types/{components → ui}/FEAASContext.d.ts +3 -2
- package/types/ui/FEAASContext.d.ts.map +1 -0
- package/types/{components → ui}/FEAASEditor.d.ts +3 -2
- package/types/ui/FEAASEditor.d.ts.map +1 -0
- package/types/{components → ui}/FEAASPicker.d.ts +3 -2
- package/types/ui/FEAASPicker.d.ts.map +1 -0
- package/types/ui/index.d.ts +5 -0
- package/types/ui/index.d.ts.map +1 -0
- package/dist/browser/basic.cjs +0 -67
- package/dist/browser/index.cjs +0 -72
- package/dist/node/basic.cjs +0 -1539
- package/dist/node/index.cjs +0 -1941
- package/src/components/index.tsx +0 -7
- package/src/index.ts +0 -4
- package/test/components.js +0 -11
- package/test/render.js +0 -688
- package/types/components/index.d.ts +0 -7
- package/types/index.d.ts +0 -4
package/dist/node/basic.js
CHANGED
|
@@ -1,1318 +1,4 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// ../node_modules/jsonpath-plus/dist/index-browser-esm.js
|
|
42
|
-
function _typeof(obj) {
|
|
43
|
-
"@babel/helpers - typeof";
|
|
44
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
45
|
-
_typeof = function(obj2) {
|
|
46
|
-
return typeof obj2;
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
_typeof = function(obj2) {
|
|
50
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return _typeof(obj);
|
|
54
|
-
}
|
|
55
|
-
function _classCallCheck(instance, Constructor) {
|
|
56
|
-
if (!(instance instanceof Constructor)) {
|
|
57
|
-
throw new TypeError("Cannot call a class as a function");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function _inherits(subClass, superClass) {
|
|
61
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
62
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
63
|
-
}
|
|
64
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
65
|
-
constructor: {
|
|
66
|
-
value: subClass,
|
|
67
|
-
writable: true,
|
|
68
|
-
configurable: true
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
if (superClass)
|
|
72
|
-
_setPrototypeOf(subClass, superClass);
|
|
73
|
-
}
|
|
74
|
-
function _getPrototypeOf(o) {
|
|
75
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
|
76
|
-
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
77
|
-
};
|
|
78
|
-
return _getPrototypeOf(o);
|
|
79
|
-
}
|
|
80
|
-
function _setPrototypeOf(o, p) {
|
|
81
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
82
|
-
o2.__proto__ = p2;
|
|
83
|
-
return o2;
|
|
84
|
-
};
|
|
85
|
-
return _setPrototypeOf(o, p);
|
|
86
|
-
}
|
|
87
|
-
function _isNativeReflectConstruct() {
|
|
88
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
89
|
-
return false;
|
|
90
|
-
if (Reflect.construct.sham)
|
|
91
|
-
return false;
|
|
92
|
-
if (typeof Proxy === "function")
|
|
93
|
-
return true;
|
|
94
|
-
try {
|
|
95
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
96
|
-
}));
|
|
97
|
-
return true;
|
|
98
|
-
} catch (e) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function _construct(Parent, args, Class) {
|
|
103
|
-
if (_isNativeReflectConstruct()) {
|
|
104
|
-
_construct = Reflect.construct;
|
|
105
|
-
} else {
|
|
106
|
-
_construct = function _construct2(Parent2, args2, Class2) {
|
|
107
|
-
var a = [null];
|
|
108
|
-
a.push.apply(a, args2);
|
|
109
|
-
var Constructor = Function.bind.apply(Parent2, a);
|
|
110
|
-
var instance = new Constructor();
|
|
111
|
-
if (Class2)
|
|
112
|
-
_setPrototypeOf(instance, Class2.prototype);
|
|
113
|
-
return instance;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return _construct.apply(null, arguments);
|
|
117
|
-
}
|
|
118
|
-
function _isNativeFunction(fn) {
|
|
119
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
120
|
-
}
|
|
121
|
-
function _wrapNativeSuper(Class) {
|
|
122
|
-
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
123
|
-
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
124
|
-
if (Class2 === null || !_isNativeFunction(Class2))
|
|
125
|
-
return Class2;
|
|
126
|
-
if (typeof Class2 !== "function") {
|
|
127
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
128
|
-
}
|
|
129
|
-
if (typeof _cache !== "undefined") {
|
|
130
|
-
if (_cache.has(Class2))
|
|
131
|
-
return _cache.get(Class2);
|
|
132
|
-
_cache.set(Class2, Wrapper);
|
|
133
|
-
}
|
|
134
|
-
function Wrapper() {
|
|
135
|
-
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
136
|
-
}
|
|
137
|
-
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
138
|
-
constructor: {
|
|
139
|
-
value: Wrapper,
|
|
140
|
-
enumerable: false,
|
|
141
|
-
writable: true,
|
|
142
|
-
configurable: true
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return _setPrototypeOf(Wrapper, Class2);
|
|
146
|
-
};
|
|
147
|
-
return _wrapNativeSuper(Class);
|
|
148
|
-
}
|
|
149
|
-
function _assertThisInitialized(self) {
|
|
150
|
-
if (self === void 0) {
|
|
151
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
152
|
-
}
|
|
153
|
-
return self;
|
|
154
|
-
}
|
|
155
|
-
function _possibleConstructorReturn(self, call) {
|
|
156
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
157
|
-
return call;
|
|
158
|
-
}
|
|
159
|
-
return _assertThisInitialized(self);
|
|
160
|
-
}
|
|
161
|
-
function _createSuper(Derived) {
|
|
162
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
163
|
-
return function _createSuperInternal() {
|
|
164
|
-
var Super = _getPrototypeOf(Derived), result;
|
|
165
|
-
if (hasNativeReflectConstruct) {
|
|
166
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
167
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
168
|
-
} else {
|
|
169
|
-
result = Super.apply(this, arguments);
|
|
170
|
-
}
|
|
171
|
-
return _possibleConstructorReturn(this, result);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function _toConsumableArray(arr) {
|
|
175
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
176
|
-
}
|
|
177
|
-
function _arrayWithoutHoles(arr) {
|
|
178
|
-
if (Array.isArray(arr))
|
|
179
|
-
return _arrayLikeToArray(arr);
|
|
180
|
-
}
|
|
181
|
-
function _iterableToArray(iter) {
|
|
182
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
183
|
-
return Array.from(iter);
|
|
184
|
-
}
|
|
185
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
186
|
-
if (!o)
|
|
187
|
-
return;
|
|
188
|
-
if (typeof o === "string")
|
|
189
|
-
return _arrayLikeToArray(o, minLen);
|
|
190
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
191
|
-
if (n === "Object" && o.constructor)
|
|
192
|
-
n = o.constructor.name;
|
|
193
|
-
if (n === "Map" || n === "Set")
|
|
194
|
-
return Array.from(o);
|
|
195
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
196
|
-
return _arrayLikeToArray(o, minLen);
|
|
197
|
-
}
|
|
198
|
-
function _arrayLikeToArray(arr, len) {
|
|
199
|
-
if (len == null || len > arr.length)
|
|
200
|
-
len = arr.length;
|
|
201
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
202
|
-
arr2[i] = arr[i];
|
|
203
|
-
return arr2;
|
|
204
|
-
}
|
|
205
|
-
function _nonIterableSpread() {
|
|
206
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
207
|
-
}
|
|
208
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
209
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
210
|
-
if (!it) {
|
|
211
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
212
|
-
if (it)
|
|
213
|
-
o = it;
|
|
214
|
-
var i = 0;
|
|
215
|
-
var F = function() {
|
|
216
|
-
};
|
|
217
|
-
return {
|
|
218
|
-
s: F,
|
|
219
|
-
n: function() {
|
|
220
|
-
if (i >= o.length)
|
|
221
|
-
return {
|
|
222
|
-
done: true
|
|
223
|
-
};
|
|
224
|
-
return {
|
|
225
|
-
done: false,
|
|
226
|
-
value: o[i++]
|
|
227
|
-
};
|
|
228
|
-
},
|
|
229
|
-
e: function(e) {
|
|
230
|
-
throw e;
|
|
231
|
-
},
|
|
232
|
-
f: F
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
236
|
-
}
|
|
237
|
-
var normalCompletion = true, didErr = false, err;
|
|
238
|
-
return {
|
|
239
|
-
s: function() {
|
|
240
|
-
it = it.call(o);
|
|
241
|
-
},
|
|
242
|
-
n: function() {
|
|
243
|
-
var step = it.next();
|
|
244
|
-
normalCompletion = step.done;
|
|
245
|
-
return step;
|
|
246
|
-
},
|
|
247
|
-
e: function(e) {
|
|
248
|
-
didErr = true;
|
|
249
|
-
err = e;
|
|
250
|
-
},
|
|
251
|
-
f: function() {
|
|
252
|
-
try {
|
|
253
|
-
if (!normalCompletion && it.return != null)
|
|
254
|
-
it.return();
|
|
255
|
-
} finally {
|
|
256
|
-
if (didErr)
|
|
257
|
-
throw err;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
var hasOwnProp = Object.prototype.hasOwnProperty;
|
|
263
|
-
function push(arr, item) {
|
|
264
|
-
arr = arr.slice();
|
|
265
|
-
arr.push(item);
|
|
266
|
-
return arr;
|
|
267
|
-
}
|
|
268
|
-
function unshift(item, arr) {
|
|
269
|
-
arr = arr.slice();
|
|
270
|
-
arr.unshift(item);
|
|
271
|
-
return arr;
|
|
272
|
-
}
|
|
273
|
-
var NewError = /* @__PURE__ */ function(_Error) {
|
|
274
|
-
_inherits(NewError2, _Error);
|
|
275
|
-
var _super = _createSuper(NewError2);
|
|
276
|
-
function NewError2(value) {
|
|
277
|
-
var _this;
|
|
278
|
-
_classCallCheck(this, NewError2);
|
|
279
|
-
_this = _super.call(this, 'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');
|
|
280
|
-
_this.avoidNew = true;
|
|
281
|
-
_this.value = value;
|
|
282
|
-
_this.name = "NewError";
|
|
283
|
-
return _this;
|
|
284
|
-
}
|
|
285
|
-
return NewError2;
|
|
286
|
-
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
287
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
288
|
-
if (!(this instanceof JSONPath)) {
|
|
289
|
-
try {
|
|
290
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
291
|
-
} catch (e) {
|
|
292
|
-
if (!e.avoidNew) {
|
|
293
|
-
throw e;
|
|
294
|
-
}
|
|
295
|
-
return e.value;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (typeof opts === "string") {
|
|
299
|
-
otherTypeCallback = callback;
|
|
300
|
-
callback = obj;
|
|
301
|
-
obj = expr;
|
|
302
|
-
expr = opts;
|
|
303
|
-
opts = null;
|
|
304
|
-
}
|
|
305
|
-
var optObj = opts && _typeof(opts) === "object";
|
|
306
|
-
opts = opts || {};
|
|
307
|
-
this.json = opts.json || obj;
|
|
308
|
-
this.path = opts.path || expr;
|
|
309
|
-
this.resultType = opts.resultType || "value";
|
|
310
|
-
this.flatten = opts.flatten || false;
|
|
311
|
-
this.wrap = hasOwnProp.call(opts, "wrap") ? opts.wrap : true;
|
|
312
|
-
this.sandbox = opts.sandbox || {};
|
|
313
|
-
this.preventEval = opts.preventEval || false;
|
|
314
|
-
this.parent = opts.parent || null;
|
|
315
|
-
this.parentProperty = opts.parentProperty || null;
|
|
316
|
-
this.callback = opts.callback || callback || null;
|
|
317
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
318
|
-
throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
|
|
319
|
-
};
|
|
320
|
-
if (opts.autostart !== false) {
|
|
321
|
-
var args = {
|
|
322
|
-
path: optObj ? opts.path : expr
|
|
323
|
-
};
|
|
324
|
-
if (!optObj) {
|
|
325
|
-
args.json = obj;
|
|
326
|
-
} else if ("json" in opts) {
|
|
327
|
-
args.json = opts.json;
|
|
328
|
-
}
|
|
329
|
-
var ret = this.evaluate(args);
|
|
330
|
-
if (!ret || _typeof(ret) !== "object") {
|
|
331
|
-
throw new NewError(ret);
|
|
332
|
-
}
|
|
333
|
-
return ret;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
337
|
-
var _this2 = this;
|
|
338
|
-
var currParent = this.parent, currParentProperty = this.parentProperty;
|
|
339
|
-
var flatten = this.flatten, wrap = this.wrap;
|
|
340
|
-
this.currResultType = this.resultType;
|
|
341
|
-
this.currPreventEval = this.preventEval;
|
|
342
|
-
this.currSandbox = this.sandbox;
|
|
343
|
-
callback = callback || this.callback;
|
|
344
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
345
|
-
json = json || this.json;
|
|
346
|
-
expr = expr || this.path;
|
|
347
|
-
if (expr && _typeof(expr) === "object" && !Array.isArray(expr)) {
|
|
348
|
-
if (!expr.path && expr.path !== "") {
|
|
349
|
-
throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
|
|
350
|
-
}
|
|
351
|
-
if (!hasOwnProp.call(expr, "json")) {
|
|
352
|
-
throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
|
|
353
|
-
}
|
|
354
|
-
var _expr = expr;
|
|
355
|
-
json = _expr.json;
|
|
356
|
-
flatten = hasOwnProp.call(expr, "flatten") ? expr.flatten : flatten;
|
|
357
|
-
this.currResultType = hasOwnProp.call(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
358
|
-
this.currSandbox = hasOwnProp.call(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
359
|
-
wrap = hasOwnProp.call(expr, "wrap") ? expr.wrap : wrap;
|
|
360
|
-
this.currPreventEval = hasOwnProp.call(expr, "preventEval") ? expr.preventEval : this.currPreventEval;
|
|
361
|
-
callback = hasOwnProp.call(expr, "callback") ? expr.callback : callback;
|
|
362
|
-
this.currOtherTypeCallback = hasOwnProp.call(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
363
|
-
currParent = hasOwnProp.call(expr, "parent") ? expr.parent : currParent;
|
|
364
|
-
currParentProperty = hasOwnProp.call(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
365
|
-
expr = expr.path;
|
|
366
|
-
}
|
|
367
|
-
currParent = currParent || null;
|
|
368
|
-
currParentProperty = currParentProperty || null;
|
|
369
|
-
if (Array.isArray(expr)) {
|
|
370
|
-
expr = JSONPath.toPathString(expr);
|
|
371
|
-
}
|
|
372
|
-
if (!expr && expr !== "" || !json) {
|
|
373
|
-
return void 0;
|
|
374
|
-
}
|
|
375
|
-
var exprList = JSONPath.toPathArray(expr);
|
|
376
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
377
|
-
exprList.shift();
|
|
378
|
-
}
|
|
379
|
-
this._hasParentSelector = null;
|
|
380
|
-
var result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
381
|
-
return ea && !ea.isParentSelector;
|
|
382
|
-
});
|
|
383
|
-
if (!result.length) {
|
|
384
|
-
return wrap ? [] : void 0;
|
|
385
|
-
}
|
|
386
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
387
|
-
return this._getPreferredOutput(result[0]);
|
|
388
|
-
}
|
|
389
|
-
return result.reduce(function(rslt, ea) {
|
|
390
|
-
var valOrPath = _this2._getPreferredOutput(ea);
|
|
391
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
392
|
-
rslt = rslt.concat(valOrPath);
|
|
393
|
-
} else {
|
|
394
|
-
rslt.push(valOrPath);
|
|
395
|
-
}
|
|
396
|
-
return rslt;
|
|
397
|
-
}, []);
|
|
398
|
-
};
|
|
399
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
400
|
-
var resultType = this.currResultType;
|
|
401
|
-
switch (resultType) {
|
|
402
|
-
case "all": {
|
|
403
|
-
var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
404
|
-
ea.pointer = JSONPath.toPointer(path);
|
|
405
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
406
|
-
return ea;
|
|
407
|
-
}
|
|
408
|
-
case "value":
|
|
409
|
-
case "parent":
|
|
410
|
-
case "parentProperty":
|
|
411
|
-
return ea[resultType];
|
|
412
|
-
case "path":
|
|
413
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
414
|
-
case "pointer":
|
|
415
|
-
return JSONPath.toPointer(ea.path);
|
|
416
|
-
default:
|
|
417
|
-
throw new TypeError("Unknown result type");
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
421
|
-
if (callback) {
|
|
422
|
-
var preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
423
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
424
|
-
callback(preferredOutput, type, fullRetObj);
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
428
|
-
var _this3 = this;
|
|
429
|
-
var retObj;
|
|
430
|
-
if (!expr.length) {
|
|
431
|
-
retObj = {
|
|
432
|
-
path,
|
|
433
|
-
value: val,
|
|
434
|
-
parent,
|
|
435
|
-
parentProperty: parentPropName,
|
|
436
|
-
hasArrExpr
|
|
437
|
-
};
|
|
438
|
-
this._handleCallback(retObj, callback, "value");
|
|
439
|
-
return retObj;
|
|
440
|
-
}
|
|
441
|
-
var loc = expr[0], x = expr.slice(1);
|
|
442
|
-
var ret = [];
|
|
443
|
-
function addRet(elems) {
|
|
444
|
-
if (Array.isArray(elems)) {
|
|
445
|
-
elems.forEach(function(t2) {
|
|
446
|
-
ret.push(t2);
|
|
447
|
-
});
|
|
448
|
-
} else {
|
|
449
|
-
ret.push(elems);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
if ((typeof loc !== "string" || literalPriority) && val && hasOwnProp.call(val, loc)) {
|
|
453
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
|
|
454
|
-
} else if (loc === "*") {
|
|
455
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
456
|
-
addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
|
|
457
|
-
});
|
|
458
|
-
} else if (loc === "..") {
|
|
459
|
-
addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
|
|
460
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
461
|
-
if (_typeof(v[m]) === "object") {
|
|
462
|
-
addRet(_this3._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
} else if (loc === "^") {
|
|
466
|
-
this._hasParentSelector = true;
|
|
467
|
-
return {
|
|
468
|
-
path: path.slice(0, -1),
|
|
469
|
-
expr: x,
|
|
470
|
-
isParentSelector: true
|
|
471
|
-
};
|
|
472
|
-
} else if (loc === "~") {
|
|
473
|
-
retObj = {
|
|
474
|
-
path: push(path, loc),
|
|
475
|
-
value: parentPropName,
|
|
476
|
-
parent,
|
|
477
|
-
parentProperty: null
|
|
478
|
-
};
|
|
479
|
-
this._handleCallback(retObj, callback, "property");
|
|
480
|
-
return retObj;
|
|
481
|
-
} else if (loc === "$") {
|
|
482
|
-
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
|
|
483
|
-
} else if (/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(loc)) {
|
|
484
|
-
addRet(this._slice(loc, x, val, path, parent, parentPropName, callback));
|
|
485
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
486
|
-
if (this.currPreventEval) {
|
|
487
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
488
|
-
}
|
|
489
|
-
this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
|
|
490
|
-
if (_this3._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
|
|
491
|
-
addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true));
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
} else if (loc[0] === "(") {
|
|
495
|
-
if (this.currPreventEval) {
|
|
496
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
497
|
-
}
|
|
498
|
-
addRet(this._trace(unshift(this._eval(loc, val, path[path.length - 1], path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
|
|
499
|
-
} else if (loc[0] === "@") {
|
|
500
|
-
var addType = false;
|
|
501
|
-
var valueType = loc.slice(1, -2);
|
|
502
|
-
switch (valueType) {
|
|
503
|
-
case "scalar":
|
|
504
|
-
if (!val || !["object", "function"].includes(_typeof(val))) {
|
|
505
|
-
addType = true;
|
|
506
|
-
}
|
|
507
|
-
break;
|
|
508
|
-
case "boolean":
|
|
509
|
-
case "string":
|
|
510
|
-
case "undefined":
|
|
511
|
-
case "function":
|
|
512
|
-
if (_typeof(val) === valueType) {
|
|
513
|
-
addType = true;
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
case "integer":
|
|
517
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
518
|
-
addType = true;
|
|
519
|
-
}
|
|
520
|
-
break;
|
|
521
|
-
case "number":
|
|
522
|
-
if (Number.isFinite(val)) {
|
|
523
|
-
addType = true;
|
|
524
|
-
}
|
|
525
|
-
break;
|
|
526
|
-
case "nonFinite":
|
|
527
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
528
|
-
addType = true;
|
|
529
|
-
}
|
|
530
|
-
break;
|
|
531
|
-
case "object":
|
|
532
|
-
if (val && _typeof(val) === valueType) {
|
|
533
|
-
addType = true;
|
|
534
|
-
}
|
|
535
|
-
break;
|
|
536
|
-
case "array":
|
|
537
|
-
if (Array.isArray(val)) {
|
|
538
|
-
addType = true;
|
|
539
|
-
}
|
|
540
|
-
break;
|
|
541
|
-
case "other":
|
|
542
|
-
addType = this.currOtherTypeCallback(val, path, parent, parentPropName);
|
|
543
|
-
break;
|
|
544
|
-
case "null":
|
|
545
|
-
if (val === null) {
|
|
546
|
-
addType = true;
|
|
547
|
-
}
|
|
548
|
-
break;
|
|
549
|
-
default:
|
|
550
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
551
|
-
}
|
|
552
|
-
if (addType) {
|
|
553
|
-
retObj = {
|
|
554
|
-
path,
|
|
555
|
-
value: val,
|
|
556
|
-
parent,
|
|
557
|
-
parentProperty: parentPropName
|
|
558
|
-
};
|
|
559
|
-
this._handleCallback(retObj, callback, "value");
|
|
560
|
-
return retObj;
|
|
561
|
-
}
|
|
562
|
-
} else if (loc[0] === "`" && val && hasOwnProp.call(val, loc.slice(1))) {
|
|
563
|
-
var locProp = loc.slice(1);
|
|
564
|
-
addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));
|
|
565
|
-
} else if (loc.includes(",")) {
|
|
566
|
-
var parts = loc.split(",");
|
|
567
|
-
var _iterator = _createForOfIteratorHelper(parts), _step;
|
|
568
|
-
try {
|
|
569
|
-
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
570
|
-
var part = _step.value;
|
|
571
|
-
addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));
|
|
572
|
-
}
|
|
573
|
-
} catch (err) {
|
|
574
|
-
_iterator.e(err);
|
|
575
|
-
} finally {
|
|
576
|
-
_iterator.f();
|
|
577
|
-
}
|
|
578
|
-
} else if (!literalPriority && val && hasOwnProp.call(val, loc)) {
|
|
579
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true));
|
|
580
|
-
}
|
|
581
|
-
if (this._hasParentSelector) {
|
|
582
|
-
for (var t = 0; t < ret.length; t++) {
|
|
583
|
-
var rett = ret[t];
|
|
584
|
-
if (rett && rett.isParentSelector) {
|
|
585
|
-
var tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
586
|
-
if (Array.isArray(tmp)) {
|
|
587
|
-
ret[t] = tmp[0];
|
|
588
|
-
var tl = tmp.length;
|
|
589
|
-
for (var tt = 1; tt < tl; tt++) {
|
|
590
|
-
t++;
|
|
591
|
-
ret.splice(t, 0, tmp[tt]);
|
|
592
|
-
}
|
|
593
|
-
} else {
|
|
594
|
-
ret[t] = tmp;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
return ret;
|
|
600
|
-
};
|
|
601
|
-
JSONPath.prototype._walk = function(loc, expr, val, path, parent, parentPropName, callback, f) {
|
|
602
|
-
if (Array.isArray(val)) {
|
|
603
|
-
var n = val.length;
|
|
604
|
-
for (var i = 0; i < n; i++) {
|
|
605
|
-
f(i, loc, expr, val, path, parent, parentPropName, callback);
|
|
606
|
-
}
|
|
607
|
-
} else if (val && _typeof(val) === "object") {
|
|
608
|
-
Object.keys(val).forEach(function(m) {
|
|
609
|
-
f(m, loc, expr, val, path, parent, parentPropName, callback);
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropName, callback) {
|
|
614
|
-
if (!Array.isArray(val)) {
|
|
615
|
-
return void 0;
|
|
616
|
-
}
|
|
617
|
-
var len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
618
|
-
var start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
619
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
620
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
621
|
-
var ret = [];
|
|
622
|
-
for (var i = start; i < end; i += step) {
|
|
623
|
-
var tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);
|
|
624
|
-
tmp.forEach(function(t) {
|
|
625
|
-
ret.push(t);
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return ret;
|
|
629
|
-
};
|
|
630
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path, parent, parentPropName) {
|
|
631
|
-
if (code.includes("@parentProperty")) {
|
|
632
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
633
|
-
code = code.replace(/@parentProperty/g, "_$_parentProperty");
|
|
634
|
-
}
|
|
635
|
-
if (code.includes("@parent")) {
|
|
636
|
-
this.currSandbox._$_parent = parent;
|
|
637
|
-
code = code.replace(/@parent/g, "_$_parent");
|
|
638
|
-
}
|
|
639
|
-
if (code.includes("@property")) {
|
|
640
|
-
this.currSandbox._$_property = _vname;
|
|
641
|
-
code = code.replace(/@property/g, "_$_property");
|
|
642
|
-
}
|
|
643
|
-
if (code.includes("@path")) {
|
|
644
|
-
this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
|
|
645
|
-
code = code.replace(/@path/g, "_$_path");
|
|
646
|
-
}
|
|
647
|
-
if (code.includes("@root")) {
|
|
648
|
-
this.currSandbox._$_root = this.json;
|
|
649
|
-
code = code.replace(/@root/g, "_$_root");
|
|
650
|
-
}
|
|
651
|
-
if (/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/.test(code)) {
|
|
652
|
-
this.currSandbox._$_v = _v;
|
|
653
|
-
code = code.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
|
|
654
|
-
}
|
|
655
|
-
try {
|
|
656
|
-
return this.vm.runInNewContext(code, this.currSandbox);
|
|
657
|
-
} catch (e) {
|
|
658
|
-
console.log(e);
|
|
659
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
JSONPath.cache = {};
|
|
663
|
-
JSONPath.toPathString = function(pathArr) {
|
|
664
|
-
var x = pathArr, n = x.length;
|
|
665
|
-
var p = "$";
|
|
666
|
-
for (var i = 1; i < n; i++) {
|
|
667
|
-
if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
|
|
668
|
-
p += /^[\*0-9]+$/.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return p;
|
|
672
|
-
};
|
|
673
|
-
JSONPath.toPointer = function(pointer) {
|
|
674
|
-
var x = pointer, n = x.length;
|
|
675
|
-
var p = "";
|
|
676
|
-
for (var i = 1; i < n; i++) {
|
|
677
|
-
if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
|
|
678
|
-
p += "/" + x[i].toString().replace(/~/g, "~0").replace(/\//g, "~1");
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return p;
|
|
682
|
-
};
|
|
683
|
-
JSONPath.toPathArray = function(expr) {
|
|
684
|
-
var cache = JSONPath.cache;
|
|
685
|
-
if (cache[expr]) {
|
|
686
|
-
return cache[expr].concat();
|
|
687
|
-
}
|
|
688
|
-
var subx = [];
|
|
689
|
-
var normalized = expr.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g, function($0, $1) {
|
|
690
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
691
|
-
}).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g, function($0, prop) {
|
|
692
|
-
return "['" + prop.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']";
|
|
693
|
-
}).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
|
|
694
|
-
return ";" + ups.split("").join(";") + ";";
|
|
695
|
-
}).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "");
|
|
696
|
-
var exprList = normalized.split(";").map(function(exp) {
|
|
697
|
-
var match = exp.match(/#([0-9]+)/);
|
|
698
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
699
|
-
});
|
|
700
|
-
cache[expr] = exprList;
|
|
701
|
-
return cache[expr].concat();
|
|
702
|
-
};
|
|
703
|
-
var moveToAnotherArray = function moveToAnotherArray2(source, target, conditionCb) {
|
|
704
|
-
var il = source.length;
|
|
705
|
-
for (var i = 0; i < il; i++) {
|
|
706
|
-
var item = source[i];
|
|
707
|
-
if (conditionCb(item)) {
|
|
708
|
-
target.push(source.splice(i--, 1)[0]);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
JSONPath.prototype.vm = {
|
|
713
|
-
runInNewContext: function runInNewContext(expr, context) {
|
|
714
|
-
var keys = Object.keys(context);
|
|
715
|
-
var funcs = [];
|
|
716
|
-
moveToAnotherArray(keys, funcs, function(key) {
|
|
717
|
-
return typeof context[key] === "function";
|
|
718
|
-
});
|
|
719
|
-
var values = keys.map(function(vr, i) {
|
|
720
|
-
return context[vr];
|
|
721
|
-
});
|
|
722
|
-
var funcString = funcs.reduce(function(s, func) {
|
|
723
|
-
var fString = context[func].toString();
|
|
724
|
-
if (!/function/.test(fString)) {
|
|
725
|
-
fString = "function " + fString;
|
|
726
|
-
}
|
|
727
|
-
return "var " + func + "=" + fString + ";" + s;
|
|
728
|
-
}, "");
|
|
729
|
-
expr = funcString + expr;
|
|
730
|
-
if (!/(["'])use strict\1/.test(expr) && !keys.includes("arguments")) {
|
|
731
|
-
expr = "var arguments = undefined;" + expr;
|
|
732
|
-
}
|
|
733
|
-
expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
|
|
734
|
-
var lastStatementEnd = expr.lastIndexOf(";");
|
|
735
|
-
var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
|
|
736
|
-
return _construct(Function, _toConsumableArray(keys).concat([code])).apply(void 0, _toConsumableArray(values));
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
|
|
740
|
-
// src/fetch.ts
|
|
741
|
-
function fetchAndRevalidate(url, options, validator, callback) {
|
|
742
|
-
return __async(this, null, function* () {
|
|
743
|
-
const date = new Date();
|
|
744
|
-
const initialResponse = yield fetch(url, options);
|
|
745
|
-
if (!initialResponse.ok)
|
|
746
|
-
throw new Error("Fetch failed");
|
|
747
|
-
const responseDate = new Date(initialResponse.headers.get("date"));
|
|
748
|
-
var response = initialResponse;
|
|
749
|
-
callback(initialResponse, "cached");
|
|
750
|
-
if (responseDate < date) {
|
|
751
|
-
const freshHeadResponse = yield fetch(url + "?" + Math.random(), __spreadProps(__spreadValues({}, options), {
|
|
752
|
-
method: "HEAD",
|
|
753
|
-
cache: "no-cache"
|
|
754
|
-
}));
|
|
755
|
-
if (freshHeadResponse.headers.get("last-modified") != initialResponse.headers.get("last-modified")) {
|
|
756
|
-
if (validator(freshHeadResponse) === false) {
|
|
757
|
-
throw new Error("Response is stale");
|
|
758
|
-
}
|
|
759
|
-
response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
|
|
760
|
-
cache: "reload"
|
|
761
|
-
}));
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
if (validator(response) === false) {
|
|
765
|
-
throw new Error("Response is not valid");
|
|
766
|
-
}
|
|
767
|
-
if (initialResponse !== response) {
|
|
768
|
-
callback(response, "valid");
|
|
769
|
-
}
|
|
770
|
-
return response;
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// src/cloud.ts
|
|
775
|
-
function getComponentURL({
|
|
776
|
-
cdn = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
777
|
-
hostname,
|
|
778
|
-
library,
|
|
779
|
-
component,
|
|
780
|
-
version,
|
|
781
|
-
revision = "published"
|
|
782
|
-
}) {
|
|
783
|
-
return `${cdn || hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
784
|
-
}
|
|
785
|
-
function getStylesheetURL({
|
|
786
|
-
cdn = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
787
|
-
hostname,
|
|
788
|
-
library,
|
|
789
|
-
revision = "published"
|
|
790
|
-
}) {
|
|
791
|
-
return `${cdn || hostname}/styles/${library}/${revision}.css`;
|
|
792
|
-
}
|
|
793
|
-
function fetchComponent(props, callback) {
|
|
794
|
-
return __async(this, null, function* () {
|
|
795
|
-
return fetchAndRevalidate(
|
|
796
|
-
getComponentURL(props),
|
|
797
|
-
{},
|
|
798
|
-
(response) => {
|
|
799
|
-
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
800
|
-
},
|
|
801
|
-
(response) => {
|
|
802
|
-
response.text().then(callback);
|
|
803
|
-
}
|
|
804
|
-
);
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
function fetchStylesheet(props, callback) {
|
|
808
|
-
return __async(this, null, function* () {
|
|
809
|
-
return fetchAndRevalidate(
|
|
810
|
-
getStylesheetURL(props),
|
|
811
|
-
{},
|
|
812
|
-
(response) => {
|
|
813
|
-
return response.headers.get("x-ms-meta-deletedAt") == null;
|
|
814
|
-
},
|
|
815
|
-
(response) => {
|
|
816
|
-
response.text().then(callback);
|
|
817
|
-
}
|
|
818
|
-
);
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// src/dom.ts
|
|
823
|
-
function renderComponentElement(content, datasources) {
|
|
824
|
-
const wrapper = document.createElement("div");
|
|
825
|
-
wrapper.innerHTML = content;
|
|
826
|
-
const fragment = document.createDocumentFragment();
|
|
827
|
-
while (wrapper.firstChild) {
|
|
828
|
-
fragment.appendChild(wrapper.firstChild);
|
|
829
|
-
}
|
|
830
|
-
renderDOMElement(fragment, datasources);
|
|
831
|
-
return wrapper;
|
|
832
|
-
}
|
|
833
|
-
function cleanCollectionBit(path) {
|
|
834
|
-
return path.replace(/(\[[^\]\[]+\]|\.\*)$/g, "");
|
|
835
|
-
}
|
|
836
|
-
function normalizeCollectionScope(path) {
|
|
837
|
-
return cleanCollectionBit(path) + ".*";
|
|
838
|
-
}
|
|
839
|
-
function getDOMCollectionIndex(element) {
|
|
840
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
841
|
-
var index = 0;
|
|
842
|
-
for (var p = element; p = p.previousElementSibling; ) {
|
|
843
|
-
if (p.getAttribute("data-path-scope") == datascope) {
|
|
844
|
-
index++;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return index;
|
|
848
|
-
}
|
|
849
|
-
function updateDOMClones(element, targetCount, config) {
|
|
850
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
851
|
-
if (datascope == null) {
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
var index = getDOMCollectionIndex(element);
|
|
855
|
-
if (index != 0) {
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
const parentElement = element.parentElement;
|
|
859
|
-
if (parentElement == null) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
if (targetCount == 0) {
|
|
863
|
-
element.style.display = "none";
|
|
864
|
-
} else if (element.style.display) {
|
|
865
|
-
element.style.display = "";
|
|
866
|
-
if (element.getAttribute("style") == "")
|
|
867
|
-
element.removeAttribute("style");
|
|
868
|
-
}
|
|
869
|
-
var count = index + 1;
|
|
870
|
-
var last = element;
|
|
871
|
-
for (var n = element; n = n.nextElementSibling; ) {
|
|
872
|
-
if (n.getAttribute("data-path-scope") == datascope) {
|
|
873
|
-
count++;
|
|
874
|
-
last = n;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
for (var i = count; i < targetCount; i++) {
|
|
878
|
-
parentElement.insertBefore(last.cloneNode(true), last.nextElementSibling);
|
|
879
|
-
}
|
|
880
|
-
for (var i = Math.max(1, targetCount); i < count; i++) {
|
|
881
|
-
last = last.previousElementSibling;
|
|
882
|
-
parentElement.removeChild(last.nextElementSibling);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
886
|
-
var path = datapath;
|
|
887
|
-
const keys = Object.keys(scopes).sort((b, a) => a.length - b.length);
|
|
888
|
-
for (const scope of keys) {
|
|
889
|
-
if (datapath.startsWith(scope) && "ends with it") {
|
|
890
|
-
if (scope == datapath) {
|
|
891
|
-
if (singleValue) {
|
|
892
|
-
return scopes[scope];
|
|
893
|
-
} else {
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
path = datapath.substring(scope.length + 1);
|
|
898
|
-
json = scopes[scope];
|
|
899
|
-
break;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
const collection = JSONPath({
|
|
903
|
-
path,
|
|
904
|
-
json
|
|
905
|
-
});
|
|
906
|
-
if (singleValue && collection && Array.isArray(collection)) {
|
|
907
|
-
return collection[0];
|
|
908
|
-
} else {
|
|
909
|
-
return collection;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
function setDOMAttribute(element, attribute, value, config) {
|
|
913
|
-
var _a;
|
|
914
|
-
if (!element)
|
|
915
|
-
return;
|
|
916
|
-
var target = element;
|
|
917
|
-
if (config == null ? void 0 : config.processValue) {
|
|
918
|
-
value = config == null ? void 0 : config.processValue(element, attribute, value);
|
|
919
|
-
}
|
|
920
|
-
var prop = attribute.replace("data-path-", "");
|
|
921
|
-
if (attribute == "data-path-src") {
|
|
922
|
-
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
923
|
-
} else if (attribute == "data-path-href") {
|
|
924
|
-
target = element.querySelector("a") || element.closest("a");
|
|
925
|
-
} else if (attribute == "data-path-alt") {
|
|
926
|
-
target = element.querySelector("img, picture");
|
|
927
|
-
} else if (attribute == "data-path-hidden") {
|
|
928
|
-
value = !value ? true : null;
|
|
929
|
-
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
930
|
-
prop = "innerHTML";
|
|
931
|
-
} else if (attribute == "data-embed-src") {
|
|
932
|
-
loadScript(element, value);
|
|
933
|
-
} else if (attribute == "data-path-attributes") {
|
|
934
|
-
const oldKeys = ((_a = element.getAttribute("data-attributes-keys")) == null ? void 0 : _a.split(",").filter(Boolean)) || [];
|
|
935
|
-
for (var property in value) {
|
|
936
|
-
var subvalue = value[property];
|
|
937
|
-
setDOMAttribute(
|
|
938
|
-
element,
|
|
939
|
-
property,
|
|
940
|
-
typeof subvalue == "object" && subvalue ? JSON.stringify(subvalue) : subvalue,
|
|
941
|
-
config
|
|
942
|
-
);
|
|
943
|
-
}
|
|
944
|
-
for (var i = 0; i < oldKeys.length; i++) {
|
|
945
|
-
if (value == null || !(oldKeys[i] in value)) {
|
|
946
|
-
setDOMAttribute(element, oldKeys[i], null, config);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
setDOMAttribute(element, "data-attributes-keys", Object.keys(value || {}).join(","));
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
if (typeof value == "boolean") {
|
|
953
|
-
value = value ? "" : null;
|
|
954
|
-
}
|
|
955
|
-
if (!target)
|
|
956
|
-
return;
|
|
957
|
-
var placeholder = String(element.getAttribute("data-path-placeholder") || target[prop]);
|
|
958
|
-
if (value != null) {
|
|
959
|
-
if (prop == "innerHTML") {
|
|
960
|
-
if (target.innerHTML != value) {
|
|
961
|
-
target.innerHTML = value;
|
|
962
|
-
}
|
|
963
|
-
} else {
|
|
964
|
-
if (target.getAttribute(prop) != value) {
|
|
965
|
-
target.setAttribute(prop, value);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
} else {
|
|
969
|
-
if (prop == "innerHTML") {
|
|
970
|
-
target.innerHTML = placeholder;
|
|
971
|
-
} else {
|
|
972
|
-
target.removeAttribute(prop);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
function observeDOMElement(element) {
|
|
977
|
-
const observer = new element.ownerDocument.defaultView.MutationObserver((changes) => {
|
|
978
|
-
changes.forEach((change) => {
|
|
979
|
-
const target = change.target;
|
|
980
|
-
const src = target.getAttribute("data-embed-src");
|
|
981
|
-
if (src) {
|
|
982
|
-
loadScript(target, src);
|
|
983
|
-
}
|
|
984
|
-
if (change.addedNodes) {
|
|
985
|
-
change.addedNodes.forEach((node) => {
|
|
986
|
-
if (node.nodeType == 1)
|
|
987
|
-
autoloadScripts(node, false);
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
observer.observe(element, { attributes: true, subtree: true, childList: true });
|
|
993
|
-
return observer;
|
|
994
|
-
}
|
|
995
|
-
function autoloadScripts(element, observe = true) {
|
|
996
|
-
const embeds = element.querySelectorAll("[data-embed-src]");
|
|
997
|
-
for (var i = 0; i < embeds.length; i++) {
|
|
998
|
-
const embed = embeds[i];
|
|
999
|
-
loadScript(embed, embed.getAttribute("data-embed-src"));
|
|
1000
|
-
}
|
|
1001
|
-
if (observe)
|
|
1002
|
-
return observeDOMElement(element);
|
|
1003
|
-
}
|
|
1004
|
-
function loadScript(element, src) {
|
|
1005
|
-
for (var p = element; p; p = p.parentElement) {
|
|
1006
|
-
if (!p.parentElement) {
|
|
1007
|
-
const scripts = p.querySelectorAll("script");
|
|
1008
|
-
for (var i = 0; i < scripts.length; i++) {
|
|
1009
|
-
if (scripts[i].getAttribute("src") == src) {
|
|
1010
|
-
return true;
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
if (p.tagName == "HTML")
|
|
1014
|
-
p = p.querySelector("head") || p;
|
|
1015
|
-
const script = p.ownerDocument.createElement("script");
|
|
1016
|
-
script.type = "module";
|
|
1017
|
-
script.src = src;
|
|
1018
|
-
p.appendChild(script);
|
|
1019
|
-
break;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
var sortOrder = ["data-attributes-keys", "data-path-attributes", "data-path-scope"];
|
|
1024
|
-
function renderDOMElement(input, datascopes, config, isNested) {
|
|
1025
|
-
var _a, _b, _c;
|
|
1026
|
-
const element = input;
|
|
1027
|
-
if (!isNested) {
|
|
1028
|
-
datascopes = ((_a = config == null ? void 0 : config.processData) == null ? void 0 : _a.call(config, element, datascopes)) || datascopes;
|
|
1029
|
-
}
|
|
1030
|
-
if (element.nodeType == 1) {
|
|
1031
|
-
const datascope = element.getAttribute("data-path-scope");
|
|
1032
|
-
if (datascope) {
|
|
1033
|
-
const index = getDOMCollectionIndex(element);
|
|
1034
|
-
const collection = queryScopes(datascopes, datascope, false) || [];
|
|
1035
|
-
if (index == 0) {
|
|
1036
|
-
updateDOMClones(element, ((_b = config == null ? void 0 : config.shouldRepeat) == null ? void 0 : _b.call(config, element, collection)) === false ? 1 : collection.length, config);
|
|
1037
|
-
}
|
|
1038
|
-
datascopes = __spreadProps(__spreadValues({}, datascopes), {
|
|
1039
|
-
[normalizeCollectionScope(datascope)]: collection[index]
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
const attrs = Array.prototype.slice.call(element.attributes).sort((a, b) => {
|
|
1043
|
-
return sortOrder.indexOf(a.name) - sortOrder.indexOf(b.name);
|
|
1044
|
-
});
|
|
1045
|
-
for (var i = 0; i < attrs.length; i++) {
|
|
1046
|
-
const { name, value: datapath } = attrs[i];
|
|
1047
|
-
if (name.startsWith("data-path") && name != "data-path-scope") {
|
|
1048
|
-
setDOMAttribute(element, name, queryScopes(datascopes, datapath, true), config);
|
|
1049
|
-
}
|
|
1050
|
-
if (name == "data-embed-src") {
|
|
1051
|
-
setDOMAttribute(element, name, element.getAttribute(name), config);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
for (var i = 0; i < element.children.length; i++) {
|
|
1056
|
-
renderDOMElement(element.children[i], datascopes, config, true);
|
|
1057
|
-
}
|
|
1058
|
-
if (!isNested) {
|
|
1059
|
-
(_c = config == null ? void 0 : config.onRender) == null ? void 0 : _c.call(config, element, datascopes);
|
|
1060
|
-
}
|
|
1061
|
-
return element;
|
|
1062
|
-
}
|
|
1063
|
-
function renderDOMContent(root, template, data, config) {
|
|
1064
|
-
var _a;
|
|
1065
|
-
const newTemplate = ((_a = config == null ? void 0 : config.processTemplate) == null ? void 0 : _a.call(config, root, template, data)) || template;
|
|
1066
|
-
root.innerHTML = newTemplate;
|
|
1067
|
-
root.classList.add("-feaas");
|
|
1068
|
-
return renderDOMElement(root, data, config);
|
|
1069
|
-
}
|
|
1070
|
-
function renderStylesheet(props, style) {
|
|
1071
|
-
renderStylesheetPromise(props, style || (style = document.createElement("style")));
|
|
1072
|
-
return style;
|
|
1073
|
-
}
|
|
1074
|
-
function renderStylesheetPromise(props, style) {
|
|
1075
|
-
style || (style = document.createElement("style"));
|
|
1076
|
-
return fetchStylesheet(props, (cssText) => {
|
|
1077
|
-
style.textContent = cssText;
|
|
1078
|
-
}).then(() => style);
|
|
1079
|
-
}
|
|
1080
|
-
function renderComponent(props, root) {
|
|
1081
|
-
renderComponentPromise(props, root || (root = document.createElement("div")));
|
|
1082
|
-
return root;
|
|
1083
|
-
}
|
|
1084
|
-
function renderComponentPromise(props, root) {
|
|
1085
|
-
return __async(this, null, function* () {
|
|
1086
|
-
root || (root = document.createElement("div"));
|
|
1087
|
-
if (!root.childNodes.length) {
|
|
1088
|
-
if ("template" in props) {
|
|
1089
|
-
return renderDOMContent(root, props.template, props.data, props);
|
|
1090
|
-
} else {
|
|
1091
|
-
return fetchComponent(props, (template) => {
|
|
1092
|
-
return renderDOMContent(root, template, props.data, props);
|
|
1093
|
-
}).then(() => root);
|
|
1094
|
-
}
|
|
1095
|
-
} else {
|
|
1096
|
-
return renderDOMElement(root, props.data, props);
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// src/components/FEAASBase.tsx
|
|
1102
|
-
var FEAASBase = class extends HTMLElement {
|
|
1103
|
-
constructor() {
|
|
1104
|
-
super(...arguments);
|
|
1105
|
-
this.connected = null;
|
|
1106
|
-
this.refs = {};
|
|
1107
|
-
this.descendants = [];
|
|
1108
|
-
this.onLoad = (payload) => {
|
|
1109
|
-
if (payload == null)
|
|
1110
|
-
return;
|
|
1111
|
-
this.payload = payload;
|
|
1112
|
-
this.render();
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
getProps(context) {
|
|
1116
|
-
return {};
|
|
1117
|
-
}
|
|
1118
|
-
getRoot() {
|
|
1119
|
-
return this;
|
|
1120
|
-
}
|
|
1121
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1122
|
-
this.set();
|
|
1123
|
-
}
|
|
1124
|
-
connectedCallback() {
|
|
1125
|
-
console.log("FEAAS: Connected", this);
|
|
1126
|
-
this.connected = new Event("feaasConnected", { bubbles: true, composed: true });
|
|
1127
|
-
this.dispatchEvent(this.connected);
|
|
1128
|
-
this.addEventListener("feaasConnected", this);
|
|
1129
|
-
this.addEventListener("feaasDisconnected", this);
|
|
1130
|
-
this.set();
|
|
1131
|
-
}
|
|
1132
|
-
disconnectedCallback() {
|
|
1133
|
-
console.log("FEAAS: Disconnected", this);
|
|
1134
|
-
this.removeEventListener("feaasConnected", this);
|
|
1135
|
-
this.removeEventListener("feaasDisconnected", this);
|
|
1136
|
-
this.dispatchEvent(new Event("feaasDisconnected", { bubbles: true, composed: true }));
|
|
1137
|
-
this.connected = null;
|
|
1138
|
-
}
|
|
1139
|
-
handleEvent(event) {
|
|
1140
|
-
switch (event.type) {
|
|
1141
|
-
case "feaasConnected":
|
|
1142
|
-
this.nestedCallback(event);
|
|
1143
|
-
break;
|
|
1144
|
-
case "feaasDisconnected":
|
|
1145
|
-
this.unnestedCallback(event);
|
|
1146
|
-
break;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
unnestedCallback(event) {
|
|
1150
|
-
const target = event.composedPath()[0];
|
|
1151
|
-
const index = this.descendants.indexOf(target);
|
|
1152
|
-
if (index == -1)
|
|
1153
|
-
return;
|
|
1154
|
-
console.log("FEAAS: Unnest", this, target);
|
|
1155
|
-
this.descendants.splice(index, -1);
|
|
1156
|
-
this.refs[target.getComponentName()] = null;
|
|
1157
|
-
if (target.refs.parent == this)
|
|
1158
|
-
target.refs.parent = null;
|
|
1159
|
-
if (target.refs.top == this) {
|
|
1160
|
-
target.refs.top = target.refs.parent;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
nestedCallback(event) {
|
|
1164
|
-
var _a, _b;
|
|
1165
|
-
const target = event.composedPath()[0];
|
|
1166
|
-
const index = this.descendants.indexOf(target);
|
|
1167
|
-
if (index != -1)
|
|
1168
|
-
return;
|
|
1169
|
-
this.descendants.push(target);
|
|
1170
|
-
console.log("FEAAS: Nest", this, target);
|
|
1171
|
-
this.refs[target.getComponentName()] = target;
|
|
1172
|
-
target.refs.top = this;
|
|
1173
|
-
(_a = target.refs).parent || (_a.parent = this);
|
|
1174
|
-
if (target.renderReact) {
|
|
1175
|
-
for (var p = target.refs.parent; p; p = p.refs.parent) {
|
|
1176
|
-
if (p.renderReact) {
|
|
1177
|
-
(_b = target.refs).parentReact || (_b.parentReact = p);
|
|
1178
|
-
target.refs.topReact = p;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
getComponentName() {
|
|
1184
|
-
return this.tagName.replace("FEAAS-", "").toLowerCase();
|
|
1185
|
-
}
|
|
1186
|
-
isReadyToLoad() {
|
|
1187
|
-
return this.payload === void 0 && this.getAttribute("hidden") == null;
|
|
1188
|
-
}
|
|
1189
|
-
reify() {
|
|
1190
|
-
return __async(this, null, function* () {
|
|
1191
|
-
if (this.payload !== void 0) {
|
|
1192
|
-
this.render();
|
|
1193
|
-
} else if (this.isReadyToLoad()) {
|
|
1194
|
-
this.payload = null;
|
|
1195
|
-
this.load().then(this.onLoad);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
load() {
|
|
1200
|
-
return Promise.resolve(null);
|
|
1201
|
-
}
|
|
1202
|
-
render(nested = false) {
|
|
1203
|
-
var _a, _b, _c;
|
|
1204
|
-
console.log("FEAAS: React", this.tagName, this.payload);
|
|
1205
|
-
if (this.payload == null)
|
|
1206
|
-
return;
|
|
1207
|
-
const { React, ReactDOM } = this.payload || {};
|
|
1208
|
-
if (!React)
|
|
1209
|
-
throw new Error(`${this.tagName}: React is not present in payload`);
|
|
1210
|
-
if (!ReactDOM)
|
|
1211
|
-
throw new Error(`${this.tagName}: ReactDOM is not present in payload`);
|
|
1212
|
-
if (!this.refs.topReact && !this.forceUpdateReact) {
|
|
1213
|
-
ReactDOM.render(React.createElement(this.getReactWrapper()), this.getReactRoot());
|
|
1214
|
-
} else if (this.forceUpdateReact) {
|
|
1215
|
-
(_a = this.forceUpdateReact) == null ? void 0 : _a.call(this);
|
|
1216
|
-
} else {
|
|
1217
|
-
(_c = (_b = this.refs.topReact).forceUpdateReact) == null ? void 0 : _c.call(_b);
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
invokeReactRendering() {
|
|
1221
|
-
const { React, ReactDOM } = this.payload || {};
|
|
1222
|
-
const children = this.descendants.filter((r) => {
|
|
1223
|
-
return r.refs.parentReact == this && r.payload;
|
|
1224
|
-
}).map((child, index) => {
|
|
1225
|
-
return React.createElement(this.getReactWrapper(child), {
|
|
1226
|
-
key: this.tagName + "-" + index,
|
|
1227
|
-
slot: child.getAttribute("slot")
|
|
1228
|
-
});
|
|
1229
|
-
});
|
|
1230
|
-
return this.renderReact(__spreadProps(__spreadValues({}, this.props), { children }), this.payload);
|
|
1231
|
-
}
|
|
1232
|
-
getReactWrapper(target = this, displayName = target.tagName) {
|
|
1233
|
-
const Wrapper = target.reactWrapper || (target.reactWrapper = (props) => {
|
|
1234
|
-
if (target.renderReact) {
|
|
1235
|
-
const { React, ReactDOM } = target.payload || {};
|
|
1236
|
-
const [value, forceUpdateReact] = React.useReducer((r) => r + 1, 0);
|
|
1237
|
-
target.forceUpdateReact = forceUpdateReact;
|
|
1238
|
-
return ReactDOM.createPortal(/* @__PURE__ */ React.createElement(React.Fragment, null, target.invokeReactRendering()), target.getReactRoot());
|
|
1239
|
-
} else {
|
|
1240
|
-
return target.render();
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
Object.assign(Wrapper, {
|
|
1244
|
-
displayName
|
|
1245
|
-
});
|
|
1246
|
-
return Wrapper;
|
|
1247
|
-
}
|
|
1248
|
-
getUID() {
|
|
1249
|
-
return this.uid || (this.uid = String(Math.random()));
|
|
1250
|
-
}
|
|
1251
|
-
getReactRoot() {
|
|
1252
|
-
return this.getRoot();
|
|
1253
|
-
}
|
|
1254
|
-
set(overrides) {
|
|
1255
|
-
this.overrides = __spreadValues(__spreadValues({}, this.overrides), overrides);
|
|
1256
|
-
this.props = __spreadValues(__spreadValues({}, this.getProps()), this.overrides);
|
|
1257
|
-
for (var property in this.props) {
|
|
1258
|
-
const value = this.props[property];
|
|
1259
|
-
if (this.props[property] == null) {
|
|
1260
|
-
this.removeAttribute(property);
|
|
1261
|
-
} else if (typeof value == "string" || typeof value == "number") {
|
|
1262
|
-
if (this.getAttribute(property) != String(value))
|
|
1263
|
-
this.setAttribute(property, String(value));
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
this.scheduleRender();
|
|
1267
|
-
}
|
|
1268
|
-
scheduleRender() {
|
|
1269
|
-
cancelAnimationFrame(this.nextRender);
|
|
1270
|
-
this.nextRender = requestAnimationFrame(() => {
|
|
1271
|
-
this.reify();
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
formatURL(src, hostname) {
|
|
1275
|
-
if (typeof src == "string" && src.match(/^\/[^\/]/)) {
|
|
1276
|
-
return hostname + src;
|
|
1277
|
-
} else {
|
|
1278
|
-
return src;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
getContextAttribute(name, element = this) {
|
|
1282
|
-
var _a, _b;
|
|
1283
|
-
return (_b = (_a = element.closest(`[${name}]`)) == null ? void 0 : _a.getAttribute(name)) != null ? _b : this.getAttribute(name);
|
|
1284
|
-
}
|
|
1285
|
-
static register(tagName) {
|
|
1286
|
-
if (!window.customElements.get(tagName)) {
|
|
1287
|
-
window.customElements.define(tagName, this);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
|
-
|
|
1292
|
-
// src/components/FEAASLoader.ts
|
|
1293
|
-
function FEAASLoaderProps(element = this) {
|
|
1294
|
-
return {
|
|
1295
|
-
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
var FEAASLoader = class extends FEAASBase {
|
|
1299
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1300
|
-
if (name == "hidden") {
|
|
1301
|
-
this.style.setProperty("display", "block", "important");
|
|
1302
|
-
this.style.setProperty("transition", "opacity 0.3s", "important");
|
|
1303
|
-
if (newValue) {
|
|
1304
|
-
this.style.setProperty("opacity", "0", "important");
|
|
1305
|
-
this.style.pointerEvents = "none";
|
|
1306
|
-
} else {
|
|
1307
|
-
this.style.setProperty("opacity", "1", "important");
|
|
1308
|
-
this.style.pointerEvents = "all";
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
connectedCallback() {
|
|
1313
|
-
this.attributeChangedCallback("hidden", this.getAttribute("hidden"), this.getAttribute("hidden"));
|
|
1314
|
-
this.stylesheet = document.createElement("style");
|
|
1315
|
-
this.stylesheet.textContent = `
|
|
1
|
+
var K=Object.create;var C=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var tt=(t,e)=>{for(var r in e)C(t,r,{get:e[r],enumerable:!0})},N=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Q(e))!Z.call(t,i)&&i!==r&&C(t,i,{get:()=>e[i],enumerable:!(n=G(e,i))||n.enumerable});return t};var et=(t,e,r)=>(r=t!=null?K(X(t)):{},N(e||!t||!t.__esModule?C(r,"default",{value:t,enumerable:!0}):r,t)),rt=t=>N(C({},"__esModule",{value:!0}),t);var ut={};tt(ut,{Base:()=>b,Component:()=>_,FEAASBase:()=>b,FEAASComponent:()=>_,FEAASComponentsProps:()=>V,FEAASLoader:()=>S,FEAASLoaderProps:()=>ht,FEAASStylesheet:()=>T,FEAASStylesheetProps:()=>z,Loader:()=>S,Stylesheet:()=>T,autoloadScripts:()=>q,cleanCollectionBit:()=>H,fetchAndRevalidate:()=>R,loadScript:()=>k,normalizeCollectionScope:()=>U,observeDOMElement:()=>W,queryScopes:()=>M,renderComponent:()=>lt,renderComponentElement:()=>st,renderComponentPromise:()=>I,renderDOMContent:()=>E,renderDOMElement:()=>A,renderStylesheet:()=>at,renderStylesheetPromise:()=>B,setDOMAttribute:()=>w});module.exports=rt(ut);var F=et(require("vm"),1),{hasOwnProperty:g}=Object.prototype;function v(t,e){return t=t.slice(),t.push(e),t}function $(t,e){return e=e.slice(),e.unshift(t),e}var L=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,n,i){if(!(this instanceof p))try{return new p(t,e,r,n,i)}catch(o){if(!o.avoidNew)throw o;return o.value}typeof t=="string"&&(i=n,n=r,r=e,e=t,t=null);let s=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=g.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||n||null,this.otherTypeCallback=t.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let o={path:s?t.path:e};s?"json"in t&&(o.json=t.json):o.json=r;let a=this.evaluate(o);if(!a||typeof a!="object")throw new L(a);return a}}p.prototype.evaluate=function(t,e,r,n){let i=this.parent,s=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!g.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),o=g.call(t,"flatten")?t.flatten:o,this.currResultType=g.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=g.call(t,"sandbox")?t.sandbox:this.currSandbox,a=g.call(t,"wrap")?t.wrap:a,this.currPreventEval=g.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=g.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=g.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,i=g.call(t,"parent")?t.parent:i,s=g.call(t,"parentProperty")?t.parentProperty:s,t=t.path}if(i=i||null,s=s||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let c=p.toPathArray(t);c[0]==="$"&&c.length>1&&c.shift(),this._hasParentSelector=null;let l=this._trace(c,e,["$"],i,s,r).filter(function(d){return d&&!d.isParentSelector});return l.length?!a&&l.length===1&&!l[0].hasArrExpr?this._getPreferredOutput(l[0]):l.reduce((d,u)=>{let f=this._getPreferredOutput(u);return o&&Array.isArray(f)?d=d.concat(f):d.push(f),d},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let n=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(n,r,t)}};p.prototype._trace=function(t,e,r,n,i,s,o,a){let c;if(!t.length)return c={path:r,value:e,parent:n,parentProperty:i,hasArrExpr:o},this._handleCallback(c,s,"value"),c;let l=t[0],d=t.slice(1),u=[];function f(h){Array.isArray(h)?h.forEach(y=>{u.push(y)}):u.push(h)}if((typeof l!="string"||a)&&e&&g.call(e,l))f(this._trace(d,e[l],v(r,l),e,l,s,o));else if(l==="*")this._walk(e,h=>{f(this._trace(d,e[h],v(r,h),e,h,s,!0,!0))});else if(l==="..")f(this._trace(d,e,r,n,i,s,o)),this._walk(e,h=>{typeof e[h]=="object"&&f(this._trace(t.slice(),e[h],v(r,h),e,h,s,!0))});else{if(l==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:d,isParentSelector:!0};if(l==="~")return c={path:v(r,l),value:i,parent:n,parentProperty:null},this._handleCallback(c,s,"property"),c;if(l==="$")f(this._trace(d,e,r,null,null,s,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))f(this._slice(l,d,e,r,n,i,s));else if(l.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let h=l.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,y=>{this._eval(h,e[y],y,r,n,i)&&f(this._trace(d,e[y],v(r,y),e,y,s,!0))})}else if(l[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace($(this._eval(l,e,r[r.length-1],r.slice(0,-1),n,i),d),e,r,n,i,s,o))}else if(l[0]==="@"){let h=!1,y=l.slice(1,-2);switch(y){case"scalar":(!e||!["object","function"].includes(typeof e))&&(h=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===y&&(h=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(h=!0);break;case"number":Number.isFinite(e)&&(h=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(h=!0);break;case"object":e&&typeof e===y&&(h=!0);break;case"array":Array.isArray(e)&&(h=!0);break;case"other":h=this.currOtherTypeCallback(e,r,n,i);break;case"null":e===null&&(h=!0);break;default:throw new TypeError("Unknown value type "+y)}if(h)return c={path:r,value:e,parent:n,parentProperty:i},this._handleCallback(c,s,"value"),c}else if(l[0]==="`"&&e&&g.call(e,l.slice(1))){let h=l.slice(1);f(this._trace(d,e[h],v(r,h),e,h,s,o,!0))}else if(l.includes(",")){let h=l.split(",");for(let y of h)f(this._trace($(y,d),e,r,n,i,s,!0))}else!a&&e&&g.call(e,l)&&f(this._trace(d,e[l],v(r,l),e,l,s,o,!0))}if(this._hasParentSelector)for(let h=0;h<u.length;h++){let y=u[h];if(y&&y.isParentSelector){let m=this._trace(y.expr,e,y.path,n,i,s,o);if(Array.isArray(m)){u[h]=m[0];let Y=m.length;for(let O=1;O<Y;O++)h++,u.splice(h,0,m[O])}else u[h]=m}}return u};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let n=0;n<r;n++)e(n)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,n,i,s,o){if(!Array.isArray(r))return;let a=r.length,c=t.split(":"),l=c[2]&&Number.parseInt(c[2])||1,d=c[0]&&Number.parseInt(c[0])||0,u=c[1]&&Number.parseInt(c[1])||a;d=d<0?Math.max(0,d+a):Math.min(a,d),u=u<0?Math.max(0,u+a):Math.min(a,u);let f=[];for(let h=d;h<u;h+=l)this._trace($(h,e),r,n,i,s,o,!0).forEach(m=>{f.push(m)});return f};p.prototype._eval=function(t,e,r,n,i,s){this.currSandbox._$_parentProperty=s,this.currSandbox._$_parent=i,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let o=t.includes("@path");o&&(this.currSandbox._$_path=p.toPathString(n.concat([r])));let a="script:"+t;if(!p.cache[a]){let c=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");o&&(c=c.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(c)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(c){throw new Error("jsonPath: "+c.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,n="$";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(e[i])||(n+=/^[0-9*]+$/u.test(e[i])?"["+e[i]+"]":"['"+e[i]+"']");return n};p.toPointer=function(t){let e=t,r=e.length,n="";for(let i=1;i<r;i++)/^(~|\^|@.*?\(\))$/u.test(e[i])||(n+="/"+e[i].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return n};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],i=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(s,o){return"[#"+(r.push(o)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(s,o){return"['"+o.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(s,o){return";"+o.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(s){let o=s.match(/#(\d+)/u);return!o||!o[1]?s:r[o[1]]});return e[t]=i,e[t].concat()};p.prototype.vm=F.default;async function R(t,e,r,n){let i=new Date,s=await fetch(t,e);if(!s.ok)throw new Error("Fetch failed");let o=new Date(s.headers.get("date"));var a=s;if(n(s,"cached"),o<i){let c=await fetch(t+"?"+Math.random(),{...e,method:"HEAD",cache:"no-cache"});if(c.headers.get("last-modified")!=s.headers.get("last-modified")){if(r(c)===!1)throw new Error("Response is stale");a=await fetch(t,{...e,cache:"reload"})}}if(r(a)===!1)throw new Error("Response is not valid");return s!==a&&n(a,"valid"),a}function nt({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,component:n,version:i,revision:s="published"}){return`${t||e}/components/${r}/${n}/${i}/${s}.html`}function it({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,revision:n="published"}){return`${t||e}/styles/${r}/${n}.css`}async function x(t,e){return R(nt(t),{},r=>r.headers.get("x-ms-meta-versionDeletedAt")==null,r=>{r.text().then(e)})}async function P(t,e){return R(it(t),{},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(e)})}function st(t,e){let r=document.createElement("div");r.innerHTML=t;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return A(n,e),r}function H(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function U(t){return H(t)+".*"}function J(t){let e=t.getAttribute("data-path-scope");for(var r=0,n=t;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==e&&r++;return r}function ot(t,e,r){let n=t.getAttribute("data-path-scope");if(n==null)return;var i=J(t);if(i!=0)return;let s=t.parentElement;if(s!=null){e==0?t.style.display="none":t.style.display&&(t.style.display="",t.getAttribute("style")==""&&t.removeAttribute("style"));for(var o=i+1,a=t,c=t;c=c.nextElementSibling;)c.getAttribute("data-path-scope")==n&&(o++,a=c);for(var l=o;l<e;l++)s.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var l=Math.max(1,e);l<o;l++)a=a.previousElementSibling,s.removeChild(a.nextElementSibling)}}function M(t,e,r=!1,n=t){var i=e;let s=Object.keys(t).sort((a,c)=>c.length-a.length);for(let a of s)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}i=e.substring(a.length+1),n=t[a];break}var o=p({path:i,json:n});return t!=null&&t._&&Array.isArray(o)&&(o==null?void 0:o.length)==0&&(o=p({path:i.replace(/^.*?\./,"_."),json:t})),r&&Array.isArray(o)?o[0]:o}function w(t,e,r,n){var i;if(t){var s=t;n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(t,e,r));var o=e.replace("data-path-","");if(e=="data-path-src")s=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")s=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")s=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")o="innerHTML";else if(e=="data-embed-src")k(t,r);else if(e=="data-path-attributes"){let u=((i=t.getAttribute("data-attributes-keys"))===null||i===void 0?void 0:i.split(",").filter(Boolean))||[];for(var a in r){var c=r[a];w(t,a,typeof c=="object"&&c?JSON.stringify(c):c,n)}for(var l=0;l<u.length;l++)(r==null||!(u[l]in r))&&w(t,u[l],null,n);w(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!s){var d=String(t.getAttribute("data-path-placeholder")||s[o]);r!=null?o=="innerHTML"?s.innerHTML!=r&&(s.innerHTML=r):s.getAttribute(o)!=r&&s.setAttribute(o,r):o=="innerHTML"?s.innerHTML=d:s.removeAttribute(o)}}}function W(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,s=i.getAttribute("data-embed-src");s&&k(i,s),n.addedNodes&&n.addedNodes.forEach(o=>{o.nodeType==1&&q(o,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function q(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];k(i,i.getAttribute("data-embed-src"))}if(e)return W(t)}function k(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let s=r.ownerDocument.createElement("script");s.type="module",s.src=e,r.appendChild(s);break}}var j=["data-attributes-keys","data-path-attributes","data-path-scope"];function A(t,e,r,n){var i,s,o;let a=t;if(n||(e=((i=r==null?void 0:r.processData)===null||i===void 0?void 0:i.call(r,a,e))||e),a.nodeType==1){let l=a.getAttribute("data-path-scope");if(l){let u=J(a),f=M(e,l,!1)||[];u==0&&ot(a,((s=r==null?void 0:r.shouldRepeat)===null||s===void 0?void 0:s.call(r,a,f))===!1?1:f.length,r),e={...e,[U(l)]:f[u]}}let d=Array.prototype.slice.call(a.attributes).sort((u,f)=>j.indexOf(u.name)-j.indexOf(f.name));for(var c=0;c<d.length;c++){let{name:u,value:f}=d[c];u.startsWith("data-path")&&u!="data-path-scope"&&w(a,u,M(e,f,!0),r),u=="data-embed-src"&&w(a,u,a.getAttribute(u),r)}}for(var c=0;c<a.children.length;c++)A(a.children[c],e,r,!0);return n||(o=r==null?void 0:r.onRender)===null||o===void 0||o.call(r,a,e),a}function E(t,e,r,n){var i;let s=((i=n==null?void 0:n.processTemplate)===null||i===void 0?void 0:i.call(n,t,e,r))||e;return t.innerHTML=s,t.classList.add("-feaas"),A(t,r,n)}function at(t,e){return B(t,e||(e=document.createElement("style"))),e}function B(t,e){return e||(e=document.createElement("style")),P(t,r=>{e.textContent=r}).then(()=>e)}function lt(t,e){return I(t,e||(e=document.createElement("div"))),e}async function I(t,e){return e||(e=document.createElement("div")),e.childNodes.length?A(e,t.data,t):"template"in t?E(e,t.template,t.data,t):x(t,r=>E(e,r,t.data,t)).then(()=>e)}var ct=typeof HTMLElement=="undefined"?class{}:HTMLElement,b=class extends ct{constructor(){super(...arguments),this.connected=null,this.refs={},this.descendants=[],this.onLoad=e=>{e!=null&&(this.payload=e,this.render())}}getProps(e){return{}}getRoot(){return this}attributeChangedCallback(e,r,n){this.set()}connectedCallback(){console.log("FEAAS: Connected",this),this.connected=new Event("feaasConnected",{bubbles:!0,composed:!0}),this.dispatchEvent(this.connected),this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this),this.set()}disconnectedCallback(){console.log("FEAAS: Disconnected",this),this.removeEventListener("feaasConnected",this),this.removeEventListener("feaasDisconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null}handleEvent(e){switch(e.type){case"feaasConnected":this.nestedCallback(e);break;case"feaasDisconnected":this.unnestedCallback(e);break}}unnestedCallback(e){let r=e.composedPath()[0],n=this.descendants.indexOf(r);n!=-1&&(console.log("FEAAS: Unnest",this,r),this.descendants.splice(n,-1),this.refs[r.getComponentName()]=null,r.refs.parent==this&&(r.refs.parent=null),r.refs.top==this&&(r.refs.top=r.refs.parent))}nestedCallback(e){var r,n;let i=e.composedPath()[0];if(this.descendants.indexOf(i)==-1&&(this.descendants.push(i),console.log("FEAAS: Nest",this,i),this.refs[i.getComponentName()]=i,i.refs.top=this,(r=i.refs).parent||(r.parent=this),i.renderReact))for(var o=i.refs.parent;o;o=o.refs.parent)o.renderReact&&((n=i.refs).parentReact||(n.parentReact=o),i.refs.topReact=o)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.render():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}render(e=!1){var r,n,i;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:s,ReactDOM:o}=this.payload||{};if(!s)throw new Error(`${this.tagName}: React is not present in payload`);if(!o)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?o.render(s.createElement(this.getReactWrapper()),this.getReactRoot()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(i=(n=this.refs.topReact).forceUpdateReact)===null||i===void 0||i.call(n)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{},n=this.descendants.filter(i=>i.refs.parentReact==this&&i.payload).map((i,s)=>e.createElement(this.getReactWrapper(i),{key:this.tagName+"-"+s,slot:i.getAttribute("slot")}));return this.renderReact({...this.props,children:n},this.payload)}getReactWrapper(e=this,r=e.tagName){let n=e.reactWrapper||(e.reactWrapper=i=>{if(e.renderReact){let{React:s,ReactDOM:o}=e.payload||{},[a,c]=s.useReducer(l=>l+1,0);return e.forceUpdateReact=c,o.createPortal(s.createElement(s.Fragment,null,e.invokeReactRendering()),e.getReactRoot())}else return e.render()});return Object.assign(n,{displayName:r}),n}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRoot(){return this.getRoot()}set(e){this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let n=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof n=="string"||typeof n=="number")&&this.getAttribute(r)!=String(n)&&this.setAttribute(r,String(n))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){var n,i;return(i=(n=r.closest(`[${e}]`))===null||n===void 0?void 0:n.getAttribute(e))!==null&&i!==void 0?i:this.getAttribute(e)}static register(e){typeof window!="undefined"&&!window.customElements.get(e)&&window.customElements.define(e,this)}};function V(t=this){let e,r=t.getAttribute("data");if(r!=null)try{e=typeof r=="string"?JSON.parse(r):{}}catch(n){}return{data:e!=null?e:{},library:t.getAttribute("library"),component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),hostname:t.getAttribute("hostname"),cdn:t.getContextAttribute("cdn"),template:t.getAttribute("template"),suspended:t.getAttribute("suspended")!=null}}var _=class extends b{setData(e){this.set({data:e})}getProps(){return V(this)}attributeChangedCallback(e,r,n){this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(e,r,n)}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{x(this.props,this.onLoad)}catch(e){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}render(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)A(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;E(this,this.payload,this.props.data)}}};_.observedAttributes=["library","component","version","revision","hostname","cdn","template","data"];_.register("feaas-component");function ht(t=this){return{hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var S=class extends b{attributeChangedCallback(e,r,n){e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all"))}connectedCallback(){this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
1316
2
|
#loader {
|
|
1317
3
|
position: absolute;
|
|
1318
4
|
top: 0;
|
|
@@ -1353,10 +39,7 @@ var FEAASLoader = class extends FEAASBase {
|
|
|
1353
39
|
width: 48px;
|
|
1354
40
|
height: 48px;
|
|
1355
41
|
}
|
|
1356
|
-
|
|
1357
|
-
this.loader = document.createElement("div");
|
|
1358
|
-
this.loader.id = "loader";
|
|
1359
|
-
this.loader.innerHTML = `
|
|
42
|
+
`,this.loader=document.createElement("div"),this.loader.id="loader",this.loader.innerHTML=`
|
|
1360
43
|
<div class="spinner">
|
|
1361
44
|
<svg
|
|
1362
45
|
viewBox="0 0 100 100"
|
|
@@ -1379,142 +62,5 @@ var FEAASLoader = class extends FEAASBase {
|
|
|
1379
62
|
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1380
63
|
></circle>
|
|
1381
64
|
</svg>
|
|
1382
|
-
</div
|
|
1383
|
-
|
|
1384
|
-
this.getRoot().appendChild(this.loader);
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
FEAASLoader.observedAttributes = ["hidden"];
|
|
1388
|
-
FEAASLoader.register("feaas-loader");
|
|
1389
|
-
|
|
1390
|
-
// src/components/FEAASStylesheet.ts
|
|
1391
|
-
function FEAASStylesheetProps(element = this) {
|
|
1392
|
-
var _a;
|
|
1393
|
-
return {
|
|
1394
|
-
library: element == null ? void 0 : element.getContextAttribute("library"),
|
|
1395
|
-
revision: (_a = element == null ? void 0 : element.getAttribute("revision")) != null ? _a : "published",
|
|
1396
|
-
cdn: (element == null ? void 0 : element.getContextAttribute("cdn")) || (element == null ? void 0 : element.getContextAttribute("hostname"))
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
var FEAASStylesheet = class extends FEAASBase {
|
|
1400
|
-
getProps() {
|
|
1401
|
-
return FEAASStylesheetProps(this);
|
|
1402
|
-
}
|
|
1403
|
-
isReadyToLoad() {
|
|
1404
|
-
return this.props.library != null && this.props.revision != null && this.props.cdn != null;
|
|
1405
|
-
}
|
|
1406
|
-
load() {
|
|
1407
|
-
return __async(this, null, function* () {
|
|
1408
|
-
fetchStylesheet(this.props, this.onLoad);
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
render() {
|
|
1412
|
-
if (!this.stylesheet) {
|
|
1413
|
-
this.stylesheet = document.createElement("style");
|
|
1414
|
-
this.appendChild(this.stylesheet);
|
|
1415
|
-
}
|
|
1416
|
-
this.stylesheet.textContent = this.payload;
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
FEAASStylesheet.register("feaas-stylesheet");
|
|
1420
|
-
|
|
1421
|
-
// src/components/FEAASComponent.ts
|
|
1422
|
-
function FEAASComponentsProps(element = this) {
|
|
1423
|
-
let data;
|
|
1424
|
-
const dataValue = element.getAttribute("data");
|
|
1425
|
-
if (dataValue != null) {
|
|
1426
|
-
try {
|
|
1427
|
-
data = typeof dataValue == "string" ? JSON.parse(dataValue) : {};
|
|
1428
|
-
} catch (e) {
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
return {
|
|
1432
|
-
data: data != null ? data : {},
|
|
1433
|
-
library: element.getAttribute("library"),
|
|
1434
|
-
component: element.getAttribute("component"),
|
|
1435
|
-
version: element.getAttribute("version"),
|
|
1436
|
-
revision: element.getAttribute("revision"),
|
|
1437
|
-
hostname: element.getAttribute("hostname"),
|
|
1438
|
-
cdn: element.getContextAttribute("cdn"),
|
|
1439
|
-
template: element.getAttribute("template")
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
var FEAASComponent = class extends FEAASBase {
|
|
1443
|
-
setData(data) {
|
|
1444
|
-
this.set({ data });
|
|
1445
|
-
}
|
|
1446
|
-
getProps() {
|
|
1447
|
-
return FEAASComponentsProps(this);
|
|
1448
|
-
}
|
|
1449
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
1450
|
-
this.payload = void 0;
|
|
1451
|
-
this.needsRefresh = true;
|
|
1452
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
1453
|
-
}
|
|
1454
|
-
getOriginal() {
|
|
1455
|
-
const scope = this.getAttribute("data-path-scope");
|
|
1456
|
-
if (!scope)
|
|
1457
|
-
return;
|
|
1458
|
-
for (var current = this; current = current.previousElementSibling; ) {
|
|
1459
|
-
if (current.getAttribute("data-path-scope") == scope) {
|
|
1460
|
-
var last = current;
|
|
1461
|
-
} else {
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return last;
|
|
1466
|
-
}
|
|
1467
|
-
isReadyToLoad() {
|
|
1468
|
-
return super.isReadyToLoad() && this.props.library != null && this.props.component != null && this.props.version != null;
|
|
1469
|
-
}
|
|
1470
|
-
load() {
|
|
1471
|
-
return __async(this, null, function* () {
|
|
1472
|
-
if (this.getOriginal()) {
|
|
1473
|
-
return;
|
|
1474
|
-
}
|
|
1475
|
-
try {
|
|
1476
|
-
fetchComponent(this.props, this.onLoad);
|
|
1477
|
-
} catch (e) {
|
|
1478
|
-
console.error(
|
|
1479
|
-
`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
render() {
|
|
1485
|
-
if (Array.from(this.children).filter((c) => c.tagName != "BR").length > 0 && !this.needsRefresh) {
|
|
1486
|
-
renderDOMElement(this, this.props.data);
|
|
1487
|
-
} else {
|
|
1488
|
-
this.needsRefresh = true;
|
|
1489
|
-
if (this.getOriginal()) {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
renderDOMContent(this, this.payload, this.props.data);
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
FEAASComponent.observedAttributes = ["library", "component", "version", "revision", "hostname", "cdn", "template", "data"];
|
|
1497
|
-
FEAASComponent.register("feaas-component");
|
|
1498
|
-
export {
|
|
1499
|
-
FEAASComponent,
|
|
1500
|
-
FEAASComponentsProps,
|
|
1501
|
-
FEAASLoader,
|
|
1502
|
-
FEAASLoaderProps,
|
|
1503
|
-
FEAASStylesheet,
|
|
1504
|
-
FEAASStylesheetProps,
|
|
1505
|
-
autoloadScripts,
|
|
1506
|
-
cleanCollectionBit,
|
|
1507
|
-
fetchAndRevalidate,
|
|
1508
|
-
loadScript,
|
|
1509
|
-
normalizeCollectionScope,
|
|
1510
|
-
observeDOMElement,
|
|
1511
|
-
queryScopes,
|
|
1512
|
-
renderComponent,
|
|
1513
|
-
renderComponentElement,
|
|
1514
|
-
renderComponentPromise,
|
|
1515
|
-
renderDOMContent,
|
|
1516
|
-
renderDOMElement,
|
|
1517
|
-
renderStylesheet,
|
|
1518
|
-
renderStylesheetPromise,
|
|
1519
|
-
setDOMAttribute
|
|
1520
|
-
};
|
|
65
|
+
</div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}};S.observedAttributes=["hidden"];S.register("feaas-loader");function z(t=this){var e;return{library:t==null?void 0:t.getContextAttribute("library"),revision:(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:"published",cdn:(t==null?void 0:t.getContextAttribute("cdn"))||(t==null?void 0:t.getContextAttribute("hostname"))}}var T=class extends b{getProps(){return z(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){P(this.props,this.onLoad)}render(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};T.register("feaas-stylesheet");var D;typeof window!="undefined"&&((D=window.FEAASLoading)!==null&&D!==void 0||(window.FEAASLoading=Promise.resolve()));0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASLoader,FEAASLoaderProps,FEAASStylesheet,FEAASStylesheetProps,Loader,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderStylesheet,renderStylesheetPromise,setDOMAttribute});
|
|
66
|
+
//# sourceMappingURL=basic.js.map
|