@cesdk/cesdk-js 1.60.0-rc.0 → 1.60.0-rc.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.60.0-rc.0",
3
+ "version": "1.60.0-rc.1",
4
4
  "module": "./index.js",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -11,14 +11,22 @@
11
11
  "module": "./index.js"
12
12
  },
13
13
  "./react": {
14
- "types": "./integrations/react.d.ts",
15
- "import": "./integrations/react.js",
16
- "module": "./integrations/react.js"
14
+ "types": "./react/index.d.ts",
15
+ "import": "./react/index.js",
16
+ "module": "./react/index.js",
17
+ "default": "./react/index.js"
17
18
  },
18
19
  "./vue": {
19
- "types": "./integrations/vue.d.ts",
20
- "import": "./integrations/vue.js",
21
- "module": "./integrations/vue.js"
20
+ "types": "./vue/index.d.ts",
21
+ "import": "./vue/index.js",
22
+ "module": "./vue/index.js",
23
+ "default": "./vue/index.js"
24
+ },
25
+ "./angular": {
26
+ "types": "./angular/index.d.ts",
27
+ "import": "./angular/index.js",
28
+ "module": "./angular/index.js",
29
+ "default": "./angular/index.js"
22
30
  }
23
31
  },
24
32
  "homepage": "https://www.img.ly",
@@ -26,13 +34,21 @@
26
34
  "license": "SEE LICENSE IN LICENSE.md",
27
35
  "readme": "README.md",
28
36
  "dependencies": {
29
- "@cesdk/engine": "1.60.0-rc.0"
37
+ "@cesdk/engine": "1.60.0-rc.1"
30
38
  },
31
39
  "peerDependencies": {
40
+ "@angular/common": ">=14.0.0",
41
+ "@angular/core": ">=14.0.0",
32
42
  "react": ">16",
33
43
  "vue": "^3.0.0"
34
44
  },
