@embeddable.com/sdk-react 0.0.13 → 0.0.15
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/package.json +8 -2
- package/.turbo/turbo-build.log +0 -13
- package/CHANGELOG.md +0 -89
- package/rollup.config.mjs +0 -36
- package/src/embedComponent.tsx +0 -40
- package/src/embedEditor.tsx +0 -57
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embeddable.com/sdk-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Embeddable SDK React plugin/module responsible for React components bundling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"embeddable",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"embeddable-react": "bin/embeddable-react"
|
|
24
24
|
},
|
|
25
25
|
"author": "Oleg Kapustin <oleg@trevor.io>",
|
|
26
|
+
"files": [
|
|
27
|
+
"lib/",
|
|
28
|
+
"scripts/",
|
|
29
|
+
"templates/"
|
|
30
|
+
],
|
|
26
31
|
"license": "MIT",
|
|
27
32
|
"peerDependencies": {
|
|
28
33
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
@@ -34,6 +39,7 @@
|
|
|
34
39
|
"dependencies": {
|
|
35
40
|
"@embeddable.com/sdk-core": "*",
|
|
36
41
|
"@vitejs/plugin-react": "^4.0.2",
|
|
37
|
-
"vite": "^4.4.2"
|
|
42
|
+
"vite": "^4.4.2",
|
|
43
|
+
"ora": "^6.3.1"
|
|
38
44
|
}
|
|
39
45
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @embeddable.com/sdk-react@0.0.13 build
|
|
3
|
-
> rollup -c
|
|
4
|
-
|
|
5
|
-
(node:1876) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
|
|
6
|
-
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
7
|
-
(node:1876) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
|
|
8
|
-
[36m
|
|
9
|
-
[1m./src/index.ts[22m → [1mlib/index.umd.js[22m...[39m
|
|
10
|
-
[32mcreated [1mlib/index.umd.js[22m in [1m2.8s[22m[39m
|
|
11
|
-
[36m
|
|
12
|
-
[1m./src/index.ts[22m → [1mlib/index.cjs.js, lib/index.esm.js[22m...[39m
|
|
13
|
-
[32mcreated [1mlib/index.cjs.js, lib/index.esm.js[22m in [1m1.7s[22m[39m
|
package/CHANGELOG.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# @embeddable.com/sdk-react
|
|
2
|
-
|
|
3
|
-
## 0.0.13
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 1137dbd: Fix import.
|
|
8
|
-
|
|
9
|
-
## 0.0.12
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- c8791d9: Improve publishing.
|
|
14
|
-
- Updated dependencies [c8791d9]
|
|
15
|
-
- @embeddable.com/sdk-core@0.0.10
|
|
16
|
-
|
|
17
|
-
## 0.0.11
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- 9d238b4: Fix loadData.
|
|
22
|
-
- Updated dependencies [9d238b4]
|
|
23
|
-
- @embeddable.com/sdk-core@0.0.7
|
|
24
|
-
|
|
25
|
-
## 0.0.10
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- 46f8ccb: Fix import.
|
|
30
|
-
- Updated dependencies [46f8ccb]
|
|
31
|
-
- @embeddable.com/sdk-core@0.0.6
|
|
32
|
-
|
|
33
|
-
## 0.0.9
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- 124ff74: Move loadData to core. Add axios.
|
|
38
|
-
- Updated dependencies [124ff74]
|
|
39
|
-
- @embeddable.com/sdk-core@0.0.5
|
|
40
|
-
|
|
41
|
-
## 0.0.8
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- ce832b1: Add package description and keywords.
|
|
46
|
-
- Updated dependencies [ce832b1]
|
|
47
|
-
- @embeddable.com/sdk-core@0.0.3
|
|
48
|
-
|
|
49
|
-
## 0.0.7
|
|
50
|
-
|
|
51
|
-
### Patch Changes
|
|
52
|
-
|
|
53
|
-
- 8a627a6: Adjust cli messages.
|
|
54
|
-
|
|
55
|
-
## 0.0.6
|
|
56
|
-
|
|
57
|
-
### Patch Changes
|
|
58
|
-
|
|
59
|
-
- Move generate back to child process.
|
|
60
|
-
|
|
61
|
-
## 0.0.5
|
|
62
|
-
|
|
63
|
-
### Patch Changes
|
|
64
|
-
|
|
65
|
-
- Fix core import.
|
|
66
|
-
|
|
67
|
-
## 0.0.4
|
|
68
|
-
|
|
69
|
-
### Patch Changes
|
|
70
|
-
|
|
71
|
-
- Run generate in the main thread.
|
|
72
|
-
|
|
73
|
-
## 0.0.3
|
|
74
|
-
|
|
75
|
-
### Patch Changes
|
|
76
|
-
|
|
77
|
-
- Add child process error log.
|
|
78
|
-
|
|
79
|
-
## 0.0.2
|
|
80
|
-
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
- Fix sdk-core dependency.
|
|
84
|
-
|
|
85
|
-
## 0.0.1
|
|
86
|
-
|
|
87
|
-
### Patch Changes
|
|
88
|
-
|
|
89
|
-
- First publish attempt.
|
package/rollup.config.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import typescript from '@rollup/plugin-typescript';
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
-
import replace from '@rollup/plugin-replace';
|
|
5
|
-
import pkg from './package.json' assert { type: 'json' };
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
input: './src/index.ts',
|
|
10
|
-
output: {
|
|
11
|
-
name: 'embeddableSdkReact',
|
|
12
|
-
file: pkg.browser,
|
|
13
|
-
format: 'umd'
|
|
14
|
-
},
|
|
15
|
-
plugins: [
|
|
16
|
-
replace({
|
|
17
|
-
preventAssignment: true,
|
|
18
|
-
values: {
|
|
19
|
-
'process.env.NODE_ENV': JSON.stringify('production')
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
resolve(),
|
|
23
|
-
commonjs(),
|
|
24
|
-
typescript()
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
input: './src/index.ts',
|
|
29
|
-
external: Object.keys(pkg.peerDependencies),
|
|
30
|
-
output: [
|
|
31
|
-
{ file: pkg.main, format: 'cjs' },
|
|
32
|
-
{ file: pkg.module, format: 'es' }
|
|
33
|
-
],
|
|
34
|
-
plugins: [typescript()]
|
|
35
|
-
}
|
|
36
|
-
]
|
package/src/embedComponent.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
type WrapperProps = {
|
|
4
|
-
propsUpdateListener: HTMLElement
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const EVENT_NAME = 'embeddable-event:update-props';
|
|
8
|
-
|
|
9
|
-
// TODO: define config type.
|
|
10
|
-
export type Config = {
|
|
11
|
-
extendedProps?: (props: any) => any
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function embedComponent(InnerComponent: React.ComponentType, config: Config) {
|
|
15
|
-
function EmbeddableWrapper({propsUpdateListener, ...props}: WrapperProps) {
|
|
16
|
-
const [propsProxy, setProps] = React.useState(props);
|
|
17
|
-
|
|
18
|
-
const propsUpdateEventHandler = ({ detail }: CustomEvent<typeof propsProxy>) => setProps(detail);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
propsUpdateListener.addEventListener(EVENT_NAME, propsUpdateEventHandler);
|
|
23
|
-
|
|
24
|
-
return () => propsUpdateListener.removeEventListener(EVENT_NAME, propsUpdateEventHandler);
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const extendedProps = React.useMemo(
|
|
29
|
-
() => config?.extendedProps?.(propsProxy),
|
|
30
|
-
[propsProxy, config?.extendedProps]
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return <InnerComponent {...propsProxy} {...extendedProps}/>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
EmbeddableWrapper.displayName = `embedded(${InnerComponent.displayName ?? 'Component'})`;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return EmbeddableWrapper;
|
|
40
|
-
}
|
package/src/embedEditor.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export type Config<T> = {
|
|
4
|
-
inputs: any;
|
|
5
|
-
events: Record<string, EmbeddableEventHandler<T>>
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type EmbeddableEventHandler<T> = (value: T, setter: Setter<T>) => void;
|
|
9
|
-
|
|
10
|
-
export type EmbeddableEvent<T> = {
|
|
11
|
-
editorId: string;
|
|
12
|
-
value: T;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type Setter<T> = (value: T) => void;
|
|
16
|
-
|
|
17
|
-
const EVENT_NAME = "embeddable:editor:changed";
|
|
18
|
-
|
|
19
|
-
export function embedEditor<T>(InnerComponent: React.ComponentType, config: Config<T>) {
|
|
20
|
-
|
|
21
|
-
function EmbeddableWrapper({editorId, initialValue}) {
|
|
22
|
-
|
|
23
|
-
const [componentState, setComponentState] = React.useState(initialValue);
|
|
24
|
-
|
|
25
|
-
const createEvent = (value: T) => {
|
|
26
|
-
|
|
27
|
-
const event = new CustomEvent<EmbeddableEvent<T>>(EVENT_NAME, {
|
|
28
|
-
bubbles: false,
|
|
29
|
-
detail: {
|
|
30
|
-
editorId,
|
|
31
|
-
value
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
window.dispatchEvent(event);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const events = config.events;
|
|
38
|
-
const eventProps: Record<string, (value: T) => void> = {};
|
|
39
|
-
|
|
40
|
-
for (const event in events) {
|
|
41
|
-
if (events.hasOwnProperty(event)) {
|
|
42
|
-
let eventFunction = events[event];
|
|
43
|
-
eventProps[event] = (value: T) => {
|
|
44
|
-
eventFunction(value, setComponentState)
|
|
45
|
-
createEvent(value)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return <InnerComponent {...eventProps} {...config.inputs(componentState)} />;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
EmbeddableWrapper.displayName = `embedded(${InnerComponent.displayName ?? 'Editor'})`;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return EmbeddableWrapper;
|
|
57
|
-
}
|
package/src/index.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["src/**/*"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"target": "es5",
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"outDir": "lib",
|
|
10
|
-
"lib": [
|
|
11
|
-
"DOM",
|
|
12
|
-
"DOM.Iterable",
|
|
13
|
-
"ESNext"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"exclude": [
|
|
17
|
-
"node_modules",
|
|
18
|
-
"lib"
|
|
19
|
-
]
|
|
20
|
-
}
|