@lowdefy/operators 3.23.2 → 4.0.0-alpha.6

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.
Files changed (71) hide show
  1. package/dist/getFromArray.js +22 -44
  2. package/dist/getFromObject.js +25 -70
  3. package/dist/index.js +18 -20
  4. package/dist/nodeParser.js +83 -146
  5. package/dist/runClass.js +57 -82
  6. package/dist/runInstance.js +60 -84
  7. package/dist/webParser.js +94 -157
  8. package/package.json +13 -19
  9. package/dist/common/_index.js +0 -45
  10. package/dist/common/and.js +0 -39
  11. package/dist/common/args.js +0 -46
  12. package/dist/common/array.js +0 -170
  13. package/dist/common/change_case.js +0 -185
  14. package/dist/common/date.js +0 -75
  15. package/dist/common/divide.js +0 -51
  16. package/dist/common/eq.js +0 -43
  17. package/dist/common/event.js +0 -46
  18. package/dist/common/function.js +0 -78
  19. package/dist/common/get.js +0 -61
  20. package/dist/common/global.js +0 -50
  21. package/dist/common/gt.js +0 -43
  22. package/dist/common/gte.js +0 -43
  23. package/dist/common/if.js +0 -41
  24. package/dist/common/if_none.js +0 -47
  25. package/dist/common/index.js +0 -69
  26. package/dist/common/input.js +0 -50
  27. package/dist/common/json.js +0 -64
  28. package/dist/common/log.js +0 -33
  29. package/dist/common/lt.js +0 -43
  30. package/dist/common/lte.js +0 -43
  31. package/dist/common/math.js +0 -210
  32. package/dist/common/mql.js +0 -124
  33. package/dist/common/ne.js +0 -43
  34. package/dist/common/not.js +0 -31
  35. package/dist/common/number.js +0 -125
  36. package/dist/common/nunjucks.js +0 -60
  37. package/dist/common/object.js +0 -118
  38. package/dist/common/operator.js +0 -49
  39. package/dist/common/or.js +0 -39
  40. package/dist/common/product.js +0 -45
  41. package/dist/common/random.js +0 -132
  42. package/dist/common/regex.js +0 -65
  43. package/dist/common/state.js +0 -50
  44. package/dist/common/string.js +0 -188
  45. package/dist/common/subtract.js +0 -47
  46. package/dist/common/sum.js +0 -45
  47. package/dist/common/switch.js +0 -49
  48. package/dist/common/type.js +0 -82
  49. package/dist/common/uri.js +0 -67
  50. package/dist/common/url_query.js +0 -50
  51. package/dist/common/user.js +0 -50
  52. package/dist/common/uuid.js +0 -76
  53. package/dist/common/yaml.js +0 -70
  54. package/dist/getFromOtherContext.js +0 -96
  55. package/dist/node/base64.js +0 -69
  56. package/dist/node/diff.js +0 -66
  57. package/dist/node/hash.js +0 -100
  58. package/dist/node/index.js +0 -29
  59. package/dist/node/secret.js +0 -54
  60. package/dist/web/actions.js +0 -46
  61. package/dist/web/base64.js +0 -67
  62. package/dist/web/event_log.js +0 -50
  63. package/dist/web/format.js +0 -52
  64. package/dist/web/index.js +0 -36
  65. package/dist/web/js.js +0 -45
  66. package/dist/web/list_contexts.js +0 -31
  67. package/dist/web/location.js +0 -74
  68. package/dist/web/media.js +0 -90
  69. package/dist/web/menu.js +0 -43
  70. package/dist/web/request.js +0 -56
  71. package/dist/web/request_details.js +0 -50
