@embeddable.com/sdk-core 0.1.0 → 0.2.0
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/lib/index.cjs.js +34 -6
- package/lib/index.esm.js +34 -6
- package/lib/index.umd.js +34 -6
- package/package.json +1 -1
- package/scripts/buildTypes.js +3 -1
- package/templates/component.tsx.template +5 -0
package/lib/index.cjs.js
CHANGED
|
@@ -38,13 +38,46 @@ var setValue = function (value, componentId, eventName) {
|
|
|
38
38
|
window.dispatchEvent(event);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
/******************************************************************************
|
|
42
|
+
Copyright (c) Microsoft Corporation.
|
|
43
|
+
|
|
44
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
45
|
+
purpose with or without fee is hereby granted.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
48
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
49
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
50
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
51
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
52
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
53
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
54
|
+
***************************************************************************** */
|
|
55
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
var __assign = function() {
|
|
59
|
+
__assign = Object.assign || function __assign(t) {
|
|
60
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
61
|
+
s = arguments[i];
|
|
62
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
63
|
+
}
|
|
64
|
+
return t;
|
|
65
|
+
};
|
|
66
|
+
return __assign.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
70
|
+
var e = new Error(message);
|
|
71
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
72
|
+
};
|
|
73
|
+
|
|
41
74
|
var embedType = function (typeName, typeConfig) {
|
|
42
75
|
// @ts-ignore
|
|
43
76
|
window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
|
|
44
77
|
// @ts-ignore
|
|
45
78
|
window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
|
|
46
79
|
// @ts-ignore
|
|
47
|
-
window.__EMBEDDABLE__.types[typeName] = typeConfig;
|
|
80
|
+
window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
|
|
48
81
|
};
|
|
49
82
|
|
|
50
83
|
var embedOption = function (typeName, option) {
|
|
@@ -56,11 +89,6 @@ var embedOption = function (typeName, option) {
|
|
|
56
89
|
// @ts-ignore
|
|
57
90
|
window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
|
|
58
91
|
// @ts-ignore
|
|
59
|
-
if (window.__EMBEDDABLE__.types[typeName].toString) {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
option.__proto__.toString = function () { return window.__EMBEDDABLE__.types[typeName].toString(option); };
|
|
62
|
-
}
|
|
63
|
-
// @ts-ignore
|
|
64
92
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
65
93
|
};
|
|
66
94
|
|
package/lib/index.esm.js
CHANGED
|
@@ -36,13 +36,46 @@ var setValue = function (value, componentId, eventName) {
|
|
|
36
36
|
window.dispatchEvent(event);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
/******************************************************************************
|
|
40
|
+
Copyright (c) Microsoft Corporation.
|
|
41
|
+
|
|
42
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
43
|
+
purpose with or without fee is hereby granted.
|
|
44
|
+
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
46
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
47
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
48
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
49
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
50
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
51
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
52
|
+
***************************************************************************** */
|
|
53
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var __assign = function() {
|
|
57
|
+
__assign = Object.assign || function __assign(t) {
|
|
58
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
59
|
+
s = arguments[i];
|
|
60
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
};
|
|
64
|
+
return __assign.apply(this, arguments);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
68
|
+
var e = new Error(message);
|
|
69
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
70
|
+
};
|
|
71
|
+
|
|
39
72
|
var embedType = function (typeName, typeConfig) {
|
|
40
73
|
// @ts-ignore
|
|
41
74
|
window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
|
|
42
75
|
// @ts-ignore
|
|
43
76
|
window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
|
|
44
77
|
// @ts-ignore
|
|
45
|
-
window.__EMBEDDABLE__.types[typeName] = typeConfig;
|
|
78
|
+
window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
|
|
46
79
|
};
|
|
47
80
|
|
|
48
81
|
var embedOption = function (typeName, option) {
|
|
@@ -54,11 +87,6 @@ var embedOption = function (typeName, option) {
|
|
|
54
87
|
// @ts-ignore
|
|
55
88
|
window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
|
|
56
89
|
// @ts-ignore
|
|
57
|
-
if (window.__EMBEDDABLE__.types[typeName].toString) {
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
option.__proto__.toString = function () { return window.__EMBEDDABLE__.types[typeName].toString(option); };
|
|
60
|
-
}
|
|
61
|
-
// @ts-ignore
|
|
62
90
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
63
91
|
};
|
|
64
92
|
|
package/lib/index.umd.js
CHANGED
|
@@ -40,13 +40,46 @@
|
|
|
40
40
|
window.dispatchEvent(event);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
/******************************************************************************
|
|
44
|
+
Copyright (c) Microsoft Corporation.
|
|
45
|
+
|
|
46
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
47
|
+
purpose with or without fee is hereby granted.
|
|
48
|
+
|
|
49
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
50
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
51
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
52
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
53
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
54
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
55
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
56
|
+
***************************************************************************** */
|
|
57
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var __assign = function() {
|
|
61
|
+
__assign = Object.assign || function __assign(t) {
|
|
62
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
63
|
+
s = arguments[i];
|
|
64
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
65
|
+
}
|
|
66
|
+
return t;
|
|
67
|
+
};
|
|
68
|
+
return __assign.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
72
|
+
var e = new Error(message);
|
|
73
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
74
|
+
};
|
|
75
|
+
|
|
43
76
|
var embedType = function (typeName, typeConfig) {
|
|
44
77
|
// @ts-ignore
|
|
45
78
|
window.__EMBEDDABLE__ = window.__EMBEDDABLE__ || {};
|
|
46
79
|
// @ts-ignore
|
|
47
80
|
window.__EMBEDDABLE__.types = window.__EMBEDDABLE__.types || {};
|
|
48
81
|
// @ts-ignore
|
|
49
|
-
window.__EMBEDDABLE__.types[typeName] = typeConfig;
|
|
82
|
+
window.__EMBEDDABLE__.types[typeName] = __assign({ name: typeName }, typeConfig);
|
|
50
83
|
};
|
|
51
84
|
|
|
52
85
|
var embedOption = function (typeName, option) {
|
|
@@ -58,11 +91,6 @@
|
|
|
58
91
|
// @ts-ignore
|
|
59
92
|
window.__EMBEDDABLE__.types[typeName].options = window.__EMBEDDABLE__.types[typeName].options || [];
|
|
60
93
|
// @ts-ignore
|
|
61
|
-
if (window.__EMBEDDABLE__.types[typeName].toString) {
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
option.__proto__.toString = function () { return window.__EMBEDDABLE__.types[typeName].toString(option); };
|
|
64
|
-
}
|
|
65
|
-
// @ts-ignore
|
|
66
94
|
window.__EMBEDDABLE__.types[typeName].options.push(option);
|
|
67
95
|
};
|
|
68
96
|
|
package/package.json
CHANGED
package/scripts/buildTypes.js
CHANGED
|
@@ -6,6 +6,7 @@ const { findEmbFiles } = require("./findEmbFiles");
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
const EMB_TYPE_FILE_REGEX = /^(.*)\.type\.emb\.[jt]s$/;
|
|
9
|
+
const EMB_OPTIONS_FILE_REGEX = /^(.*)\.options\.emb\.[jt]s$/;
|
|
9
10
|
|
|
10
11
|
async function buildTypes(ctx) {
|
|
11
12
|
await generate(ctx);
|
|
@@ -20,8 +21,9 @@ module.exports = { buildTypes };
|
|
|
20
21
|
|
|
21
22
|
async function generate(ctx) {
|
|
22
23
|
const typeFiles = await findEmbFiles(ctx.client.srcDir, EMB_TYPE_FILE_REGEX);
|
|
24
|
+
const optionsFiles = await findEmbFiles(ctx.client.srcDir, EMB_OPTIONS_FILE_REGEX);
|
|
23
25
|
|
|
24
|
-
const typeImports = typeFiles.map(([fileName, filePath]) =>
|
|
26
|
+
const typeImports = typeFiles.concat(optionsFiles).map(([fileName, filePath]) =>
|
|
25
27
|
`import './${path.relative(ctx.client.rootDir, filePath)}';`
|
|
26
28
|
).join('\n');
|
|
27
29
|
|