@zenky/storefront-vue 0.9.46 → 0.10.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/LICENSE.md +2 -2
- package/README.md +163 -6
- package/dist/cart/index.d.ts +559 -0
- package/dist/cart/index.js +13 -0
- package/dist/cart/index.js.map +1 -0
- package/dist/catalog/index.d.ts +73 -0
- package/dist/catalog/index.js +4 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-2OD7CLKD.js +102 -0
- package/dist/chunk-2OD7CLKD.js.map +1 -0
- package/dist/chunk-4MJKN7PL.js +111 -0
- package/dist/chunk-4MJKN7PL.js.map +1 -0
- package/dist/chunk-5QCUH3FF.js +15 -0
- package/dist/chunk-5QCUH3FF.js.map +1 -0
- package/dist/chunk-AL5W5JSD.js +41 -0
- package/dist/chunk-AL5W5JSD.js.map +1 -0
- package/dist/chunk-BIGTKVC6.js +38 -0
- package/dist/chunk-BIGTKVC6.js.map +1 -0
- package/dist/chunk-BWUKMWHL.js +45 -0
- package/dist/chunk-BWUKMWHL.js.map +1 -0
- package/dist/chunk-DKWDKVXQ.js +91 -0
- package/dist/chunk-DKWDKVXQ.js.map +1 -0
- package/dist/chunk-EMGQXBU3.js +3 -0
- package/dist/chunk-EMGQXBU3.js.map +1 -0
- package/dist/chunk-EYRCAUUP.js +45 -0
- package/dist/chunk-EYRCAUUP.js.map +1 -0
- package/dist/chunk-GW2QNTAD.js +327 -0
- package/dist/chunk-GW2QNTAD.js.map +1 -0
- package/dist/chunk-IGDDWGS4.js +557 -0
- package/dist/chunk-IGDDWGS4.js.map +1 -0
- package/dist/chunk-OQLU7FSR.js +1841 -0
- package/dist/chunk-OQLU7FSR.js.map +1 -0
- package/dist/chunk-PJ2LEKW6.js +229 -0
- package/dist/chunk-PJ2LEKW6.js.map +1 -0
- package/dist/chunk-PWHIDGKW.js +97 -0
- package/dist/chunk-PWHIDGKW.js.map +1 -0
- package/dist/chunk-RO25KNM5.js +36 -0
- package/dist/chunk-RO25KNM5.js.map +1 -0
- package/dist/chunk-V3VVDQIR.js +27 -0
- package/dist/chunk-V3VVDQIR.js.map +1 -0
- package/dist/chunk-VL3T36VM.js +386 -0
- package/dist/chunk-VL3T36VM.js.map +1 -0
- package/dist/chunk-XUGXLJZB.js +14 -0
- package/dist/chunk-XUGXLJZB.js.map +1 -0
- package/dist/chunk-Z3IW4ODZ.js +36 -0
- package/dist/chunk-Z3IW4ODZ.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/index.d.ts +54 -0
- package/dist/layout/index.js +102 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/money/index.d.ts +26 -0
- package/dist/money/index.js +3 -0
- package/dist/money/index.js.map +1 -0
- package/dist/order/index.d.ts +34 -0
- package/dist/order/index.js +209 -0
- package/dist/order/index.js.map +1 -0
- package/dist/pagination/index.d.ts +87 -0
- package/dist/pagination/index.js +97 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/ports/index.d.ts +124 -0
- package/dist/ports/index.js +3 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/products/index.d.ts +105 -0
- package/dist/products/index.js +7 -0
- package/dist/products/index.js.map +1 -0
- package/dist/promotions/index.d.ts +10 -0
- package/dist/promotions/index.js +7 -0
- package/dist/promotions/index.js.map +1 -0
- package/dist/schedule-Dd3zwHEb.d.ts +27 -0
- package/dist/seo/index.d.ts +91 -0
- package/dist/seo/index.js +289 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/snippets/index.d.ts +17 -0
- package/dist/snippets/index.js +3 -0
- package/dist/snippets/index.js.map +1 -0
- package/dist/snippets-BC5bkSjm.d.ts +23 -0
- package/dist/stores/index.d.ts +196 -0
- package/dist/stores/index.js +8 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/theme/index.d.ts +60 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/utils/index.d.ts +66 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/website-settings/index.d.ts +38 -0
- package/dist/website-settings/index.js +3 -0
- package/dist/website-settings/index.js.map +1 -0
- package/package.json +122 -41
- package/dist/esm/index.js +0 -3642
- package/dist/zenky.d.ts +0 -10377
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,15 +1,172 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zenky/storefront-vue
|
|
2
|
+
|
|
3
|
+
Headless storefront engine for Zenky — Vue 3 + Pinia, no framework lock-in.
|
|
4
|
+
|
|
5
|
+
One engine behind many storefronts. The cart, order building, checkout, catalog resolution, delivery slots, SEO/JSON-LD, theme, and store/profile state all live here as framework-agnostic composables and Pinia stores. The consumer — a Nuxt site, a QR-code menu, a new template — brings the framework glue (cookies, config, toasts, HTTP transport, `useHead`) and draws its own UI on top.
|
|
6
|
+
|
|
7
|
+
The design is Ports & Adapters: the core declares small ports for everything it needs from the outside world, the consumer provides adapters once, and every composable reads them through `useRuntime()`. The core never imports `useCookie`, `useRoute`, `useHead`, `$fetch`, or anything Nuxt-specific.
|
|
2
8
|
|
|
3
9
|
## Installation
|
|
4
10
|
|
|
5
|
-
```
|
|
6
|
-
npm
|
|
11
|
+
```bash
|
|
12
|
+
npm install @zenky/storefront-vue
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies (the consumer already has these):
|
|
16
|
+
|
|
17
|
+
```jsonc
|
|
18
|
+
{
|
|
19
|
+
"vue": "^3.5.0",
|
|
20
|
+
"pinia": "^3.0.0",
|
|
21
|
+
"@zenky/storefront-api": ">=0.0.64",
|
|
22
|
+
"@zenky/integrations-sdk": ">=0.1.3"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
Assemble the runtime once at your composition root and install it as a Vue plugin. After that, core composables just work.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createStorefront } from '@zenky/storefront-vue'
|
|
32
|
+
|
|
33
|
+
app.use(
|
|
34
|
+
createStorefront({
|
|
35
|
+
sdk, // ZenkyStorefront instance (one per app)
|
|
36
|
+
config: { baseUrl, baseAuthUrl },
|
|
37
|
+
storage: { // where order id/token, settings, etc. persist
|
|
38
|
+
get: (key) => readCookie(key),
|
|
39
|
+
set: (key, value, opts) => writeCookie(key, value, opts),
|
|
40
|
+
remove: (key, opts) => deleteCookie(key, opts),
|
|
41
|
+
},
|
|
42
|
+
notifier: { // user-facing messages
|
|
43
|
+
error: (m) => toast.error(m),
|
|
44
|
+
success: (m) => toast.success(m),
|
|
45
|
+
warning: (m) => toast.warning(m),
|
|
46
|
+
message: (title, opts) => toast(title, opts),
|
|
47
|
+
},
|
|
48
|
+
activity: { // busy indicators for long operations
|
|
49
|
+
begin: (kind) => busy.begin(kind),
|
|
50
|
+
end: (kind) => busy.end(kind),
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then, anywhere in a component or composable:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { useStorefrontCart } from '@zenky/storefront-vue/cart'
|
|
60
|
+
|
|
61
|
+
const cart = useStorefrontCart()
|
|
62
|
+
|
|
63
|
+
await cart.initializeOrder()
|
|
64
|
+
await cart.addToCart({ productId, productVariantId, quantity: 1 })
|
|
65
|
+
|
|
66
|
+
cart.itemCount.value // reactive
|
|
67
|
+
cart.totalPrice.value
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Runtime Ports
|
|
71
|
+
|
|
72
|
+
`createStorefront(runtime)` takes one object. Five ports are required; the rest are optional — omit an optional port and the feature that needs it is simply skipped.
|
|
73
|
+
|
|
74
|
+
| Port | Required | What the consumer provides |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `sdk` | yes | A `ZenkyStorefront` instance (`@zenky/storefront-api`). |
|
|
77
|
+
| `config` | yes | `{ baseUrl, baseAuthUrl, salesChannelId? }`. |
|
|
78
|
+
| `storage` | yes | Key/value persistence — cookies, `localStorage`, memory. |
|
|
79
|
+
| `notifier` | yes | Toasts: `error` / `success` / `warning` / `message`. |
|
|
80
|
+
| `activity` | yes | `begin(kind)` / `end(kind)` for busy state. |
|
|
81
|
+
| `events` | no | Lazy `{ get() }` provider for `ZenkyIntegrationsSDK`; resolve on every event. |
|
|
82
|
+
| `realtime` | no | Lazy `{ get() }` provider for the WebSocket adapter (`subscribe` / `unsubscribe` / `isReady`). |
|
|
83
|
+
| `catalogReloader` | no | Reloads the catalog when the stock changes. |
|
|
84
|
+
| `rum` | no | Performance marks (`mark` / `measure`). |
|
|
85
|
+
| `commerceEvents` | no | Commerce-event tracking (`trackAddedToCart`, `getIdentity`, …). |
|
|
86
|
+
|
|
87
|
+
Types for every port live in the `ports` subpath, alongside no-op defaults and an in-memory storage helper for SSR/tests:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import {
|
|
91
|
+
type StorefrontRuntime,
|
|
92
|
+
type StorageAdapter,
|
|
93
|
+
NOOP_NOTIFIER,
|
|
94
|
+
NOOP_ACTIVITY_REPORTER,
|
|
95
|
+
createMemoryStorage,
|
|
96
|
+
} from '@zenky/storefront-vue/ports'
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Subpath Imports
|
|
100
|
+
|
|
101
|
+
Each public domain is its own entry point, so bundlers only pull in what you import.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { minorToMajor } from '@zenky/storefront-vue/money'
|
|
105
|
+
import { buildCssVariableMap, THEME_PRESETS } from '@zenky/storefront-vue/theme'
|
|
106
|
+
import { getRemoteCatalog, findCategoryByShortId } from '@zenky/storefront-vue/catalog'
|
|
107
|
+
import { useStorefrontCart, useCheckoutSubmit } from '@zenky/storefront-vue/cart'
|
|
108
|
+
import { generateFreeTimeGroups } from '@zenky/storefront-vue/order'
|
|
109
|
+
import { buildProductSchema, buildOgTags } from '@zenky/storefront-vue/seo'
|
|
110
|
+
import { useHeaderData, useFooterData } from '@zenky/storefront-vue/layout'
|
|
111
|
+
import { usePaginatedList } from '@zenky/storefront-vue/pagination'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Available subpaths: `ports`, `money`, `utils`, `theme`, `stores`, `products`, `catalog`, `cart`, `order`, `promotions`, `seo`, `layout`, `pagination`, `snippets`, `website-settings`.
|
|
115
|
+
|
|
116
|
+
## Pinia Stores
|
|
117
|
+
|
|
118
|
+
The `stores` subpath exposes setup-style Pinia stores (ids namespaced `zenky-*`): cart, order settings, store profile, catalog, products, auth, promotions. They are plain state containers — no API calls, no UI logic — and they are the reactive backbone the composables read from. Install Pinia before mounting the storefront plugin.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { useCartStore, useStoreProfileStore } from '@zenky/storefront-vue/stores'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Money
|
|
125
|
+
|
|
126
|
+
Prices are stored and computed in minor units (kopecks) everywhere. Convert only at the API boundary.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { minorToMajor, minorToMajorString, majorToMinor } from '@zenky/storefront-vue/money'
|
|
130
|
+
|
|
131
|
+
minorToMajor(65000, 'RUB') // 650 — numbers for bill/amount fields
|
|
132
|
+
minorToMajorString(65000, 'RUB') // "650.00" — strings where the API expects them
|
|
133
|
+
majorToMinor(650, 'RUB') // 65000 — user input back into the store
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm run dev # tsup --watch
|
|
140
|
+
npm run build # ESM + .d.ts to dist/
|
|
141
|
+
npm run typecheck # tsc --noEmit
|
|
142
|
+
npm test # vitest
|
|
143
|
+
npm run check:exports # publint + are-the-types-wrong (esm-only profile)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Local linking with yalc
|
|
147
|
+
|
|
148
|
+
Until the package is published, link it into a consumer app with [yalc](https://github.com/wclr/yalc):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# in this package, after a build:
|
|
152
|
+
npx yalc publish
|
|
153
|
+
|
|
154
|
+
# in the consumer app:
|
|
155
|
+
npx yalc add @zenky/storefront-vue
|
|
156
|
+
|
|
157
|
+
# after each change here:
|
|
158
|
+
npm run build && npx yalc push
|
|
7
159
|
```
|
|
8
160
|
|
|
9
|
-
##
|
|
161
|
+
## Package Scripts
|
|
10
162
|
|
|
11
|
-
|
|
163
|
+
- `build` — bundle the multi-entry ESM package with tsup.
|
|
164
|
+
- `dev` — rebuild on change.
|
|
165
|
+
- `test` / `test:watch` — run the Vitest suite.
|
|
166
|
+
- `typecheck` — type-only compile.
|
|
167
|
+
- `check:exports` — validate the exports map and published types.
|
|
168
|
+
- `prepublishOnly` — typecheck → test → build → check:exports.
|
|
12
169
|
|
|
13
170
|
## License
|
|
14
171
|
|
|
15
|
-
|
|
172
|
+
MIT
|