@uniformdev/uniform-nuxt 16.0.1-nuxt.179 → 16.0.1-nuxt.181
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/module.d.ts +9 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -4
- package/dist/runtime/plugin.mjs +44 -33
- package/dist/types.d.ts +1 -5
- package/package.json +9 -7
package/dist/module.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
1
2
|
import { ManifestV2 } from '@uniformdev/context';
|
|
2
3
|
|
|
3
|
-
interface
|
|
4
|
-
projectId
|
|
5
|
-
readOnlyApiKey
|
|
4
|
+
interface UniformModuleOptions {
|
|
5
|
+
projectId: string;
|
|
6
|
+
readOnlyApiKey: string;
|
|
6
7
|
apiHost?: string;
|
|
7
8
|
manifest?: ManifestV2;
|
|
8
9
|
outputType?: string;
|
|
10
|
+
uniformContextPath?: string;
|
|
11
|
+
defaultConsent?: boolean;
|
|
12
|
+
enableContextDevTools?: boolean;
|
|
9
13
|
}
|
|
10
|
-
declare const _default: NuxtModule<
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<UniformModuleOptions>;
|
|
11
15
|
|
|
12
|
-
export {
|
|
16
|
+
export { UniformModuleOptions, _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,25 +1,56 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { defineNuxtModule, addPlugin } from '@nuxt/kit';
|
|
3
|
+
import { defineNuxtModule, resolveAlias, addTemplate, addPlugin, extendViteConfig } from '@nuxt/kit';
|
|
4
4
|
|
|
5
|
+
const uniformContextProxyPath = "uniform/context/instance.ts";
|
|
5
6
|
const module = defineNuxtModule({
|
|
6
7
|
meta: {
|
|
7
8
|
name: "nuxt-uniform",
|
|
8
9
|
configKey: "uniform"
|
|
9
10
|
},
|
|
10
11
|
defaults: {
|
|
11
|
-
projectId:
|
|
12
|
-
readOnlyApiKey:
|
|
12
|
+
projectId: "",
|
|
13
|
+
readOnlyApiKey: "",
|
|
13
14
|
apiHost: "https://uniform.app",
|
|
14
15
|
manifest: void 0,
|
|
15
|
-
outputType: void 0
|
|
16
|
+
outputType: void 0,
|
|
17
|
+
uniformContextPath: void 0,
|
|
18
|
+
defaultConsent: false,
|
|
19
|
+
enableContextDevTools: true
|
|
16
20
|
},
|
|
17
21
|
setup(options, nuxt) {
|
|
22
|
+
if (!options.projectId || !options.readOnlyApiKey) {
|
|
23
|
+
throw new Error("uniform-nuxt: The module options 'projectId' and 'readOnlyApiKey' are required");
|
|
24
|
+
}
|
|
25
|
+
optimizeDeps(["rfdc"]);
|
|
18
26
|
nuxt.options.runtimeConfig.public["$uniform"] = { ...options };
|
|
27
|
+
if (options.uniformContextPath) {
|
|
28
|
+
const resolvedUserContextPath = resolveConfigFilePath(nuxt, options.uniformContextPath);
|
|
29
|
+
addTemplate({
|
|
30
|
+
filename: uniformContextProxyPath,
|
|
31
|
+
getContents: () => `export { default } from '${resolvedUserContextPath}';`
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
addTemplate({
|
|
35
|
+
filename: uniformContextProxyPath,
|
|
36
|
+
getContents: () => `export default undefined;`
|
|
37
|
+
});
|
|
38
|
+
}
|
|
19
39
|
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
|
|
20
40
|
nuxt.options.build.transpile.push(runtimeDir);
|
|
21
41
|
addPlugin(resolve(runtimeDir, "plugin"));
|
|
22
42
|
}
|
|
23
43
|
});
|
|
44
|
+
function resolveConfigFilePath(nuxt, filePath) {
|
|
45
|
+
return resolve(nuxt.options.rootDir, resolveAlias(filePath));
|
|
46
|
+
}
|
|
47
|
+
function optimizeDeps(deps) {
|
|
48
|
+
extendViteConfig((config) => {
|
|
49
|
+
config.optimizeDeps = {
|
|
50
|
+
...config.optimizeDeps,
|
|
51
|
+
include: [...config.optimizeDeps?.include ?? [], ...deps]
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
24
55
|
|
|
25
56
|
export { module as default };
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
useState,
|
|
9
9
|
useCookie
|
|
10
10
|
} from "#app";
|
|
11
|
+
import userProvidedContextInstance from "#build/uniform/context/instance";
|
|
12
|
+
import { watch, toRaw } from "vue-demi";
|
|
11
13
|
import {
|
|
12
14
|
CanvasClient,
|
|
13
15
|
CANVAS_DRAFT_STATE,
|
|
@@ -16,45 +18,55 @@ import {
|
|
|
16
18
|
import {
|
|
17
19
|
Context,
|
|
18
20
|
CookieTransitionDataStore,
|
|
21
|
+
enableContextDevTools,
|
|
19
22
|
UNIFORM_DEFAULT_COOKIE_NAME
|
|
20
23
|
} from "@uniformdev/context";
|
|
21
24
|
import { Composition, SlotContent, useCompositionEventEffect } from "@uniformdev/canvas-vue";
|
|
22
25
|
import {
|
|
23
|
-
provideUniformContext
|
|
26
|
+
provideUniformContext,
|
|
27
|
+
onRouteChange
|
|
24
28
|
} from "@uniformdev/context-vue";
|
|
25
29
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
26
30
|
if (nuxtApp.$uniformIsSetup) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
try {
|
|
34
|
+
const currentCompositionId = useState("currentCompositionId", () => "");
|
|
35
|
+
const preview = setupPreview();
|
|
36
|
+
const uniformContextData = setupContext(nuxtApp);
|
|
37
|
+
const uniformCanvasClient = setupCanvas(nuxtApp);
|
|
38
|
+
setupLivePreview(currentCompositionId, Boolean(preview));
|
|
39
|
+
const useComposition = setupUseComposition(uniformCanvasClient, currentCompositionId, preview);
|
|
40
|
+
return {
|
|
41
|
+
provide: {
|
|
42
|
+
uniformIsSetup: true,
|
|
43
|
+
preview,
|
|
44
|
+
uniformCanvasClient,
|
|
45
|
+
uniformContext: uniformContextData.context,
|
|
46
|
+
useComposition
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.log("uniform-nuxt: An error occurred while initializing the Uniform plugin", e);
|
|
51
|
+
}
|
|
45
52
|
});
|
|
46
53
|
function setupContext(nuxtApp) {
|
|
47
|
-
const options =
|
|
54
|
+
const options = getModuleOptions();
|
|
48
55
|
const uniformCookie = useCookie(UNIFORM_DEFAULT_COOKIE_NAME).value;
|
|
49
|
-
let uniformContext;
|
|
50
|
-
if (
|
|
56
|
+
let uniformContext = userProvidedContextInstance;
|
|
57
|
+
if (uniformContext !== void 0 && !uniformContext.manifest) {
|
|
58
|
+
throw new Error(`uniform-nuxt: The Uniform Context instance returned by ${options.uniformContextPath} is not valid`);
|
|
59
|
+
}
|
|
60
|
+
if (!uniformContext && options.manifest) {
|
|
51
61
|
console.log("uniform-nuxt: \u{1F4DC} found a manifest, will initialize Context");
|
|
62
|
+
const manifestAsSimpleObject = toRaw(options.manifest);
|
|
52
63
|
uniformContext = new Context({
|
|
53
|
-
defaultConsent:
|
|
54
|
-
manifest:
|
|
64
|
+
defaultConsent: Boolean(options.defaultConsent),
|
|
65
|
+
manifest: manifestAsSimpleObject,
|
|
55
66
|
transitionStore: new CookieTransitionDataStore({
|
|
56
67
|
serverCookieValue: uniformCookie
|
|
57
|
-
})
|
|
68
|
+
}),
|
|
69
|
+
plugins: options.enableContextDevTools ? [enableContextDevTools()] : void 0
|
|
58
70
|
});
|
|
59
71
|
}
|
|
60
72
|
provideUniformContext({
|
|
@@ -62,19 +74,15 @@ function setupContext(nuxtApp) {
|
|
|
62
74
|
outputType: options.outputType,
|
|
63
75
|
vueAppInstance: nuxtApp.vueApp
|
|
64
76
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
outputType: options.outputType,
|
|
70
|
-
vueAppInstance: nuxtApp.vueApp
|
|
71
|
-
});
|
|
77
|
+
const route = useRoute();
|
|
78
|
+
watch(() => JSON.stringify(route.query), () => {
|
|
79
|
+
if (uniformContext)
|
|
80
|
+
onRouteChange(uniformContext);
|
|
72
81
|
});
|
|
73
|
-
console.log("setupContext nuxtApp.vueApp._uid", nuxtApp.vueApp._uid);
|
|
74
82
|
return { context: uniformContext, outputType: options.outputType };
|
|
75
83
|
}
|
|
76
84
|
function setupCanvas(nuxtApp) {
|
|
77
|
-
const options =
|
|
85
|
+
const options = getModuleOptions();
|
|
78
86
|
nuxtApp.vueApp.component("Composition", Composition);
|
|
79
87
|
nuxtApp.vueApp.component("SlotContent", SlotContent);
|
|
80
88
|
const uniformCanvasClient = new CanvasClient({
|
|
@@ -96,7 +104,7 @@ function setupPreview() {
|
|
|
96
104
|
return preview;
|
|
97
105
|
}
|
|
98
106
|
function setupLivePreview(currentCompositionId, isPreview = false) {
|
|
99
|
-
const { projectId } =
|
|
107
|
+
const { projectId } = getModuleOptions();
|
|
100
108
|
const enabled = isPreview;
|
|
101
109
|
const onCompositionChange = async () => {
|
|
102
110
|
await refreshNuxtData();
|
|
@@ -122,3 +130,6 @@ function setupUseComposition(uniformCanvasClient, currentCompositionId, preview)
|
|
|
122
130
|
};
|
|
123
131
|
return useComposition;
|
|
124
132
|
}
|
|
133
|
+
function getModuleOptions() {
|
|
134
|
+
return useRuntimeConfig().public.$uniform;
|
|
135
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { } from './module'
|
|
3
3
|
|
|
4
|
-
declare module '@nuxt/schema' {
|
|
5
|
-
interface NuxtConfig { ['uniform']?: Partial<ModuleOptions> }
|
|
6
|
-
interface NuxtOptions { ['uniform']?: ModuleOptions }
|
|
7
|
-
}
|
|
8
4
|
|
|
9
5
|
|
|
10
6
|
export { default } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/uniform-nuxt",
|
|
3
|
-
"version": "16.0.1-nuxt.
|
|
3
|
+
"version": "16.0.1-nuxt.181+d2c9a0bbf",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,17 +30,19 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@nuxt/module-builder": "0.1.7",
|
|
33
|
+
"@nuxt/schema": "3.0.0-rc.4",
|
|
33
34
|
"@nuxtjs/eslint-config-typescript": "10.0.0",
|
|
34
|
-
"@uniformdev/canvas": "^16.0.1-nuxt.
|
|
35
|
-
"@uniformdev/canvas-vue": "^16.0.1-nuxt.
|
|
36
|
-
"@uniformdev/context": "^16.0.1-nuxt.
|
|
37
|
-
"@uniformdev/context-vue": "^16.0.1-nuxt.
|
|
35
|
+
"@uniformdev/canvas": "^16.0.1-nuxt.181+d2c9a0bbf",
|
|
36
|
+
"@uniformdev/canvas-vue": "^16.0.1-nuxt.181+d2c9a0bbf",
|
|
37
|
+
"@uniformdev/context": "^16.0.1-nuxt.181+d2c9a0bbf",
|
|
38
|
+
"@uniformdev/context-vue": "^16.0.1-nuxt.181+d2c9a0bbf",
|
|
38
39
|
"esbuild": "0.13.15",
|
|
39
40
|
"eslint": "latest",
|
|
40
|
-
"nuxt": "^3.0.0-rc.4"
|
|
41
|
+
"nuxt": "^3.0.0-rc.4",
|
|
42
|
+
"vue": "3.2.37"
|
|
41
43
|
},
|
|
42
44
|
"publishConfig": {
|
|
43
45
|
"access": "public"
|
|
44
46
|
},
|
|
45
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d2c9a0bbf7c8a640213fee2f6eae7c1cfdd08b02"
|
|
46
48
|
}
|