@lightspeed/crane-api 1.0.2 → 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/CHANGELOG.md +13 -0
- package/README.md +113 -6
- package/dist/index.d.mts +1914 -527
- package/dist/index.d.ts +1914 -527
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.1 - 2026-01-14
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Enable the Category and Product selectors to accept an externalContent parameter, which is required to support integration with the Deck content editor.
|
|
8
|
+
|
|
9
|
+
## 1.1.0 - 2026-01-07
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Add `crane-api` documentation.
|
|
14
|
+
- Add reserved template page name and custom page configuration.
|
|
15
|
+
|
|
3
16
|
## 1.0.2 - 2025-12-11
|
|
4
17
|
|
|
5
18
|
### Added
|
package/README.md
CHANGED
|
@@ -1,17 +1,124 @@
|
|
|
1
1
|
# @lightspeed/crane-api
|
|
2
2
|
|
|
3
|
-
Lightweight API package for building custom sections and templates with `@lightspeed/crane`.
|
|
3
|
+
Lightweight runtime API package for building custom sections and templates with `@lightspeed/crane`.
|
|
4
4
|
|
|
5
|
-
This package provides
|
|
5
|
+
This package provides Vue 3 composables and TypeScript types needed for custom sections and templates, without CLI or build tools.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @lightspeed/crane-api
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Note:** This package is automatically included when using `@lightspeed/crane`. Install separately only if you need the API without the CLI.
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
The package exports:
|
|
18
|
+
|
|
19
|
+
- **App Creation** — `createVueServerApp`, `createVueClientApp` for SSR/hydration
|
|
20
|
+
- **Content Composables** — Access user-editable content (text, images, buttons, etc.)
|
|
21
|
+
- **Design Composables** — Access styling settings (colors, fonts, backgrounds)
|
|
22
|
+
- **Types** — TypeScript definitions for data structures
|
|
23
|
+
|
|
24
|
+
## App Entry Points
|
|
25
|
+
|
|
26
|
+
Every section requires two entry points for SSR and client hydration:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// server.ts — SSR rendering
|
|
30
|
+
import { createVueServerApp } from '@lightspeed/crane-api';
|
|
31
|
+
import Section from './Section.vue';
|
|
32
|
+
import type { ContentType, DesignType } from './type';
|
|
33
|
+
|
|
34
|
+
export default createVueServerApp<ContentType, DesignType>(Section);
|
|
35
|
+
```
|
|
8
36
|
|
|
9
37
|
```typescript
|
|
10
|
-
|
|
38
|
+
// client.ts — Client hydration
|
|
39
|
+
import { createVueClientApp } from '@lightspeed/crane-api';
|
|
40
|
+
import Section from './Section.vue';
|
|
41
|
+
import type { ContentType, DesignType } from './type';
|
|
42
|
+
|
|
43
|
+
export default createVueClientApp<ContentType, DesignType>(Section);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Content Composables
|
|
47
|
+
|
|
48
|
+
Access content defined in `settings/content.ts`:
|
|
49
|
+
|
|
50
|
+
| Composable | Editor Type | Return Type |
|
|
51
|
+
|------------|-------------|-------------|
|
|
52
|
+
| `useInputboxElementContent` | INPUTBOX | `Reactive<InputBoxContent>` |
|
|
53
|
+
| `useTextareaElementContent` | TEXTAREA | `Reactive<TextAreaContent>` |
|
|
54
|
+
| `useButtonElementContent` | BUTTON | `Reactive<ButtonContentData>` |
|
|
55
|
+
| `useImageElementContent` | IMAGE | `Reactive<ImageContent>` |
|
|
56
|
+
| `useToggleElementContent` | TOGGLE | `Reactive<ToggleContent>` |
|
|
57
|
+
| `useSelectboxElementContent` | SELECTBOX | `Reactive<SelectBoxContent>` |
|
|
58
|
+
| `useDeckElementContent` | DECK | `Reactive<DeckContent>` |
|
|
59
|
+
| `useCategorySelectorElementContent` | CATEGORY_SELECTOR | `Reactive<CategorySelector>` |
|
|
60
|
+
| `useProductSelectorElementContent` | PRODUCT_SELECTOR | `Reactive<ProductSelector>` |
|
|
61
|
+
| `useLogoElementContent` | LOGO | `Reactive<LogoContent>` |
|
|
62
|
+
| `useMenuElementContent` | MENU | `Reactive<MenuContent>` |
|
|
63
|
+
| `useNavigationMenuElementContent` | NAVIGATION_MENU | `Reactive<MenuContent>` |
|
|
64
|
+
| `useTranslation` | — | Translation helper |
|
|
65
|
+
|
|
66
|
+
### Example
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { useInputboxElementContent, useImageElementContent } from '@lightspeed/crane-api';
|
|
70
|
+
import type { ContentType } from './type';
|
|
71
|
+
|
|
72
|
+
const title = useInputboxElementContent<ContentType>('title');
|
|
73
|
+
const image = useImageElementContent<ContentType>('hero_image');
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Design Composables
|
|
78
|
+
|
|
79
|
+
Access design settings defined in `settings/design.ts`:
|
|
80
|
+
|
|
81
|
+
| Composable | Editor Type | Return Type |
|
|
82
|
+
|------------|-------------|-------------|
|
|
83
|
+
| `useTextElementDesign` | TEXT | `Reactive<TextDesignData>` |
|
|
84
|
+
| `useTextareaElementDesign` | TEXTAREA | `Reactive<TextareaDesignData>` |
|
|
85
|
+
| `useButtonElementDesign` | BUTTON | `Reactive<ButtonDesignData>` |
|
|
86
|
+
| `useBackgroundElementDesign` | BACKGROUND | `Reactive<BackgroundDesignData>` |
|
|
87
|
+
| `useImageElementDesign` | IMAGE | `Reactive<ImageDesignData>` |
|
|
88
|
+
| `useToggleElementDesign` | TOGGLE | `Reactive<ToggleDesignData>` |
|
|
89
|
+
| `useSelectboxElementDesign` | SELECTBOX | `Reactive<SelectboxDesignData>` |
|
|
90
|
+
| `useLayoutElementDesign` | — | `Reactive<LayoutDesignData>` |
|
|
91
|
+
| `useLogoElementDesign` | LOGO | `ComputedRef<LogoDesignData>` |
|
|
92
|
+
|
|
93
|
+
### Example
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { useTextElementDesign, useBackgroundElementDesign } from '@lightspeed/crane-api';
|
|
97
|
+
import type { DesignType } from './type';
|
|
98
|
+
|
|
99
|
+
const titleStyle = useTextElementDesign<DesignType>('title_style');
|
|
100
|
+
const background = useBackgroundElementDesign<DesignType>('section_background');
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Working with DECK
|
|
105
|
+
|
|
106
|
+
DECK allows collections of cards. Use `getReactiveRef` to access card fields:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { useDeckElementContent, EditorTypes } from '@lightspeed/crane-api';
|
|
110
|
+
import type { ContentType } from './type';
|
|
111
|
+
|
|
112
|
+
const slides = useDeckElementContent<ContentType>('slides');
|
|
113
|
+
|
|
114
|
+
slides.cards?.forEach(card => {
|
|
115
|
+
const title = slides.getReactiveRef(card, EditorTypes.INPUTBOX, 'title');
|
|
116
|
+
const image = slides.getReactiveRef(card, EditorTypes.IMAGE, 'background');
|
|
117
|
+
const button = slides.getReactiveRef(card, EditorTypes.BUTTON, 'cta');
|
|
118
|
+
});
|
|
11
119
|
```
|
|
12
120
|
|
|
13
121
|
## Requirements
|
|
14
122
|
|
|
15
123
|
- Node.js >= 20
|
|
16
|
-
- Vue 3
|
|
17
|
-
|
|
124
|
+
- Vue >= 3.4
|