35
45
  "peerDependenciesMeta": {
46
+ "@angular/common": {
47
+ "optional": true
48
+ },
49
+ "@angular/core": {
50
+ "optional": true
51
+ },
36
52
  "react": {
37
53
  "optional": true
38
54
  },
package/vue/index.js ADDED
@@ -0,0 +1 @@
1
+ import{defineComponent as e,h as t,onBeforeUnmount as i,onMounted as a,ref as r,shallowRef as n,watch as o}from"vue";var l=e({name:"CreativeEditor",props:{config:{type:Object,required:!0},init:{type:Function,required:!0},height:{type:[Number,String],default:"100%"},width:{type:[Number,String],default:"100%"},class:{type:String,default:void 0}},emits:{"loading-state-change":e=>["idle","loading","loaded","error"].includes(e),error:e=>e&&"object"==typeof e&&"string"==typeof e.message},setup(e,{emit:l,expose:d,attrs:c}){const s=r(null),u=n(null),g=r("idle");let f=0,p=!1;const v=(e,t)=>{const i={message:e,cause:t};g.value="error",l("loading-state-change","error"),l("error",i)},h=()=>{if(u.value)try{u.value.dispose()}catch(e){p&&v("Error during CreativeEditor cleanup",e)}finally{u.value=null}},y=async()=>{const t=++f,i=s.value;if(i)try{g.value="loading",l("loading-state-change","loading"),(e=>{if(!e||"object"!=typeof e)throw new Error("Configuration must be a valid object")})(e.config),(e=>{if(!e||"function"!=typeof e)throw new Error("Init must be a valid function")})(e.init);const CreativeEditorSDK=(await import("@cesdk/cesdk-js")).default,a=await CreativeEditorSDK.create(i,e.config);if(t!==f||!p){try{a.dispose()}catch{}return}u.value=a,g.value="loaded",l("loading-state-change","loaded");try{await(e.init?.(a))}catch(e){v("Initialization function failed",e)}}catch(e){p&&t===f&&v("Failed to create Creative Editor SDK instance",e)}};return o((()=>e.config),(()=>{s.value&&p&&(h(),y())}),{deep:!0}),o((()=>e.init),(()=>{s.value&&p&&(h(),y())})),a((()=>{p=!0,y()})),i((()=>{p=!1,f++,h()})),d({cesdk:u,loadingState:g,reinitialize:y,dispose:h}),()=>{const i={height:e.height,width:e.width};return t("div",{ref:s,class:e.class,style:i,"data-testid":"creative-editor-container",...c})}}}),d=l;export{l as CreativeEditor,d as default};
@@ -1,171 +0,0 @@
1
- // packages/integrations/vue.ts
2
- import {
3
- defineComponent,
4
- h,
5
- onBeforeUnmount,
6
- onMounted,
7
- ref,
8
- shallowRef,
9
- watch
10
- } from "vue";
11
- var CreativeEditor = defineComponent({
12
- name: "CreativeEditor",
13
- props: {
14
- config: {
15
- type: Object,
16
- required: true
17
- },
18
- init: {
19
- type: Function,
20
- required: true
21
- },
22
- height: {
23
- type: [Number, String],
24
- default: "100%"
25
- },
26
- width: {
27
- type: [Number, String],
28
- default: "100%"
29
- },
30
- class: {
31
- type: String,
32
- default: void 0
33
- }
34
- },
35
- emits: {
36
- "loading-state-change": (state) => {
37
- return ["idle", "loading", "loaded", "error"].includes(state);
38
- },
39
- error: (error) => {
40
- return error && typeof error === "object" && typeof error.message === "string";
41
- }
42
- },
43
- setup(props, { emit, expose, attrs }) {
44
- const cesdkContainer = ref(null);
45
- const cesdkInstance = shallowRef(null);
46
- const loadingState = ref("idle");
47
- let initToken = 0;
48
- let mounted = false;
49
- const handleError = (errorMessage, cause) => {
50
- const editorError = {
51
- message: errorMessage,
52
- cause
53
- };
54
- loadingState.value = "error";
55
- emit("loading-state-change", "error");
56
- emit("error", editorError);
57
- };
58
- const instanceCleanup = () => {
59
- if (cesdkInstance.value) {
60
- try {
61
- cesdkInstance.value.dispose();
62
- } catch (cleanupError) {
63
- if (mounted) {
64
- handleError("Error during CreativeEditor cleanup", cleanupError);
65
- }
66
- } finally {
67
- cesdkInstance.value = null;
68
- }
69
- }
70
- };
71
- const validateConfig = (cfg) => {
72
- if (!cfg || typeof cfg !== "object") {
73
- throw new Error("Configuration must be a valid object");
74
- }
75
- };
76
- const validateInit = (initFn) => {
77
- if (!initFn || typeof initFn !== "function") {
78
- throw new Error("Init must be a valid function");
79
- }
80
- };
81
- const initializeSDK = async () => {
82
- const token = ++initToken;
83
- const element = cesdkContainer.value;
84
- if (!element) {
85
- return;
86
- }
87
- try {
88
- loadingState.value = "loading";
89
- emit("loading-state-change", "loading");
90
- validateConfig(props.config);
91
- validateInit(props.init);
92
- const CreativeEditorSDK = (await import("@cesdk/cesdk-js")).default;
93
- const instance = await CreativeEditorSDK.create(element, props.config);
94
- if (token !== initToken || !mounted) {
95
- try {
96
- instance.dispose();
97
- } catch {
98
- }
99
- return;
100
- }
101
- cesdkInstance.value = instance;
102
- loadingState.value = "loaded";
103
- emit("loading-state-change", "loaded");
104
- try {
105
- await props.init?.(instance);
106
- } catch (initError) {
107
- handleError("Initialization function failed", initError);
108
- }
109
- } catch (creationError) {
110
- if (mounted && token === initToken) {
111
- handleError(
112
- "Failed to create Creative Editor SDK instance",
113
- creationError
114
- );
115
- }
116
- }
117
- };
118
- watch(
119
- () => props.config,
120
- () => {
121
- if (cesdkContainer.value && mounted) {
122
- instanceCleanup();
123
- void initializeSDK();
124
- }
125
- },
126
- { deep: true }
127
- );
128
- watch(
129
- () => props.init,
130
- () => {
131
- if (cesdkContainer.value && mounted) {
132
- instanceCleanup();
133
- void initializeSDK();
134
- }
135
- }
136
- );
137
- onMounted(() => {
138
- mounted = true;
139
- void initializeSDK();
140
- });
141
- onBeforeUnmount(() => {
142
- mounted = false;
143
- initToken++;
144
- instanceCleanup();
145
- });
146
- expose({
147
- cesdk: cesdkInstance,
148
- loadingState,
149
- reinitialize: initializeSDK,
150
- dispose: instanceCleanup
151
- });
152
- return () => {
153
- const containerStyle = {
154
- height: props.height,
155
- width: props.width
156
- };
157
- return h("div", {
158
- ref: cesdkContainer,
159
- class: props.class,
160
- style: containerStyle,
161
- "data-testid": "creative-editor-container",
162
- ...attrs
163
- });
164
- };
165
- }
166
- });
167
- var vue_default = CreativeEditor;
168
- export {
169
- CreativeEditor,
170
- vue_default as default
171
- };
File without changes
File without changes
File without changes