@lightspeed/crane 1.0.3 → 1.1.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/dist/app.d.mts +147 -10
- package/dist/app.d.ts +147 -10
- package/dist/app.mjs +1 -1
- package/dist/cli.mjs +22 -6
- package/package.json +7 -3
- package/template/footers/example-footer/ExampleFooter.vue +51 -0
- package/template/footers/example-footer/assets/example_footer_showcase_1_preview.png +0 -0
- package/template/footers/example-footer/assets/sample_image.jpg +0 -0
- package/template/footers/example-footer/client.ts +5 -0
- package/template/footers/example-footer/component/ReportAbuse.vue +18 -0
- package/template/footers/example-footer/entity/color.ts +4 -0
- package/template/footers/example-footer/server.ts +5 -0
- package/template/footers/example-footer/settings/content.ts +3 -0
- package/template/footers/example-footer/settings/design.ts +11 -0
- package/template/footers/example-footer/settings/translations.ts +12 -0
- package/template/footers/example-footer/showcases/1.ts +13 -0
- package/template/footers/example-footer/showcases/translations.ts +9 -0
- package/template/footers/example-footer/type.ts +5 -0
- package/template/headers/example-header/ExampleHeader.vue +30 -0
- package/template/headers/example-header/assets/cart.svg +20 -0
- package/template/headers/example-header/assets/example_header_showcase_1_preview.png +0 -0
- package/template/headers/example-header/assets/sample_image.jpg +0 -0
- package/template/headers/example-header/assets/search.svg +13 -0
- package/template/headers/example-header/client.ts +5 -0
- package/template/headers/example-header/component/Cart.vue +64 -0
- package/template/headers/example-header/component/SampleComponent.vue +11 -0
- package/template/headers/example-header/component/SearchForm.vue +89 -0
- package/template/headers/example-header/server.ts +5 -0
- package/template/headers/example-header/settings/content.ts +1 -0
- package/template/headers/example-header/settings/design.ts +1 -0
- package/template/headers/example-header/settings/layout.ts +1 -0
- package/template/headers/example-header/settings/translations.ts +5 -0
- package/template/headers/example-header/showcases/1.ts +11 -0
- package/template/headers/example-header/showcases/translations.ts +5 -0
- package/template/headers/example-header/type.ts +5 -0
- package/template/package.json +3 -2
- package/template/sections/example-section/component/image/ImagesGrid.vue +18 -37
- package/template/sections/example-section/settings/content.ts +53 -55
- package/template/sections/example-section/settings/translations.ts +27 -24
- package/template/sections/example-section/showcases/1.ts +143 -103
- package/template/sections/example-section/showcases/2.ts +127 -103
- package/template/sections/example-section/showcases/translations.ts +6 -0
- package/template/templates/template.ts +177 -118
- package/types.d.ts +14 -1
package/dist/app.d.mts
CHANGED
|
@@ -12,6 +12,7 @@ interface AppBaseData<C, D> {
|
|
|
12
12
|
readonly content: C;
|
|
13
13
|
readonly design: D;
|
|
14
14
|
readonly defaults: Record<string, unknown>;
|
|
15
|
+
readonly externalContent: Record<string, unknown>;
|
|
15
16
|
}
|
|
16
17
|
interface AppBaseState<C, D> {
|
|
17
18
|
readonly context: AppBaseContext;
|
|
@@ -19,26 +20,42 @@ interface AppBaseState<C, D> {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
interface VueBaseProps<CONTENT, DESIGN> {
|
|
22
|
-
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
-
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
+
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>, externalContent: Record<string, unknown>) => void;
|
|
24
|
+
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>, externalContent: Record<string, unknown>) => void;
|
|
24
25
|
readonly context: Ref<AppBaseContext>;
|
|
25
26
|
readonly content: Ref<CONTENT>;
|
|
26
27
|
readonly design: Ref<DESIGN>;
|
|
27
28
|
readonly defaults: Ref<Record<string, unknown>>;
|
|
29
|
+
readonly externalContent: Ref<Record<string, unknown>>;
|
|
28
30
|
}
|
|
29
31
|
declare function useVueBaseProps<CONTENT, DESIGN>(): VueBaseProps<CONTENT, DESIGN>;
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
interface InputBoxContent {
|
|
34
|
+
hasContent: boolean;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
declare function useInputboxElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
32
38
|
hasContent: boolean;
|
|
33
39
|
value: string | undefined;
|
|
34
40
|
};
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
interface TextAreaContent {
|
|
43
|
+
hasContent: boolean;
|
|
44
|
+
value: string;
|
|
45
|
+
}
|
|
46
|
+
declare function useTextareaElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
37
47
|
hasContent: boolean;
|
|
38
48
|
value: string | undefined;
|
|
39
49
|
};
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
interface ButtonContent {
|
|
52
|
+
title: string;
|
|
53
|
+
link: string;
|
|
54
|
+
hasTitle: boolean;
|
|
55
|
+
hasLink: boolean;
|
|
56
|
+
performAction: () => void;
|
|
57
|
+
}
|
|
58
|
+
declare function useButtonElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
42
59
|
title: string | undefined;
|
|
43
60
|
link: string | undefined;
|
|
44
61
|
hasTitle: boolean;
|
|
@@ -46,7 +63,14 @@ declare function useButtonElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
|
46
63
|
performAction: () => void;
|
|
47
64
|
};
|
|
48
65
|
|
|
49
|
-
|
|
66
|
+
interface ImageContent {
|
|
67
|
+
hasContent: boolean;
|
|
68
|
+
lowResolutionMobileImage: string;
|
|
69
|
+
highResolutionMobileImage: string;
|
|
70
|
+
lowResolutionDesktopImage: string;
|
|
71
|
+
highResolutionDesktopImage: string;
|
|
72
|
+
}
|
|
73
|
+
declare function useImageElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
50
74
|
hasContent: boolean;
|
|
51
75
|
lowResolutionMobileImage: string;
|
|
52
76
|
highResolutionMobileImage: string;
|
|
@@ -54,16 +78,64 @@ declare function useImageElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
|
54
78
|
highResolutionDesktopImage: string;
|
|
55
79
|
};
|
|
56
80
|
|
|
57
|
-
|
|
81
|
+
interface ToggleContent {
|
|
82
|
+
hasContent: boolean;
|
|
83
|
+
value: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare function useToggleElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
58
86
|
hasContent: boolean;
|
|
59
87
|
value: boolean | undefined;
|
|
60
88
|
};
|
|
61
89
|
|
|
62
|
-
|
|
90
|
+
interface SelectBoxContent {
|
|
63
91
|
hasContent: boolean;
|
|
64
|
-
value:
|
|
92
|
+
value: string;
|
|
93
|
+
}
|
|
94
|
+
declare function useSelectboxElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
95
|
+
hasContent: boolean;
|
|
96
|
+
value: string | undefined;
|
|
65
97
|
};
|
|
66
98
|
|
|
99
|
+
interface Card {
|
|
100
|
+
title: string;
|
|
101
|
+
settings: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
interface Deck {
|
|
104
|
+
cards: Card[];
|
|
105
|
+
}
|
|
106
|
+
declare enum EditorTypes {
|
|
107
|
+
INPUTBOX = "INPUTBOX",
|
|
108
|
+
TEXTAREA = "TEXTAREA",
|
|
109
|
+
BUTTON = "BUTTON",
|
|
110
|
+
IMAGE = "IMAGE",
|
|
111
|
+
TOGGLE = "TOGGLE",
|
|
112
|
+
SELECTBOX = "SELECTBOX"
|
|
113
|
+
}
|
|
114
|
+
declare function useDeckElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
115
|
+
hasContent: boolean;
|
|
116
|
+
cards: Card[] | undefined;
|
|
117
|
+
getReactiveRef: typeof getReactiveRef;
|
|
118
|
+
};
|
|
119
|
+
declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes, contentElementName: string): {
|
|
120
|
+
hasContent: boolean;
|
|
121
|
+
value: string | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
title: string | undefined;
|
|
124
|
+
link: string | undefined;
|
|
125
|
+
hasTitle: boolean;
|
|
126
|
+
hasLink: boolean;
|
|
127
|
+
performAction: () => void;
|
|
128
|
+
} | {
|
|
129
|
+
hasContent: boolean;
|
|
130
|
+
lowResolutionMobileImage: string;
|
|
131
|
+
highResolutionMobileImage: string;
|
|
132
|
+
lowResolutionDesktopImage: string;
|
|
133
|
+
highResolutionDesktopImage: string;
|
|
134
|
+
} | {
|
|
135
|
+
hasContent: boolean;
|
|
136
|
+
value: boolean | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
|
|
67
139
|
declare function useTextElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
68
140
|
font: string | undefined;
|
|
69
141
|
size: number | GlobalTextSizeString | undefined;
|
|
@@ -141,4 +213,69 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
141
213
|
};
|
|
142
214
|
};
|
|
143
215
|
|
|
144
|
-
|
|
216
|
+
interface InstantsiteTilePromise {
|
|
217
|
+
add(callback: (id: string) => void): void;
|
|
218
|
+
}
|
|
219
|
+
interface InstantsiteJSAPI {
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves the current site ID.
|
|
222
|
+
*
|
|
223
|
+
* @returns {number} The site ID.
|
|
224
|
+
*/
|
|
225
|
+
getSiteId: () => number;
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves the public token for a given app.
|
|
228
|
+
*
|
|
229
|
+
* @param {string} appId - The ID of the app.
|
|
230
|
+
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
231
|
+
*/
|
|
232
|
+
getAppPublicToken: (appId: string) => string | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves the public configuration for a given app.
|
|
235
|
+
*
|
|
236
|
+
* @param {string} appId - The ID of the app.
|
|
237
|
+
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
238
|
+
*/
|
|
239
|
+
getAppPublicConfig: (appId: string) => string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* An event that triggers when a tile is loaded.
|
|
242
|
+
*
|
|
243
|
+
* @type {InstantsiteTilePromise}
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
248
|
+
*
|
|
249
|
+
* tileLoadedPromise?.add((tileId) => {
|
|
250
|
+
* console.log('Tile loaded:', tileId);
|
|
251
|
+
* });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
onTileLoaded: InstantsiteTilePromise;
|
|
255
|
+
/**
|
|
256
|
+
* An event that triggers when a tile is unloaded.
|
|
257
|
+
*
|
|
258
|
+
* @type {InstantsiteTilePromise}
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
263
|
+
*
|
|
264
|
+
* tileUnloadedPromise?.add((tileId) => {
|
|
265
|
+
* console.log('Tile unloaded:', tileId);
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
onTileUnloaded: InstantsiteTilePromise;
|
|
270
|
+
/**
|
|
271
|
+
* Opens the search page with the specified keyword.
|
|
272
|
+
*
|
|
273
|
+
* @param {string | undefined} keyword - The keyword to search for.
|
|
274
|
+
* @returns {void}
|
|
275
|
+
*/
|
|
276
|
+
openSearchPage: (keyword: string | undefined) => void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
280
|
+
|
|
281
|
+
export { type ButtonContent, type Card, type Deck, EditorTypes, type ImageContent, type InputBoxContent, type SelectBoxContent, type TextAreaContent, type ToggleContent, createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
package/dist/app.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ interface AppBaseData<C, D> {
|
|
|
12
12
|
readonly content: C;
|
|
13
13
|
readonly design: D;
|
|
14
14
|
readonly defaults: Record<string, unknown>;
|
|
15
|
+
readonly externalContent: Record<string, unknown>;
|
|
15
16
|
}
|
|
16
17
|
interface AppBaseState<C, D> {
|
|
17
18
|
readonly context: AppBaseContext;
|
|
@@ -19,26 +20,42 @@ interface AppBaseState<C, D> {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
interface VueBaseProps<CONTENT, DESIGN> {
|
|
22
|
-
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
-
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
+
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>, externalContent: Record<string, unknown>) => void;
|
|
24
|
+
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>, externalContent: Record<string, unknown>) => void;
|
|
24
25
|
readonly context: Ref<AppBaseContext>;
|
|
25
26
|
readonly content: Ref<CONTENT>;
|
|
26
27
|
readonly design: Ref<DESIGN>;
|
|
27
28
|
readonly defaults: Ref<Record<string, unknown>>;
|
|
29
|
+
readonly externalContent: Ref<Record<string, unknown>>;
|
|
28
30
|
}
|
|
29
31
|
declare function useVueBaseProps<CONTENT, DESIGN>(): VueBaseProps<CONTENT, DESIGN>;
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
interface InputBoxContent {
|
|
34
|
+
hasContent: boolean;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
declare function useInputboxElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
32
38
|
hasContent: boolean;
|
|
33
39
|
value: string | undefined;
|
|
34
40
|
};
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
interface TextAreaContent {
|
|
43
|
+
hasContent: boolean;
|
|
44
|
+
value: string;
|
|
45
|
+
}
|
|
46
|
+
declare function useTextareaElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
37
47
|
hasContent: boolean;
|
|
38
48
|
value: string | undefined;
|
|
39
49
|
};
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
interface ButtonContent {
|
|
52
|
+
title: string;
|
|
53
|
+
link: string;
|
|
54
|
+
hasTitle: boolean;
|
|
55
|
+
hasLink: boolean;
|
|
56
|
+
performAction: () => void;
|
|
57
|
+
}
|
|
58
|
+
declare function useButtonElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
42
59
|
title: string | undefined;
|
|
43
60
|
link: string | undefined;
|
|
44
61
|
hasTitle: boolean;
|
|
@@ -46,7 +63,14 @@ declare function useButtonElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
|
46
63
|
performAction: () => void;
|
|
47
64
|
};
|
|
48
65
|
|
|
49
|
-
|
|
66
|
+
interface ImageContent {
|
|
67
|
+
hasContent: boolean;
|
|
68
|
+
lowResolutionMobileImage: string;
|
|
69
|
+
highResolutionMobileImage: string;
|
|
70
|
+
lowResolutionDesktopImage: string;
|
|
71
|
+
highResolutionDesktopImage: string;
|
|
72
|
+
}
|
|
73
|
+
declare function useImageElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
50
74
|
hasContent: boolean;
|
|
51
75
|
lowResolutionMobileImage: string;
|
|
52
76
|
highResolutionMobileImage: string;
|
|
@@ -54,16 +78,64 @@ declare function useImageElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
|
54
78
|
highResolutionDesktopImage: string;
|
|
55
79
|
};
|
|
56
80
|
|
|
57
|
-
|
|
81
|
+
interface ToggleContent {
|
|
82
|
+
hasContent: boolean;
|
|
83
|
+
value: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare function useToggleElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
58
86
|
hasContent: boolean;
|
|
59
87
|
value: boolean | undefined;
|
|
60
88
|
};
|
|
61
89
|
|
|
62
|
-
|
|
90
|
+
interface SelectBoxContent {
|
|
63
91
|
hasContent: boolean;
|
|
64
|
-
value:
|
|
92
|
+
value: string;
|
|
93
|
+
}
|
|
94
|
+
declare function useSelectboxElementContent<CONTENT>(elementName: string, externalContent?: Record<string, unknown>): {
|
|
95
|
+
hasContent: boolean;
|
|
96
|
+
value: string | undefined;
|
|
65
97
|
};
|
|
66
98
|
|
|
99
|
+
interface Card {
|
|
100
|
+
title: string;
|
|
101
|
+
settings: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
interface Deck {
|
|
104
|
+
cards: Card[];
|
|
105
|
+
}
|
|
106
|
+
declare enum EditorTypes {
|
|
107
|
+
INPUTBOX = "INPUTBOX",
|
|
108
|
+
TEXTAREA = "TEXTAREA",
|
|
109
|
+
BUTTON = "BUTTON",
|
|
110
|
+
IMAGE = "IMAGE",
|
|
111
|
+
TOGGLE = "TOGGLE",
|
|
112
|
+
SELECTBOX = "SELECTBOX"
|
|
113
|
+
}
|
|
114
|
+
declare function useDeckElementContent<CONTENT>(elementName: keyof CONTENT): {
|
|
115
|
+
hasContent: boolean;
|
|
116
|
+
cards: Card[] | undefined;
|
|
117
|
+
getReactiveRef: typeof getReactiveRef;
|
|
118
|
+
};
|
|
119
|
+
declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes, contentElementName: string): {
|
|
120
|
+
hasContent: boolean;
|
|
121
|
+
value: string | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
title: string | undefined;
|
|
124
|
+
link: string | undefined;
|
|
125
|
+
hasTitle: boolean;
|
|
126
|
+
hasLink: boolean;
|
|
127
|
+
performAction: () => void;
|
|
128
|
+
} | {
|
|
129
|
+
hasContent: boolean;
|
|
130
|
+
lowResolutionMobileImage: string;
|
|
131
|
+
highResolutionMobileImage: string;
|
|
132
|
+
lowResolutionDesktopImage: string;
|
|
133
|
+
highResolutionDesktopImage: string;
|
|
134
|
+
} | {
|
|
135
|
+
hasContent: boolean;
|
|
136
|
+
value: boolean | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
|
|
67
139
|
declare function useTextElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
68
140
|
font: string | undefined;
|
|
69
141
|
size: number | GlobalTextSizeString | undefined;
|
|
@@ -141,4 +213,69 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
141
213
|
};
|
|
142
214
|
};
|
|
143
215
|
|
|
144
|
-
|
|
216
|
+
interface InstantsiteTilePromise {
|
|
217
|
+
add(callback: (id: string) => void): void;
|
|
218
|
+
}
|
|
219
|
+
interface InstantsiteJSAPI {
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves the current site ID.
|
|
222
|
+
*
|
|
223
|
+
* @returns {number} The site ID.
|
|
224
|
+
*/
|
|
225
|
+
getSiteId: () => number;
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves the public token for a given app.
|
|
228
|
+
*
|
|
229
|
+
* @param {string} appId - The ID of the app.
|
|
230
|
+
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
231
|
+
*/
|
|
232
|
+
getAppPublicToken: (appId: string) => string | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves the public configuration for a given app.
|
|
235
|
+
*
|
|
236
|
+
* @param {string} appId - The ID of the app.
|
|
237
|
+
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
238
|
+
*/
|
|
239
|
+
getAppPublicConfig: (appId: string) => string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* An event that triggers when a tile is loaded.
|
|
242
|
+
*
|
|
243
|
+
* @type {InstantsiteTilePromise}
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
248
|
+
*
|
|
249
|
+
* tileLoadedPromise?.add((tileId) => {
|
|
250
|
+
* console.log('Tile loaded:', tileId);
|
|
251
|
+
* });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
onTileLoaded: InstantsiteTilePromise;
|
|
255
|
+
/**
|
|
256
|
+
* An event that triggers when a tile is unloaded.
|
|
257
|
+
*
|
|
258
|
+
* @type {InstantsiteTilePromise}
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
263
|
+
*
|
|
264
|
+
* tileUnloadedPromise?.add((tileId) => {
|
|
265
|
+
* console.log('Tile unloaded:', tileId);
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
onTileUnloaded: InstantsiteTilePromise;
|
|
270
|
+
/**
|
|
271
|
+
* Opens the search page with the specified keyword.
|
|
272
|
+
*
|
|
273
|
+
* @param {string | undefined} keyword - The keyword to search for.
|
|
274
|
+
* @returns {void}
|
|
275
|
+
*/
|
|
276
|
+
openSearchPage: (keyword: string | undefined) => void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
280
|
+
|
|
281
|
+
export { type ButtonContent, type Card, type Deck, EditorTypes, type ImageContent, type InputBoxContent, type SelectBoxContent, type TextAreaContent, type ToggleContent, createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
package/dist/app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCurrentInstance as
|
|
1
|
+
import{getCurrentInstance as z,ref as b,computed as r,reactive as f,createSSRApp as D}from"vue";import{renderToString as L}from"vue/server-renderer";const w=new Map;function v(){const n=(a,l,u,d,s,i)=>{w.set(a._uid,{context:b(l),content:b(u),design:b(d),defaults:b(s),externalContent:b(i)})},t=(a,l,u,d,s)=>{const i=w.get(a._uid);i!==void 0&&(i.content.value=l,i.design.value=u,i.defaults.value=d,i.externalContent.value=s)},e=z()?.appContext.app._uid??-1,o=w.get(e);return{init:n,update:t,context:o?.context,content:o?.content,design:o?.design,defaults:o?.defaults,externalContent:o?.externalContent}}function C(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return $(o,n)}function $(n,t){const e=r(()=>{const l=n.value[t];if(l!==void 0){if(typeof l=="string")return l;throw new Error(`Element ${t} is not inputbox`)}}),o=r(()=>e.value!==void 0),a=r(()=>e.value);return f({hasContent:o,value:a})}function h(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return B(o,n)}function B(n,t){const e=r(()=>{const l=n.value[t];if(l!==void 0){if(typeof l=="string")return l;throw new Error(`Element ${t} is not textarea`)}}),o=r(()=>e.value!==void 0),a=r(()=>e.value);return f({hasContent:o,value:a})}function R(n){return"title"in n&&"type"in n}function T(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return S(o,n)}function S(n,t){const e=r(()=>{const s=n.value[t];if(s!==void 0){if(R(s))return s;throw new Error(`Element ${t} is not action link`)}}),o=r(()=>e.value?.title),a=r(()=>e.value?.link),l=r(()=>!!o.value),u=r(()=>!!a.value),d=s=>{if(s?.pageUrl)return s.pageUrl;switch(s?.pageId){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":default:return"/"}};return f({title:o,link:a,hasTitle:l,hasLink:u,performAction:()=>{if(e.value!==void 0)switch(e.value.type){case"HYPER_LINK":e.value.link&&window.open(e.value.link,"_blank");break;case"GO_TO_STORE_LINK":window.open("/products");break;case"GO_TO_PAGE":window.open(d(e.value));break;case"MAIL_LINK":e.value.email&&window.open(`mailto:${e.value.email}`,"_self");break;case"TEL_LINK":e.value.phone&&window.open(`tel:${e.value.phone}`,"_self");break;case"SCROLL_TO_TILE":{if(typeof document>"u")return;const s=e.value.tileId;document.getElementById(`tile-${s}`)?.scrollIntoView();break}default:throw new Error(`Unknown ButtonType: ${e.value.type}`)}}})}function G(n){return"bucket"in n&&"borderInfo"in n&&"set"in n}function m(n,t){const e=new RegExp(/^https?:\/\//);return n!=null&&e.test(n)?n:`${t}/${n}`}function x(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return N(o,n)}function N(n,t){const e=r(()=>{const i=n.value[t];if(i!==void 0){if(G(i))return i;throw new Error(`Element ${t} is not image`)}}),o=r(()=>e.value===void 0?"":v().context.value.imageBuckets?.[e.value?.bucket]),a=r(()=>e.value!==void 0),l=r(()=>m(e.value?.set?.["cropped-webp-100x200"]?.url,o.value)),u=r(()=>m(e.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),d=r(()=>m(e.value?.set?.["webp-200x200"]?.url,o.value)),s=r(()=>m(e.value?.set?.["webp-2000x2000"]?.url,o.value));return f({hasContent:a,lowResolutionMobileImage:l,highResolutionMobileImage:u,lowResolutionDesktopImage:d,highResolutionDesktopImage:s})}function U(n){return"enabled"in n}function k(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return X(o,n)}function X(n,t){const e=r(()=>{const l=n.value[t];if(l!==void 0){if(U(l))return l;throw new Error(`Element ${t} is not toggle`)}}),o=r(()=>e.value!==void 0),a=r(()=>e.value?.enabled);return f({hasContent:o,value:a})}function I(n,t){const e=v(),o=r(()=>t!==void 0?t:e.content.value);return M(o,n)}function M(n,t){const e=r(()=>{const l=n.value[t];if(l!==void 0){if(typeof l=="string")return l;throw new Error(`Element ${t} is not selectbox`)}}),o=r(()=>e.value!==void 0),a=r(()=>e.value);return f({hasContent:o,value:a})}var A=(n=>(n.INPUTBOX="INPUTBOX",n.TEXTAREA="TEXTAREA",n.BUTTON="BUTTON",n.IMAGE="IMAGE",n.TOGGLE="TOGGLE",n.SELECTBOX="SELECTBOX",n))(A||{});function P(n){if(typeof n!="object"||n===null)return!1;const t=n;return Array.isArray(t.cards)&&t.cards.every(e=>typeof e.settings=="object"&&e.settings!==null)}function K(n){const t=v(),e=r(()=>{const l=t.content.value[n];if(l!==void 0){if(P(l))return l;throw new Error(`Element ${n} is not of DECK type`)}}),o=r(()=>e.value!==void 0&&e.value.cards.length>0),a=r(()=>e.value?.cards);return f({hasContent:o,cards:a,getReactiveRef:V})}function V(n,t,e){if(n==null)throw Error("Could not get a reactive ref for undefined Card");const o=n.settings[e];if(o===void 0)return o;switch(t){case"TEXTAREA":return h(e,n.settings);case"INPUTBOX":return C(e,n.settings);case"SELECTBOX":return I(e,n.settings);case"IMAGE":return x(e,n.settings);case"TOGGLE":return k(e,n.settings);case"BUTTON":return T(e,n.settings);default:return}}function y(n,t){if(t===void 0)return;if(!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.fontFamily[e]}function O(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.textSize[e]}function p(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.color[e]}function W(n){const t=v(),e=r(()=>{const i=t.design.value[n],c=t.defaults.value[n],g=t.context.value.globalDesign;return{font:i?.font?.replaceAll("_"," ")??y(g,c?.font),size:i?.size??O(g,c?.size),bold:i?.bold??c?.bold,italic:i?.italic??c?.italic,color:i?.color??p(g,c?.color),visible:i?.visible??c?.visible??!1}}),o=r(()=>e.value?.font),a=r(()=>e.value?.size),l=r(()=>e.value?.bold),u=r(()=>e.value?.italic),d=r(()=>e.value?.color),s=r(()=>e.value?.visible);return f({font:o,size:a,bold:l,italic:u,color:d,visible:s})}function j(n){const t=v(),e=r(()=>{const c=t.design.value[n],g=t.defaults.value[n],E=t.context.value.globalDesign;return{font:c?.font?.replaceAll("_"," ")??y(E,g?.font),size:c?.size??O(E,g?.size),bold:c?.bold??g?.bold,italic:c?.italic??g?.italic,color:c?.color??p(E,g?.color),visible:c?.visible??g?.visible??!1,whiteSpace:"pre-wrap"}}),o=r(()=>e.value?.font),a=r(()=>e.value?.size),l=r(()=>e.value?.bold),u=r(()=>e.value?.italic),d=r(()=>e.value?.color),s=r(()=>e.value?.visible),i=r(()=>e.value?.whiteSpace);return f({font:o,size:a,bold:l,italic:u,color:d,visible:s,whiteSpace:i})}function F(n){const t=v(),e=r(()=>{const i=t.design.value[n],c=t.defaults.value[n],g=t.context.value.globalDesign;return{appearance:i?.appearance??c?.appearance,font:i?.font??y(g,c?.font),size:i?.size??c?.size,style:i?.style??c?.style,color:i?.color??p(g,c?.color),visible:i?.visible??c?.visible??!1}}),o=r(()=>e.value?.appearance),a=r(()=>e.value?.font),l=r(()=>e.value?.size),u=r(()=>e.value?.style),d=r(()=>e.value?.color),s=r(()=>e.value?.visible);return f({appearance:o,font:a,size:l,style:u,color:d,visible:s})}function H(n){const t=v(),e=r(()=>{const l=t.design.value[n],u=t.defaults.value[n],d=t.context.value.globalDesign;return{overlay:{type:l?.overlay?.type??u?.overlay?.type,solid:{color:l?.overlay?.solid?.color??p(d,u?.overlay?.solid?.color)},gradient:{fromColor:l?.overlay?.gradient?.fromColor??p(d,u?.overlay?.gradient?.fromColor),toColor:l?.overlay?.gradient?.toColor??p(d,u?.overlay?.gradient?.toColor)}},visible:l?.visible??u?.visible??!1}}),o=r(()=>e.value?.overlay),a=r(()=>e.value?.visible);return f({overlay:o,visible:a})}function J(n){const t=v(),e=r(()=>{const a=t.design.value[n],l=t.defaults.value[n];return{enabled:a?.enabled??l?.enabled}}),o=r(()=>e.value?.enabled);return f({enabled:o})}function Y(n){const t=v(),e=r(()=>{const a=t.design.value[n],l=t.defaults.value[n];return{value:a?.value??l?.value}}),o=r(()=>e.value?.value);return f({value:o})}function q(n){const t=v(),e=r(()=>{const a=t.design.value[n],l=t.defaults.value[n],u=t.context.value.globalDesign;return{background:{type:a?.background?.type??l?.background?.type,solid:{color:a?.background?.solid?.color??p(u,l?.background?.solid?.color)},gradient:{fromColor:a?.background?.gradient?.fromColor??p(u,l?.background?.gradient?.fromColor),toColor:a?.background?.gradient?.toColor??p(u,l?.background?.gradient?.toColor)}}}}),o=r(()=>e.value?.background);return f({background:o})}function Q(){const n=v(),t=r(()=>n.design.value.layout),e=r(()=>t.value);return f({layout:e})}function _(n){return{app:D(n)}}function Z(n,t){return{init:()=>{const{app:e}=_(n);return t?.init?.(e),{render:async(o,a)=>(v().init(e,o,a.content,a.design,a.defaults,a.externalContent),t?.render?.(e,o,a),{html:await L(e,{context:o}),state:{context:o,data:a}})}}}}function ee(n,t){return{init:()=>{const{app:e}=_(n);return t?.init?.(e),{mount:(o,a)=>{v().init(e,a.context,a.data.content,a.data.design,a.data.defaults,a.data.externalContent),t?.mount?.(e,o,a),e.mount(o)},update:o=>{v().update(e,o.data.content,o.data.design,o.data.defaults,o.data.externalContent),t?.update?.(e,o)},unmount:()=>{t?.unmount?.(e),e.unmount()}}}}}function te(){return globalThis.window.instantsite}export{A as EditorTypes,ee as createVueClientApp,Z as createVueServerApp,q as useBackgroundElementDesign,T as useButtonElementContent,F as useButtonElementDesign,K as useDeckElementContent,x as useImageElementContent,H as useImageElementDesign,C as useInputboxElementContent,te as useInstantsiteJsApi,Q as useLayoutElementDesign,I as useSelectboxElementContent,Y as useSelectboxElementDesign,W as useTextElementDesign,h as useTextareaElementContent,j as useTextareaElementDesign,k as useToggleElementContent,J as useToggleElementDesign,v as useVueBaseProps};
|