@cesdk/engine 1.68.0-nightly.20260123 → 1.68.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/engine",
3
- "version": "1.68.0-nightly.20260123",
3
+ "version": "1.68.0-rc.0",
4
4
  "main": "./index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -0,0 +1,115 @@
1
+ /// <reference types="react" />
2
+
3
+ import type { Configuration } from '@cesdk/cesdk-js';
4
+ import type CreativeEditorSDK from '@cesdk/cesdk-js';
5
+ import { ForwardRefExoticComponent } from 'react';
6
+ import { RefAttributes } from 'react';
7
+
8
+ /**
9
+ * A production-ready React wrapper for the Creative Editor SDK.
10
+ *
11
+ * Provides a React component with proper error handling, loading state callbacks,
12
+ * and lifecycle management for integrating the Creative Editor SDK. The component
13
+ * handles SDK initialization and cleanup.
14
+ *
15
+ * @example Basic Usage
16
+ * ```tsx
17
+ * import CreativeEditor from '@cesdk/cesdk-js/react';
18
+ *
19
+ * function MyApp() {
20
+ * return (
21
+ * <CreativeEditor
22
+ * config={{
23
+ * licenseKey: 'your-license-key',
24
+ * baseURL: 'https://your-cdn-url/assets',
25
+ * }}
26
+ * init={async (cesdk) => {
27
+ * await cesdk.addDefaultAssetSources();
28
+ * await cesdk.addDemoAssetSources();
29
+ * await cesdk.createDesignScene();
30
+ * }}
31
+ * width="100vw"
32
+ * height="100vh"
33
+ * />
34
+ * );
35
+ * }
36
+ * ```
37
+ *
38
+ * @example With Error Handling
39
+ * ```tsx
40
+ * import CreativeEditor from '@cesdk/cesdk-js/react';
41
+ *
42
+ * function MyApp() {
43
+ * return (
44
+ * <CreativeEditor
45
+ * config={{
46
+ * licenseKey: 'your-license-key',
47
+ * baseURL: 'https://your-cdn-url/assets',
48
+ * }}
49
+ * init={async (cesdk) => {
50
+ * await cesdk.addDefaultAssetSources();
51
+ * await cesdk.addDemoAssetSources();
52
+ * await cesdk.createDesignScene();
53
+ * }}
54
+ * onError={(error) => {
55
+ * console.error('SDK initialization failed:', error);
56
+ * // Handle error (e.g., show notification, retry logic)
57
+ * }}
58
+ * onLoadingStateChange={(state) => {
59
+ * console.log('Loading state changed:', state);
60
+ * }}
61
+ * width="100vw"
62
+ * height="100vh"
63
+ * />
64
+ * );
65
+ * }
66
+ * ```
67
+ * @remarks
68
+ * - The component automatically handles SDK cleanup on unmount
69
+ * - For render-time errors, we recommend using a React Error Boundary
70
+ * @category Framework Wrapper
71
+ * @public
72
+ */
73
+ declare const CreativeEditor: ForwardRefExoticComponent<CreativeEditorProps & RefAttributes<HTMLDivElement>>;
74
+ export { CreativeEditor }
75
+ export default CreativeEditor;
76
+
77
+ /**
78
+ * Error that occurred during Creative Editor SDK initialization.
79
+ * @public
80
+ */
81
+ export declare interface CreativeEditorError {
82
+ /** The error message */
83
+ message: string;
84
+ /** The original error object */
85
+ cause?: unknown;
86
+ }
87
+
88
+ /**
89
+ * Loading state of the Creative Editor SDK.
90
+ * @public
91
+ */
92
+ export declare type CreativeEditorLoadingState = 'idle' | 'loading' | 'loaded' | 'error';
93
+
94
+ /**
95
+ * Props for the CreativeEditor React component.
96
+ * @public
97
+ */
98
+ export declare interface CreativeEditorProps {
99
+ /** Configuration object for the Creative Editor SDK */
100
+ config: Configuration;
101
+ /** Initialization function called after SDK instance is created */
102
+ init?: (cesdk: CreativeEditorSDK) => void | Promise<void>;
103
+ /** Height of the editor container */
104
+ height?: number | string;
105
+ /** Width of the editor container */
106
+ width?: number | string;
107
+ /** CSS class name for the container element */
108
+ className?: string;
109
+ /** Callback fired when loading state changes */
110
+ onLoadingStateChange?: (state: CreativeEditorLoadingState) => void;
111
+ /** Callback fired when an error occurs */
112
+ onError?: (error: CreativeEditorError) => void;
113
+ }
114
+
115
+ export { }
package/react/index.js ADDED
@@ -0,0 +1 @@
1
+ import{createElement as t,forwardRef as r,useCallback as e,useEffect as n,useMemo as i,useRef as a}from"react";function o(...t){return r=>{for(const e of t)"function"==typeof e?e(r):null!=e&&(e.current=r)}}function c(t){const r=a(t);return n((()=>{r.current=t})),i((()=>(...t)=>r.current?.(...t)),[])}var u=r((function({config:r,init:u,height:d="100%",width:l="100%",className:s,onLoadingStateChange:f,onError:h},p){const v=a(null),y=a(null),g=a("idle"),m=c(h),w=c(f),E=a(r).current,C=i((()=>({height:d,width:l})),[d,l]),b=e((t=>{g.current=t,w?.(t)}),[w]),j=e(((t,r)=>{const e={message:t,cause:r};b("error"),m?.(e)}),[m,b]),N=e((()=>{if(y.current)try{y.current.dispose()}catch(t){j("Error during CreativeEditor cleanup",t)}finally{y.current=null,b("idle")}}),[j,b]),k=e((t=>{if(!t||"object"!=typeof t)throw new Error("Configuration must be a valid object")}),[]),I=e((t=>{if(!t||"function"!=typeof t)throw new Error("Init must be a valid function")}),[]);return n((()=>{let t=!0;return(async()=>{const r=v.current;if(r&&"idle"===g.current&&!y.current)try{b("loading"),k(E),I(u);const CreativeEditorSDK=(await import("@cesdk/cesdk-js")).default,e=await CreativeEditorSDK.create(r,E);if(!t)return void e.dispose();y.current=e,b("loaded");try{await(u?.(e))}catch(t){j("Initialization function failed",t)}}catch(r){if(!t)return;j("Failed to create Creative Editor SDK instance",r)}})(),()=>{t=!1,b("idle"),N()}}),[u,k,I,b,j,N,E]),t("div",{ref:o(v,p),style:C,className:s,"data-testid":"creative-editor-container"})}));u.displayName="CreativeEditor";var d=u;export{u as CreativeEditor,d as default};
package/vue/index.d.ts ADDED
@@ -0,0 +1,162 @@
1
+ import type { Configuration } from '@cesdk/cesdk-js';
2
+ import type CreativeEditorSDK from '@cesdk/cesdk-js';
3
+ import { DefineComponent } from 'vue';
4
+ import { PropType } from 'vue';
5
+
6
+ /**
7
+ * A production-ready Vue 3 wrapper for the Creative Editor SDK.
8
+ *
9
+ * Provides a Vue component with proper error handling, loading state events,
10
+ * and lifecycle management for integrating the Creative Editor SDK. The component
11
+ * handles SDK initialization and cleanup using Vue's Composition API.
12
+ *
13
+ * @example Basic Usage
14
+ * ```vue
15
+ * <template>
16
+ * <CreativeEditor
17
+ * :config="{
18
+ * licenseKey: 'your-license-key',
19
+ * baseURL: 'https://your-cdn-url/assets',
20
+ * }"
21
+ * :init="initEditor"
22
+ * width="100vw"
23
+ * height="100vh"
24
+ * />
25
+ * </template>
26
+ *
27
+ * <script setup lang="ts">
28
+ * import CreativeEditor from '@cesdk/cesdk-js/vue';
29
+ *
30
+ * const initEditor = async (cesdk) => {
31
+ * await cesdk.addDefaultAssetSources();
32
+ * await cesdk.addDemoAssetSources();
33
+ * await cesdk.createDesignScene();
34
+ * };
35
+ * </script>
36
+ * ```
37
+ *
38
+ * @example With Error Handling
39
+ * ```vue
40
+ * <template>
41
+ * <CreativeEditor
42
+ * :config="{
43
+ * licenseKey: 'your-license-key',
44
+ * baseURL: 'https://your-cdn-url/assets',
45
+ * }"
46
+ * :init="initEditor"
47
+ * @loading-state-change="onLoadingStateChange"
48
+ * @error="onError"
49
+ * width="100vw"
50
+ * height="100vh"
51
+ * />
52
+ * </template>
53
+ *
54
+ * <script setup lang="ts">
55
+ * import CreativeEditor, {
56
+ * type CreativeEditorError,
57
+ * type CreativeEditorLoadingState
58
+ * } from '@cesdk/cesdk-js/vue';
59
+ *
60
+ * const initEditor = async (cesdk) => {
61
+ * await cesdk.addDefaultAssetSources();
62
+ * await cesdk.addDemoAssetSources();
63
+ * await cesdk.createDesignScene();
64
+ * };
65
+ *
66
+ * const onError = (error: CreativeEditorError) => {
67
+ * console.error('SDK initialization failed:', error);
68
+ * // Handle error (e.g., show notification, retry logic)
69
+ * };
70
+ *
71
+ * const onLoadingStateChange = (state: CreativeEditorLoadingState) => {
72
+ * console.log('Loading state changed:', state);
73
+ * };
74
+ * </script>
75
+ * ```
76
+ *
77
+ * @remarks
78
+ * - The component automatically handles SDK cleanup on unmount
79
+ * - Uses Vue 3 Composition API for optimal performance and TypeScript support
80
+ * - For render-time errors, we recommend using Vue's error handling mechanisms
81
+ * @category Framework Wrapper
82
+ * @public
83
+ */
84
+ declare const CreativeEditor: CreativeEditorComponent;
85
+ export { CreativeEditor }
86
+ export default CreativeEditor;
87
+
88
+ /**
89
+ * Component type for the CreativeEditor Vue component.
90
+ * @public
91
+ * */
92
+ export declare type CreativeEditorComponent = DefineComponent<{
93
+ config: {
94
+ type: PropType<Configuration>;
95
+ required: true;
96
+ };
97
+ init: {
98
+ type: PropType<(cesdk: CreativeEditorSDK) => void | Promise<void>>;
99
+ };
100
+ height: {
101
+ type: PropType<string | number>;
102
+ default: string;
103
+ };
104
+ width: {
105
+ type: PropType<string | number>;
106
+ default: string;
107
+ };
108
+ class: {
109
+ type: StringConstructor;
110
+ default: undefined;
111
+ };
112
+ }, {}, {}, {}, {}, {}, {}, {
113
+ 'loading-state-change': (state: CreativeEditorLoadingState) => void;
114
+ error: (error: CreativeEditorError) => void;
115
+ }>;
116
+
117
+ /**
118
+ * Emits for the CreativeEditor Vue component.
119
+ * @public
120
+ */
121
+ export declare type CreativeEditorEmits = {
122
+ /** Emitted when loading state changes */
123
+ 'loading-state-change': (state: CreativeEditorLoadingState) => void;
124
+ /** Emitted when an error occurs */
125
+ error: (error: CreativeEditorError) => void;
126
+ };
127
+
128
+ /**
129
+ * Error that occurred during Creative Editor SDK initialization.
130
+ * @public
131
+ */
132
+ export declare interface CreativeEditorError {
133
+ /** The error message */
134
+ message: string;
135
+ /** The original error object */
136
+ cause?: unknown;
137
+ }
138
+
139
+ /**
140
+ * Loading state of the Creative Editor SDK.
141
+ * @public
142
+ */
143
+ export declare type CreativeEditorLoadingState = 'idle' | 'loading' | 'loaded' | 'error';
144
+
145
+ /**
146
+ * Props for the CreativeEditor Vue component.
147
+ * @public
148
+ */
149
+ export declare interface CreativeEditorProps {
150
+ /** Configuration object for the Creative Editor SDK */
151
+ config: Configuration;
152
+ /** Initialization function called after SDK instance is created */
153
+ init: (cesdk: CreativeEditorSDK) => void | Promise<void>;
154
+ /** Height of the editor container */
155
+ height?: number | string;
156
+ /** Width of the editor container */
157
+ width?: number | string;
158
+ /** CSS class name for the container element */
159
+ class?: string;
160
+ }
161
+
162
+ export { }
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};