package/dist/node/hash.js DELETED
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _crypto = _interopRequireDefault(require("crypto"));
9
-
10
- var _runClass = _interopRequireDefault(require("../runClass"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /*
15
- Copyright 2020-2021 Lowdefy, Inc
16
-
17
- Licensed under the Apache License, Version 2.0 (the "License");
18
- you may not use this file except in compliance with the License.
19
- You may obtain a copy of the License at
20
-
21
- http://www.apache.org/licenses/LICENSE-2.0
22
-
23
- Unless required by applicable law or agreed to in writing, software
24
- distributed under the License is distributed on an "AS IS" BASIS,
25
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- See the License for the specific language governing permissions and
27
- limitations under the License.
28
- */
29
- function hash(algorithm, data) {
30
- return _crypto.default.createHash(algorithm).update(data).digest('hex');
31
- }
32
-
33
- function md5(data) {
34
- return hash('md5', data);
35
- }
36
-
37
- function sha1(data) {
38
- return hash('sha1', data);
39
- }
40
-
41
- function sha256(data) {
42
- return hash('sha256', data);
43
- }
44
-
45
- function sha512(data) {
46
- return hash('sha512', data);
47
- }
48
-
49
- function ripemd160(data) {
50
- return hash('ripemd160', data);
51
- }
52
-
53
- var functions = {
54
- md5,
55
- sha1,
56
- sha256,
57
- sha512,
58
- ripemd160
59
- };
60
- var meta = {
61
- md5: {
62
- validTypes: ['string'],
63
- singleArg: true
64
- },
65
- sha1: {
66
- validTypes: ['string'],
67
- singleArg: true
68
- },
69
- sha256: {
70
- validTypes: ['string'],
71
- singleArg: true
72
- },
73
- sha512: {
74
- validTypes: ['string'],
75
- singleArg: true
76
- },
77
- ripemd160: {
78
- validTypes: ['string'],
79
- singleArg: true
80
- }
81
- };
82
-
83
- function _hash(_ref) {
84
- var {
85
- params,
86
- location,
87
- methodName
88
- } = _ref;
89
- return (0, _runClass.default)({
90
- functions,
91
- location,
92
- meta,
93
- methodName,
94
- operator: '_hash',
95
- params
96
- });
97
- }
98
-
99
- var _default = _hash;
100
- exports.default = _default;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /*
9
- Copyright 2020-2021 Lowdefy, Inc
10
-
11
- Licensed under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License.
13
- You may obtain a copy of the License at
14
-
15
- http://www.apache.org/licenses/LICENSE-2.0
16
-
17
- Unless required by applicable law or agreed to in writing, software
18
- distributed under the License is distributed on an "AS IS" BASIS,
19
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- See the License for the specific language governing permissions and
21
- limitations under the License.
22
- */
23
- var _default = {
24
- _diff: 'node/diff',
25
- _base64: 'node/base64',
26
- _secret: 'node/secret',
27
- _hash: 'node/hash'
28
- };
29
- exports.default = _default;
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- var _excluded = ["OPENID_CLIENT_SECRET", "JWT_SECRET"];
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
-
22
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
-
24
- function _secret(_ref) {
25
- var {
26
- env,
27
- location,
28
- params,
29
- secrets = {}
30
- } = _ref;
31
-
32
- if (params === true || params.all) {
33
- throw new Error("Operator Error: Getting all secrets is not allowed. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
34
- } // Filter out OpenID Connect and JSON web token secrets
35
- // eslint-disable-next-line no-unused-vars
36
-
37
-
38
- var {
39
- OPENID_CLIENT_SECRET,
40
- JWT_SECRET
41
- } = secrets,
42
- rest = _objectWithoutProperties(secrets, _excluded);
43
-
44
- return (0, _getFromObject.default)({
45
- env,
46
- location,
47
- object: _objectSpread({}, rest),
48
- operator: '_secret',
49
- params
50
- });
51
- }
52
-
53
- var _default = _secret;
54
- exports.default = _default;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- function _actions(_ref) {
28
- var {
29
- actions,
30
- arrayIndices,
31
- env,
32
- location,
33
- params
34
- } = _ref;
35
- return (0, _getFromObject.default)({
36
- arrayIndices,
37
- env,
38
- location,
39
- object: actions,
40
- operator: '_actions',
41
- params
42
- });
43
- }
44
-
45
- var _default = _actions;
46
- exports.default = _default;
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _runClass = _interopRequireDefault(require("../runClass"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- function decode(input) {
28
- return atob(input);
29
- }
30
-
31
- function encode(input) {
32
- return btoa(input);
33
- }
34
-
35
- var functions = {
36
- encode,
37
- decode
38
- };
39
- var meta = {
40
- encode: {
41
- singleArg: true,
42
- validTypes: ['string']
43
- },
44
- decode: {
45
- singleArg: true,
46
- validTypes: ['string']
47
- }
48
- };
49
-
50
- function _base64(_ref) {
51
- var {
52
- params,
53
- location,
54
- methodName
55
- } = _ref;
56
- return (0, _runClass.default)({
57
- functions,
58
- location,
59
- meta,
60
- methodName,
61
- operator: '_base64',
62
- params
63
- });
64
- }
65
-
66
- var _default = _base64;
67
- exports.default = _default;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- function _event_log(_ref) {
28
- var {
29
- params,
30
- eventLog,
31
- context,
32
- contexts,
33
- arrayIndices,
34
- location,
35
- env
36
- } = _ref;
37
- return (0, _getFromObject.default)({
38
- arrayIndices,
39
- context,
40
- contexts,
41
- env,
42
- location,
43
- object: eventLog,
44
- operator: '_event_log',
45
- params
46
- });
47
- }
48
-
49
- var _default = _event_log;
50
- exports.default = _default;
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
- var _format2 = _interopRequireDefault(require("@lowdefy/format"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /*
15
- Copyright 2020-2021 Lowdefy, Inc
16
-
17
- Licensed under the Apache License, Version 2.0 (the "License");
18
- you may not use this file except in compliance with the License.
19
- You may obtain a copy of the License at
20
-
21
- http://www.apache.org/licenses/LICENSE-2.0
22
-
23
- Unless required by applicable law or agreed to in writing, software
24
- distributed under the License is distributed on an "AS IS" BASIS,
25
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
- See the License for the specific language governing permissions and
27
- limitations under the License.
28
- */
29
- function _format(_ref) {
30
- var {
31
- location,
32
- methodName,
33
- params
34
- } = _ref;
35
-
36
- if (!_format2.default[methodName]) {
37
- throw new Error("Operator Error: $_format.".concat(methodName, " is not supported, use one of the following: ").concat(Object.keys(_format2.default).join(', '), ".\n Received: {\"_format.").concat(methodName, "\":").concat(JSON.stringify(params), "} at ").concat(location, "."));
38
- }
39
-
40
- if (!_helpers.type.isObject(params)) {
41
- throw new Error("Operator Error: _format takes an object as arguments. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
42
- }
43
-
44
- if (!_helpers.type.isObject(params.params) && !_helpers.type.isUndefined(params.params)) {
45
- throw new Error("Operator Error: _format params argument should be an object or undefined. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
46
- }
47
-
48
- return _format2.default[methodName](params.params)(params.on);
49
- }
50
-
51
- var _default = _format;
52
- exports.default = _default;
package/dist/web/index.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /*
9
- Copyright 2020-2021 Lowdefy, Inc
10
-
11
- Licensed under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License.
13
- You may obtain a copy of the License at
14
-
15
- http://www.apache.org/licenses/LICENSE-2.0
16
-
17
- Unless required by applicable law or agreed to in writing, software
18
- distributed under the License is distributed on an "AS IS" BASIS,
19
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- See the License for the specific language governing permissions and
21
- limitations under the License.
22
- */
23
- var _default = {
24
- _actions: 'web/actions',
25
- _event_log: 'web/event_log',
26
- _base64: 'web/base64',
27
- _format: 'web/format',
28
- _list_contexts: 'web/list_contexts',
29
- _location: 'web/location',
30
- _js: 'web/js',
31
- _media: 'web/media',
32
- _menu: 'web/menu',
33
- _request_details: 'web/request_details',
34
- _request: 'web/request'
35
- };
36
- exports.default = _default;
package/dist/web/js.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
- /*
11
- Copyright 2020-2021 Lowdefy, Inc
12
-
13
- Licensed under the Apache License, Version 2.0 (the "License");
14
- you may not use this file except in compliance with the License.
15
- You may obtain a copy of the License at
16
-
17
- http://www.apache.org/licenses/LICENSE-2.0
18
-
19
- Unless required by applicable law or agreed to in writing, software
20
- distributed under the License is distributed on an "AS IS" BASIS,
21
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- See the License for the specific language governing permissions and
23
- limitations under the License.
24
- */
25
- function _js(_ref) {
26
- var {
27
- context,
28
- params,
29
- location,
30
- methodName
31
- } = _ref;
32
-
33
- if (!_helpers.type.isFunction(context.lowdefy.imports.jsOperators[methodName])) {
34
- throw new Error("Operator Error: _js.".concat(methodName, " is not a function."));
35
- }
36
-
37
- if (!_helpers.type.isNone(params) && !_helpers.type.isArray(params)) {
38
- throw new Error("Operator Error: _js.".concat(methodName, " takes an array as input at ").concat(location, "."));
39
- }
40
-
41
- return context.lowdefy.imports.jsOperators[methodName](...(params || []));
42
- }
43
-
44
- var _default = _js;
45
- exports.default = _default;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /*
9
- Copyright 2020-2021 Lowdefy, Inc
10
-
11
- Licensed under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License.
13
- You may obtain a copy of the License at
14
-
15
- http://www.apache.org/licenses/LICENSE-2.0
16
-
17
- Unless required by applicable law or agreed to in writing, software
18
- distributed under the License is distributed on an "AS IS" BASIS,
19
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- See the License for the specific language governing permissions and
21
- limitations under the License.
22
- */
23
- function _list_contexts(_ref) {
24
- var {
25
- contexts
26
- } = _ref;
27
- return Object.keys(contexts).sort();
28
- }
29
-
30
- var _default = _list_contexts;
31
- exports.default = _default;
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- var validProperties = ['basePath', 'href', 'origin', 'protocol', 'homePageId', 'host', 'hostname', 'port', 'pageId', 'pathname', 'search', 'hash'];
28
-
29
- function _location(_ref) {
30
- var {
31
- arrayIndices,
32
- context,
33
- contexts,
34
- env,
35
- location,
36
- params
37
- } = _ref;
38
-
39
- if (!window || !window.location) {
40
- throw new Error("Operator Error: Browser window.location not available for _location. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
41
- }
42
-
43
- if (!validProperties.includes(params)) {
44
- throw new Error("Operator Error: _location only returns values for ".concat(validProperties.join(', '), ". Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
45
- }
46
-
47
- var windowLocation = {
48
- basePath: context.lowdefy.basePath,
49
- href: window.location.href,
50
- origin: window.location.origin,
51
- protocol: window.location.protocol,
52
- homePageId: context.lowdefy.homePageId,
53
- host: window.location.host,
54
- hostname: window.location.hostname,
55
- port: window.location.port,
56
- pageId: context.lowdefy.pageId,
57
- pathname: window.location.pathname,
58
- search: window.location.search,
59
- hash: window.location.hash
60
- };
61
- return (0, _getFromObject.default)({
62
- arrayIndices,
63
- context,
64
- contexts,
65
- env,
66
- location,
67
- object: windowLocation,
68
- operator: '_location',
69
- params
70
- });
71
- }
72
-
73
- var _default = _location;
74
- exports.default = _default;
package/dist/web/media.js DELETED
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.breakpoints = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- /*
13
- Copyright 2020-2021 Lowdefy, Inc
14
-
15
- Licensed under the Apache License, Version 2.0 (the "License");
16
- you may not use this file except in compliance with the License.
17
- You may obtain a copy of the License at
18
-
19
- http://www.apache.org/licenses/LICENSE-2.0
20
-
21
- Unless required by applicable law or agreed to in writing, software
22
- distributed under the License is distributed on an "AS IS" BASIS,
23
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
- See the License for the specific language governing permissions and
25
- limitations under the License.
26
- */
27
- var breakpoints = [576, 768, 992, 1200, 1600];
28
- exports.breakpoints = breakpoints;
29
-
30
- function _media(_ref) {
31
- var {
32
- arrayIndices,
33
- context,
34
- contexts,
35
- env,
36
- location,
37
- params
38
- } = _ref;
39
-
40
- if (!window || !window.innerWidth) {
41
- throw new Error("Operator Error: device window width not available for _media. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
42
- }
43
-
44
- var size;
45
-
46
- switch (true) {
47
- case window.innerWidth < breakpoints[0]:
48
- size = 'xs';
49
- break;
50
-
51
- case window.innerWidth < breakpoints[1]:
52
- size = 'sm';
53
- break;
54
-
55
- case window.innerWidth < breakpoints[2]:
56
- size = 'md';
57
- break;
58
-
59
- case window.innerWidth < breakpoints[3]:
60
- size = 'lg';
61
- break;
62
-
63
- case window.innerWidth < breakpoints[4]:
64
- size = 'xl';
65
- break;
66
-
67
- default:
68
- size = 'xxl';
69
- break;
70
- }
71
-
72
- var media = {
73
- size,
74
- width: window.innerWidth,
75
- height: window.innerHeight
76
- };
77
- return (0, _getFromObject.default)({
78
- arrayIndices,
79
- context,
80
- contexts,
81
- env,
82
- location,
83
- object: media,
84
- operator: '_media',
85
- params
86
- });
87
- }
88
-
89
- var _default = _media;
90
- exports.default = _default;