@moonbase.sh/nuxt 0.0.0-stage → 0.1.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/README.md +114 -2
- package/dist/module.d.ts +35 -0
- package/dist/module.js +86 -0
- package/dist/runtime/composables.d.ts +1 -0
- package/dist/runtime/composables.js +4 -0
- package/dist/runtime/config.d.ts +17 -0
- package/dist/runtime/config.js +12 -0
- package/dist/runtime/options.d.ts +29 -0
- package/dist/runtime/options.js +35 -0
- package/dist/runtime/plugin.d.ts +6 -0
- package/dist/runtime/plugin.js +38 -0
- package/package.json +44 -3
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @moonbase.sh/nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nuxt module for building storefronts with Moonbase.sh. It sets up [`@moonbase.sh/vue`](https://www.npmjs.com/package/@moonbase.sh/vue)
|
|
4
|
+
in your Nuxt app, rendered on the server and in the browser, and auto-imports its composables.
|
|
5
|
+
|
|
6
|
+
Learn more in our official docs: https://moonbase.sh/docs/storefronts/sdks/vue/
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx nuxi module add @moonbase.sh/nuxt
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then give it your store's address:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// nuxt.config.ts
|
|
18
|
+
export default defineNuxtConfig({
|
|
19
|
+
modules: ['@moonbase.sh/nuxt'],
|
|
20
|
+
moonbase: {
|
|
21
|
+
endpoint: 'https://acme.moonbase.sh',
|
|
22
|
+
persistUtm: true,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Works with Nuxt 3.14 and later, and Nuxt 4.
|
|
28
|
+
|
|
29
|
+
If you import from `@moonbase.sh/vue` yourself, for its types for instance, add it to your app as well
|
|
30
|
+
(`pnpm add @moonbase.sh/vue`), on the same major version the module uses, so both use one copy.
|
|
31
|
+
|
|
32
|
+
## Options
|
|
33
|
+
|
|
34
|
+
| Option | Default | |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `endpoint` | | Your store's Moonbase address. Required, here, in the environment or in `moonbase.config.ts`. |
|
|
37
|
+
| `persistUtm` | `false` | Keep the attribution a visitor arrived with across visits rather than for the tab, with their consent. |
|
|
38
|
+
| `includeManifests` | `false` | Include each download's manifest with the products in the catalog. |
|
|
39
|
+
| `autoImports` | `true` | Auto-import the composables and `formatMoney`. Turn it off if their names clash with your own. |
|
|
40
|
+
|
|
41
|
+
The first three go into the public runtime config, so the environment can set them where the app runs:
|
|
42
|
+
`NUXT_PUBLIC_MOONBASE_ENDPOINT`, `NUXT_PUBLIC_MOONBASE_PERSIST_UTM` and `NUXT_PUBLIC_MOONBASE_INCLUDE_MANIFESTS`.
|
|
43
|
+
|
|
44
|
+
## Use it
|
|
45
|
+
|
|
46
|
+
The composables (`useProducts`, `useCart`, `useAuth`, `useInventory` and the rest) and `formatMoney` are
|
|
47
|
+
auto-imported:
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
const products = useProducts()
|
|
52
|
+
const { addToCart, checkout } = useCart()
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The storefront itself is `useNuxtApp().$moonbase`.
|
|
57
|
+
|
|
58
|
+
## Options only the browser knows: `moonbase.config.ts`
|
|
59
|
+
|
|
60
|
+
Some options can't go in `nuxt.config`, because only the running app knows them: the visitor's earlier answer to
|
|
61
|
+
your cookie banner, a custom token `store` or a `logger`. Put them in `moonbase.config.ts`, next to `app.config.ts`
|
|
62
|
+
(in `app/` on Nuxt 4, at the root on Nuxt 3):
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// app/moonbase.config.ts
|
|
66
|
+
export default defineMoonbaseConfig(() => {
|
|
67
|
+
const consent = useCookie<'granted' | 'denied' | undefined>('cookie-consent')
|
|
68
|
+
return {
|
|
69
|
+
attributionConsent: consent.value ? consent.value === 'granted' : undefined,
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
It takes anything `createStorefront` does, including `endpoint`, and wins over `nuxt.config` field by field, except
|
|
75
|
+
where it leaves a field `undefined`. The function runs on the server and in the browser, just before the storefront
|
|
76
|
+
is created, so composables work in it. It returns the options themselves, not a promise.
|
|
77
|
+
|
|
78
|
+
A consent the visitor already gave belongs here, so the storefront starts with it. When they answer the banner later,
|
|
79
|
+
tell the storefront then:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
useNuxtApp().$moonbase.setAttributionConsent(granted)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## React to the checkout
|
|
86
|
+
|
|
87
|
+
Register your own handlers in a plugin of your own, which runs after the module's. The storefront calls them from a
|
|
88
|
+
browser event, outside your app's context, so wrap anything that needs it, such as `navigateTo`, in `runWithContext`:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
// app/plugins/checkout.client.ts
|
|
92
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
93
|
+
const { $moonbase } = nuxtApp
|
|
94
|
+
|
|
95
|
+
$moonbase.onCheckoutCompleted(() => nuxtApp.runWithContext(() => {
|
|
96
|
+
$moonbase.closeCheckout()
|
|
97
|
+
return navigateTo('/order-completed')
|
|
98
|
+
}))
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
A buyer who paid on Moonbase's hosted checkout (on a phone, by default) comes back to your page, and the storefront
|
|
103
|
+
reopens the finished checkout there, so `onCheckoutCompleted` is called for them too.
|
|
104
|
+
|
|
105
|
+
## Why a module
|
|
106
|
+
|
|
107
|
+
On a phone, the checkout sends the buyer back to your page with `mb_intent=checkout&mb_complete=true&mb_endpoint=…`
|
|
108
|
+
in the address. The storefront reads those as it is created, reopens the finished checkout and takes them off the
|
|
109
|
+
address. Nuxt's router starts before any of your app's plugins and puts the address it started with back once the
|
|
110
|
+
app is created, so a storefront created in your own plugin leaves them there: a reload or Back reopens the checkout,
|
|
111
|
+
and a copied link carries them along.
|
|
112
|
+
|
|
113
|
+
The module creates the storefront after Nuxt restores the server's state and before the router starts, and on a
|
|
114
|
+
page rendered on request also takes the parameters out of the path Nuxt rendered the page for, which the router
|
|
115
|
+
prefers to the address.
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { MoonbaseConfiguration } from '@moonbase.sh/vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What `moonbase.config.ts` can set: anything `createStorefront` takes, including the endpoint. It is
|
|
6
|
+
* merged over the module's options from `nuxt.config`, field by field.
|
|
7
|
+
*/
|
|
8
|
+
type MoonbaseOptions = Partial<Omit<MoonbaseConfiguration, 'sdk'>>;
|
|
9
|
+
type MoonbaseConfigFunction = () => MoonbaseOptions;
|
|
10
|
+
|
|
11
|
+
interface ModuleOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The store's Moonbase address, such as `https://acme.moonbase.sh`. `NUXT_PUBLIC_MOONBASE_ENDPOINT`
|
|
14
|
+
* overrides it where the app runs, and `moonbase.config.ts` can set it too.
|
|
15
|
+
*/
|
|
16
|
+
endpoint?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Keep the attribution a visitor arrived with across visits, rather than for the tab. Only with the
|
|
19
|
+
* visitor's consent, as `attributionConsent` reports it.
|
|
20
|
+
*/
|
|
21
|
+
persistUtm?: boolean;
|
|
22
|
+
/** Include each download's manifest with the products in the catalog. */
|
|
23
|
+
includeManifests?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Auto-import the `@moonbase.sh/vue` composables (`useCart`, `useAuth`, `useProduct` and the rest) and
|
|
26
|
+
* `formatMoney`. Turn it off if their names clash with the app's own.
|
|
27
|
+
*
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
autoImports?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare const module: NuxtModule<ModuleOptions>;
|
|
34
|
+
|
|
35
|
+
export { type ModuleOptions, type MoonbaseConfigFunction, type MoonbaseOptions, module as default };
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/module.ts
|
|
2
|
+
import { basename, dirname, resolve } from "path";
|
|
3
|
+
import process from "process";
|
|
4
|
+
import { addImports, addPlugin, addTemplate, createResolver, defineNuxtModule, findPath, updateTemplates, useLogger } from "@nuxt/kit";
|
|
5
|
+
|
|
6
|
+
// src/autoImports.ts
|
|
7
|
+
var autoImported = [
|
|
8
|
+
"formatMoney",
|
|
9
|
+
"useActivationRequest",
|
|
10
|
+
"useAuth",
|
|
11
|
+
"useBundle",
|
|
12
|
+
"useBundles",
|
|
13
|
+
"useCart",
|
|
14
|
+
"useCartOffer",
|
|
15
|
+
"useCheckout",
|
|
16
|
+
"useCommunicationPreferences",
|
|
17
|
+
"useEligibleOffers",
|
|
18
|
+
"useGroups",
|
|
19
|
+
"useInventory",
|
|
20
|
+
"useLockedOffers",
|
|
21
|
+
"useOffer",
|
|
22
|
+
"useOffers",
|
|
23
|
+
"useOrders",
|
|
24
|
+
"useProduct",
|
|
25
|
+
"useProducts",
|
|
26
|
+
"usePromotions",
|
|
27
|
+
"useReviews",
|
|
28
|
+
"useVendor",
|
|
29
|
+
"useVoucher"
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
// src/module.ts
|
|
33
|
+
var CONFIG_TEMPLATE = "moonbase/config.mjs";
|
|
34
|
+
var module = defineNuxtModule({
|
|
35
|
+
meta: {
|
|
36
|
+
name: "@moonbase.sh/nuxt",
|
|
37
|
+
configKey: "moonbase",
|
|
38
|
+
// The plugin's order is only right for where Nuxt puts payload revival and its router, which is
|
|
39
|
+
// the same from 3.6 to 4.6. The floor is the oldest Nuxt the round trip test has run on.
|
|
40
|
+
compatibility: { nuxt: "^3.14.0 || ^4.0.0" }
|
|
41
|
+
},
|
|
42
|
+
defaults: {
|
|
43
|
+
autoImports: true
|
|
44
|
+
},
|
|
45
|
+
async setup(options, nuxt) {
|
|
46
|
+
const resolver = createResolver(import.meta.url);
|
|
47
|
+
const logger = useLogger("@moonbase.sh/nuxt");
|
|
48
|
+
const fromOptions = {
|
|
49
|
+
endpoint: options.endpoint ?? "",
|
|
50
|
+
persistUtm: options.persistUtm ?? false,
|
|
51
|
+
includeManifests: options.includeManifests ?? false
|
|
52
|
+
};
|
|
53
|
+
const runtimeConfig = {
|
|
54
|
+
...fromOptions,
|
|
55
|
+
...nuxt.options.runtimeConfig.public.moonbase
|
|
56
|
+
};
|
|
57
|
+
nuxt.options.runtimeConfig.public.moonbase = runtimeConfig;
|
|
58
|
+
const findAppConfig = () => findPath(resolve(nuxt.options.srcDir, "moonbase.config"));
|
|
59
|
+
let appConfig = await findAppConfig();
|
|
60
|
+
addTemplate({
|
|
61
|
+
filename: CONFIG_TEMPLATE,
|
|
62
|
+
getContents: () => appConfig ? `export { default } from ${JSON.stringify(appConfig)}
|
|
63
|
+
` : "export default undefined\n"
|
|
64
|
+
});
|
|
65
|
+
if (nuxt.options.dev) {
|
|
66
|
+
if (!runtimeConfig.endpoint && !process.env.NUXT_PUBLIC_MOONBASE_ENDPOINT && !appConfig)
|
|
67
|
+
logger.warn("No endpoint for the storefront yet: set `moonbase.endpoint` in nuxt.config, or `NUXT_PUBLIC_MOONBASE_ENDPOINT`.");
|
|
68
|
+
nuxt.hook("builder:watch", async (event, path) => {
|
|
69
|
+
const file = resolve(nuxt.options.srcDir, path);
|
|
70
|
+
if (event !== "add" && event !== "unlink" || dirname(file) !== resolve(nuxt.options.srcDir) || !/^moonbase\.config\.\w+$/.test(basename(file)))
|
|
71
|
+
return;
|
|
72
|
+
appConfig = await findAppConfig();
|
|
73
|
+
await updateTemplates({ filter: (template) => template.filename === CONFIG_TEMPLATE });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
addPlugin(await resolver.resolvePath("./runtime/plugin"));
|
|
77
|
+
const composables = await resolver.resolvePath("./runtime/composables");
|
|
78
|
+
if (options.autoImports)
|
|
79
|
+
addImports(autoImported.map((name) => ({ name, from: composables })));
|
|
80
|
+
addImports({ name: "defineMoonbaseConfig", from: await resolver.resolvePath("./runtime/config") });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
var module_default = module;
|
|
84
|
+
export {
|
|
85
|
+
module_default as default
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@moonbase.sh/vue';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MoonbaseConfiguration } from '@moonbase.sh/vue';
|
|
2
|
+
/**
|
|
3
|
+
* What `moonbase.config.ts` can set: anything `createStorefront` takes, including the endpoint. It is
|
|
4
|
+
* merged over the module's options from `nuxt.config`, field by field.
|
|
5
|
+
*/
|
|
6
|
+
export type MoonbaseOptions = Partial<Omit<MoonbaseConfiguration, 'sdk'>>;
|
|
7
|
+
export type MoonbaseConfigFunction = () => MoonbaseOptions;
|
|
8
|
+
/**
|
|
9
|
+
* The storefront options only the running app knows, such as the visitor's earlier answer to a cookie
|
|
10
|
+
* banner, a custom token `store` or a `logger`. Export it as the default of `moonbase.config.ts`, next
|
|
11
|
+
* to `app.config.ts`.
|
|
12
|
+
*
|
|
13
|
+
* The function runs in the module's plugin, on the server and in the browser, just before the
|
|
14
|
+
* storefront is created, so composables such as `useCookie` work in it. It returns the options, not a
|
|
15
|
+
* promise of them: on the server, the app's context does not survive an `await` there.
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineMoonbaseConfig(config: MoonbaseConfigFunction): MoonbaseConfigFunction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storefront options only the running app knows, such as the visitor's earlier answer to a cookie
|
|
3
|
+
* banner, a custom token `store` or a `logger`. Export it as the default of `moonbase.config.ts`, next
|
|
4
|
+
* to `app.config.ts`.
|
|
5
|
+
*
|
|
6
|
+
* The function runs in the module's plugin, on the server and in the browser, just before the
|
|
7
|
+
* storefront is created, so composables such as `useCookie` work in it. It returns the options, not a
|
|
8
|
+
* promise of them: on the server, the app's context does not survive an `await` there.
|
|
9
|
+
*/
|
|
10
|
+
export function defineMoonbaseConfig(config) {
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MoonbaseConfiguration } from '@moonbase.sh/vue';
|
|
2
|
+
import type { MoonbaseOptions } from './config.js';
|
|
3
|
+
/** What the module puts in `runtimeConfig.public.moonbase`, from its options in `nuxt.config`. */
|
|
4
|
+
export interface MoonbaseRuntimeConfig {
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
persistUtm?: boolean;
|
|
7
|
+
includeManifests?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface StorefrontOptions {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
configuration: Omit<MoonbaseConfiguration, 'endpoint'>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The arguments for `createStorefront`: `moonbase.config.ts` over the runtime config, field by field.
|
|
15
|
+
* A field `moonbase.config.ts` leaves `undefined` has not been decided there, so the runtime config's
|
|
16
|
+
* value stands.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveStorefrontOptions(runtime: MoonbaseRuntimeConfig | undefined, app: MoonbaseOptions | undefined): StorefrontOptions;
|
|
19
|
+
/**
|
|
20
|
+
* The path Nuxt rendered the page for, without the `mb_` parameters the storefront has just taken off
|
|
21
|
+
* the address, or `undefined` when it needs no change.
|
|
22
|
+
*
|
|
23
|
+
* Nuxt's router starts from the rendered path rather than the address whenever the two differ, which
|
|
24
|
+
* they do on a page rendered on request for a URL with a query. Left as it is, the router would put
|
|
25
|
+
* the parameters back. Only touched when the storefront did take them off the address, so a
|
|
26
|
+
* parameter it leaves for later, such as `mb_checkout_mode`, stays, and a path without any is never
|
|
27
|
+
* re-encoded.
|
|
28
|
+
*/
|
|
29
|
+
export declare function tidyRenderedPath(renderedPath: string | undefined, addressSearch: string): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { withoutHandshakeParams } from '@moonbase.sh/vue';
|
|
2
|
+
/**
|
|
3
|
+
* The arguments for `createStorefront`: `moonbase.config.ts` over the runtime config, field by field.
|
|
4
|
+
* A field `moonbase.config.ts` leaves `undefined` has not been decided there, so the runtime config's
|
|
5
|
+
* value stands.
|
|
6
|
+
*/
|
|
7
|
+
export function resolveStorefrontOptions(runtime, app) {
|
|
8
|
+
const { endpoint, ...configuration } = { ...definedFields(runtime), ...definedFields(app) };
|
|
9
|
+
if (!endpoint) {
|
|
10
|
+
throw new Error('@moonbase.sh/nuxt has no endpoint for the storefront. Set `moonbase.endpoint` in nuxt.config, '
|
|
11
|
+
+ '`NUXT_PUBLIC_MOONBASE_ENDPOINT` where the app runs, or `endpoint` in moonbase.config.ts.');
|
|
12
|
+
}
|
|
13
|
+
return { endpoint, configuration };
|
|
14
|
+
}
|
|
15
|
+
function definedFields(value) {
|
|
16
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([, field]) => field !== undefined));
|
|
17
|
+
}
|
|
18
|
+
const HANDSHAKE = /[?&]mb_/;
|
|
19
|
+
/**
|
|
20
|
+
* The path Nuxt rendered the page for, without the `mb_` parameters the storefront has just taken off
|
|
21
|
+
* the address, or `undefined` when it needs no change.
|
|
22
|
+
*
|
|
23
|
+
* Nuxt's router starts from the rendered path rather than the address whenever the two differ, which
|
|
24
|
+
* they do on a page rendered on request for a URL with a query. Left as it is, the router would put
|
|
25
|
+
* the parameters back. Only touched when the storefront did take them off the address, so a
|
|
26
|
+
* parameter it leaves for later, such as `mb_checkout_mode`, stays, and a path without any is never
|
|
27
|
+
* re-encoded.
|
|
28
|
+
*/
|
|
29
|
+
export function tidyRenderedPath(renderedPath, addressSearch) {
|
|
30
|
+
if (!renderedPath || !HANDSHAKE.test(renderedPath) || HANDSHAKE.test(addressSearch))
|
|
31
|
+
return undefined;
|
|
32
|
+
// The origin is a placeholder: only the path, query and hash come back out.
|
|
33
|
+
const tidy = new URL(withoutHandshakeParams(new URL(renderedPath, 'http://localhost').href));
|
|
34
|
+
return tidy.pathname + tidy.search + tidy.hash;
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createStorefront } from '@moonbase.sh/vue';
|
|
2
|
+
import { defineNuxtPlugin, useState } from '#app';
|
|
3
|
+
import moonbaseConfig from '#build/moonbase/config.mjs';
|
|
4
|
+
import { resolveStorefrontOptions, tidyRenderedPath } from './options.js';
|
|
5
|
+
const plugin = defineNuxtPlugin({
|
|
6
|
+
name: 'moonbase',
|
|
7
|
+
// Between `nuxt:revive-payload:client` (-30), so `useState` already holds what the server rendered
|
|
8
|
+
// with, and `nuxt:router` (-20). The router reads the address as it starts and writes it back once
|
|
9
|
+
// the app is created, so the storefront has to have taken a finished checkout's `mb_` parameters
|
|
10
|
+
// off the address by then, which it does as it is created. Created any later, as an app's own
|
|
11
|
+
// plugin is, the parameters come back, and a reload reopens the finished checkout.
|
|
12
|
+
order: -25,
|
|
13
|
+
async setup(nuxtApp) {
|
|
14
|
+
// Nothing is awaited before the storefront is created: on the server, the app's context does not
|
|
15
|
+
// survive an `await` here, and both `moonbase.config.ts` and `useState` need it.
|
|
16
|
+
const appOptions = moonbaseConfig?.();
|
|
17
|
+
const { endpoint, configuration } = resolveStorefrontOptions(nuxtApp.$config.public.moonbase, appOptions);
|
|
18
|
+
const storefront = createStorefront(endpoint, (key, state) => useState(key, () => state), configuration);
|
|
19
|
+
if (import.meta.server) {
|
|
20
|
+
// A page still renders without the catalog, and the browser fetches it as it starts, so a
|
|
21
|
+
// failed request here is not worth an error page.
|
|
22
|
+
try {
|
|
23
|
+
await storefront.updateStorefront();
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
console.error('Could not load the Moonbase storefront while rendering, so the browser will', err);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const renderedPath = tidyRenderedPath(nuxtApp.payload.path, window.location.search);
|
|
31
|
+
if (renderedPath !== undefined)
|
|
32
|
+
nuxtApp.payload.path = renderedPath;
|
|
33
|
+
}
|
|
34
|
+
nuxtApp.vueApp.use(storefront);
|
|
35
|
+
return { provide: { moonbase: storefront } };
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/nuxt",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Nuxt module for building storefronts with Moonbase.sh, on @moonbase.sh/vue",
|
|
6
|
+
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/module.d.ts",
|
|
12
|
+
"default": "./dist/module.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/module.js",
|
|
17
|
+
"types": "./dist/module.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@moonbase.sh/vue": "^3.14.1",
|
|
23
|
+
"@nuxt/kit": "^4.5.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@nuxt/schema": "^4.5.2",
|
|
27
|
+
"@types/node": "^20.19.33",
|
|
28
|
+
"nuxt": "^4.5.2",
|
|
29
|
+
"nuxt3": "npm:nuxt@3.14.0",
|
|
30
|
+
"playwright": "1.60.0",
|
|
31
|
+
"rimraf": "^5.0.10",
|
|
32
|
+
"tsup": "^8.5.0",
|
|
33
|
+
"typescript": "~5.8.3",
|
|
34
|
+
"vitest": "^2.1.4",
|
|
35
|
+
"vue": "^3.5.17"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rimraf dist && tsup && tsc -p tsconfig.runtime.json",
|
|
39
|
+
"type-check": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
40
|
+
"lint": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content",
|
|
41
|
+
"lint:fix": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content --fix",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"test:integration": "TEST_INTEGRATION=true vitest run",
|
|
45
|
+
"test:roundtrip": "node test/roundtrip/run.ts"
|
|
46
|
+
}
|
|
6
47
|
}
|