@yext/visual-editor 0.0.38 → 0.0.40

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.
@@ -1,267 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("node:path"),i=require("fs-extra"),p=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
2
- import "@yext/visual-editor/style.css";
3
- import {
4
- Template,
5
- GetPath,
6
- TemplateProps,
7
- TemplateRenderProps,
8
- GetHeadConfig,
9
- HeadConfig,
10
- TagType,
11
- } from "@yext/pages";
12
- import { Render } from "@measured/puck";
13
- import { mainConfig } from "../ve.config";
14
- import {
15
- applyTheme,
16
- VisualEditorProvider,
17
- normalizeSlug,
18
- getPageMetadata,
19
- applyAnalytics,
20
- } from "@yext/visual-editor";
21
- import { themeConfig } from "../../theme.config";
22
- import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
23
-
24
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
25
- document,
26
- }): HeadConfig => {
27
- const { title, description } = getPageMetadata(document);
28
- const faviconUrl = document?._site?.favicon?.url;
29
-
30
- return {
31
- title: title,
32
- charset: "UTF-8",
33
- viewport: "width=device-width, initial-scale=1",
34
- tags: [
35
- {
36
- type: "link",
37
- attributes: {
38
- rel: "icon",
39
- type: "image/x-icon",
40
- },
41
- },
42
- ...(description
43
- ? [
44
- {
45
- type: "meta" as TagType,
46
- attributes: {
47
- name: "description",
48
- content: description,
49
- },
50
- },
51
- ]
52
- : []),
53
- ...(faviconUrl
54
- ? [
55
- {
56
- type: "link" as TagType,
57
- attributes: {
58
- rel: "icon",
59
- type: "image/x-icon",
60
- href: faviconUrl,
61
- },
62
- },
63
- ]
64
- : []),
65
- ],
66
- other: [
67
- applyAnalytics(document),
68
- applyTheme(document, themeConfig),
69
- SchemaWrapper(document._schema),
70
- ].join("\\n"),
71
- };
72
- };
73
-
74
- export const getPath: GetPath<TemplateProps> = ({ document }) => {
75
- if (document.slug) {
76
- return document.slug;
77
- }
78
-
79
- const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
80
- const path = document.address
81
- ? \`\${localePath}\${document.address.region}/\${document.address.city}/\${document.address.line1}\`
82
- : \`\${localePath}\${document.id}\`;
83
-
84
- return normalizeSlug(path);
85
- };
86
-
87
- const Location: Template<TemplateRenderProps> = (props) => {
88
- const { document } = props;
89
-
90
- return (
91
- <AnalyticsProvider
92
- apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
93
- templateData={props}
94
- currency="USD"
95
- >
96
- <VisualEditorProvider templateProps={props}>
97
- <Render config={mainConfig} data={JSON.parse(document.__.layout)} />
98
- </VisualEditorProvider>
99
- </AnalyticsProvider>
100
- );
101
- };
102
-
103
- export default Location;
104
- `,d=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
105
- import {
106
- applyTheme,
107
- Editor,
108
- usePlatformBridgeDocument,
109
- usePlatformBridgeEntityFields,
110
- VisualEditorProvider,
111
- } from "@yext/visual-editor";
112
- import { componentRegistry } from "../ve.config";
113
- import {
114
- GetPath,
115
- TemplateProps,
116
- TemplateConfig,
117
- HeadConfig,
118
- TemplateRenderProps,
119
- GetHeadConfig,
120
- } from "@yext/pages";
121
- import { themeConfig } from "../../theme.config";
122
- import tailwindConfig from "../../tailwind.config";
123
-
124
- // Editor is avaliable at /edit
125
- export const getPath: GetPath<TemplateProps> = () => {
126
- return "edit";
127
- };
128
-
129
- export const config: TemplateConfig = {
130
- name: "edit",
131
- };
132
-
133
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
134
- document,
135
- }): HeadConfig => {
136
- return {
137
- other: applyTheme(document, themeConfig),
138
- };
139
- };
140
-
141
- // Render the editor
142
- const Edit: () => JSX.Element = () => {
143
- const entityDocument = usePlatformBridgeDocument();
144
- const entityFields = usePlatformBridgeEntityFields();
145
-
146
- return (
147
- <VisualEditorProvider
148
- templateProps={{
149
- document: entityDocument,
150
- }}
151
- entityFields={entityFields}
152
- tailwindConfig={tailwindConfig}
153
- >
154
- <Editor
155
- document={entityDocument}
156
- componentRegistry={componentRegistry}
157
- themeConfig={themeConfig}
158
- />
159
- </VisualEditorProvider>
160
- );
161
- };
162
-
163
- export default Edit;
164
- `,l=`import "@yext/visual-editor/style.css";
165
- import {
166
- Template,
167
- GetPath,
168
- TemplateProps,
169
- TemplateRenderProps,
170
- GetHeadConfig,
171
- HeadConfig,
172
- TagType,
173
- } from "@yext/pages";
174
- import { Render } from "@measured/puck";
175
- import { directoryConfig } from "../ve.config";
176
- import {
177
- applyTheme,
178
- VisualEditorProvider,
179
- normalizeSlug,
180
- getPageMetadata,
181
- applyAnalytics,
182
- } from "@yext/visual-editor";
183
- import { themeConfig } from "../../theme.config";
184
- import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
185
-
186
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
187
- document,
188
- }): HeadConfig => {
189
- const { title, description } = getPageMetadata(document);
190
- const faviconUrl = document?._site?.favicon?.url;
191
-
192
- return {
193
- title: title,
194
- charset: "UTF-8",
195
- viewport: "width=device-width, initial-scale=1",
196
- tags: [
197
- {
198
- type: "link",
199
- attributes: {
200
- rel: "icon",
201
- type: "image/x-icon",
202
- },
203
- },
204
- ...(description
205
- ? [
206
- {
207
- type: "meta" as TagType,
208
- attributes: {
209
- name: "description",
210
- content: description,
211
- },
212
- },
213
- ]
214
- : []),
215
- ...(faviconUrl
216
- ? [
217
- {
218
- type: "link" as TagType,
219
- attributes: {
220
- rel: "icon",
221
- type: "image/x-icon",
222
- href: faviconUrl,
223
- },
224
- },
225
- ]
226
- : []),
227
- ],
228
- other: [
229
- applyAnalytics(document),
230
- applyTheme(document, themeConfig),
231
- SchemaWrapper(document._schema),
232
- ].join("\\n"),
233
- };
234
- };
235
-
236
- export const getPath: GetPath<TemplateProps> = ({ document }) => {
237
- if (document.slug) {
238
- return document.slug;
239
- }
240
-
241
- const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
242
- const path = \`\${localePath}\${document.id}\`;
243
-
244
- return normalizeSlug(path);
245
- };
246
-
247
- const Directory: Template<TemplateRenderProps> = (props) => {
248
- const { document } = props;
249
-
250
- return (
251
- <AnalyticsProvider
252
- apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
253
- templateData={props}
254
- currency="USD"
255
- >
256
- <VisualEditorProvider templateProps={props}>
257
- <Render
258
- config={directoryConfig}
259
- data={JSON.parse(document.__.layout)}
260
- />
261
- </VisualEditorProvider>
262
- </AnalyticsProvider>
263
- );
264
- };
265
-
266
- export default Directory;
267
- `,m={"src/templates/main.tsx":p,"src/templates/edit.tsx":d,"src/templates/directory.tsx":l},u=()=>{let e=!1;const a=[],c=()=>{Object.entries(m).forEach(([n,r])=>{const o=s.join(process.cwd(),n);a.push(o),i.mkdirSync(s.dirname(o),{recursive:!0}),!i.existsSync(o)&&i.writeFileSync(o,r)})},t=()=>{a.forEach(n=>{i.rmSync(n,{force:!0})})};return process.on("SIGINT",()=>{t(),process.nextTick(()=>process.exit(0))}),process.on("SIGTERM",()=>{t(),process.nextTick(()=>process.exit(0))}),{name:"vite-plugin-yext-visual-editor",config(n,{command:r}){e=r==="build"},configureServer(n){e||(c(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&c()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BBlk-mUB.cjs");exports.yextVisualEditorPlugin=e.yextVisualEditorPlugin;
@@ -1,312 +1,4 @@
1
- import s from "node:path";
2
- import i from "fs-extra";
3
- const p = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
4
- import "@yext/visual-editor/style.css";
5
- import {
6
- Template,
7
- GetPath,
8
- TemplateProps,
9
- TemplateRenderProps,
10
- GetHeadConfig,
11
- HeadConfig,
12
- TagType,
13
- } from "@yext/pages";
14
- import { Render } from "@measured/puck";
15
- import { mainConfig } from "../ve.config";
16
- import {
17
- applyTheme,
18
- VisualEditorProvider,
19
- normalizeSlug,
20
- getPageMetadata,
21
- applyAnalytics,
22
- } from "@yext/visual-editor";
23
- import { themeConfig } from "../../theme.config";
24
- import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
25
-
26
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
27
- document,
28
- }): HeadConfig => {
29
- const { title, description } = getPageMetadata(document);
30
- const faviconUrl = document?._site?.favicon?.url;
31
-
32
- return {
33
- title: title,
34
- charset: "UTF-8",
35
- viewport: "width=device-width, initial-scale=1",
36
- tags: [
37
- {
38
- type: "link",
39
- attributes: {
40
- rel: "icon",
41
- type: "image/x-icon",
42
- },
43
- },
44
- ...(description
45
- ? [
46
- {
47
- type: "meta" as TagType,
48
- attributes: {
49
- name: "description",
50
- content: description,
51
- },
52
- },
53
- ]
54
- : []),
55
- ...(faviconUrl
56
- ? [
57
- {
58
- type: "link" as TagType,
59
- attributes: {
60
- rel: "icon",
61
- type: "image/x-icon",
62
- href: faviconUrl,
63
- },
64
- },
65
- ]
66
- : []),
67
- ],
68
- other: [
69
- applyAnalytics(document),
70
- applyTheme(document, themeConfig),
71
- SchemaWrapper(document._schema),
72
- ].join("\\n"),
73
- };
74
- };
75
-
76
- export const getPath: GetPath<TemplateProps> = ({ document }) => {
77
- if (document.slug) {
78
- return document.slug;
79
- }
80
-
81
- const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
82
- const path = document.address
83
- ? \`\${localePath}\${document.address.region}/\${document.address.city}/\${document.address.line1}\`
84
- : \`\${localePath}\${document.id}\`;
85
-
86
- return normalizeSlug(path);
87
- };
88
-
89
- const Location: Template<TemplateRenderProps> = (props) => {
90
- const { document } = props;
91
-
92
- return (
93
- <AnalyticsProvider
94
- apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
95
- templateData={props}
96
- currency="USD"
97
- >
98
- <VisualEditorProvider templateProps={props}>
99
- <Render config={mainConfig} data={JSON.parse(document.__.layout)} />
100
- </VisualEditorProvider>
101
- </AnalyticsProvider>
102
- );
103
- };
104
-
105
- export default Location;
106
- `, d = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
107
- import {
108
- applyTheme,
109
- Editor,
110
- usePlatformBridgeDocument,
111
- usePlatformBridgeEntityFields,
112
- VisualEditorProvider,
113
- } from "@yext/visual-editor";
114
- import { componentRegistry } from "../ve.config";
115
- import {
116
- GetPath,
117
- TemplateProps,
118
- TemplateConfig,
119
- HeadConfig,
120
- TemplateRenderProps,
121
- GetHeadConfig,
122
- } from "@yext/pages";
123
- import { themeConfig } from "../../theme.config";
124
- import tailwindConfig from "../../tailwind.config";
125
-
126
- // Editor is avaliable at /edit
127
- export const getPath: GetPath<TemplateProps> = () => {
128
- return "edit";
129
- };
130
-
131
- export const config: TemplateConfig = {
132
- name: "edit",
133
- };
134
-
135
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
136
- document,
137
- }): HeadConfig => {
138
- return {
139
- other: applyTheme(document, themeConfig),
140
- };
141
- };
142
-
143
- // Render the editor
144
- const Edit: () => JSX.Element = () => {
145
- const entityDocument = usePlatformBridgeDocument();
146
- const entityFields = usePlatformBridgeEntityFields();
147
-
148
- return (
149
- <VisualEditorProvider
150
- templateProps={{
151
- document: entityDocument,
152
- }}
153
- entityFields={entityFields}
154
- tailwindConfig={tailwindConfig}
155
- >
156
- <Editor
157
- document={entityDocument}
158
- componentRegistry={componentRegistry}
159
- themeConfig={themeConfig}
160
- />
161
- </VisualEditorProvider>
162
- );
163
- };
164
-
165
- export default Edit;
166
- `, m = `import "@yext/visual-editor/style.css";
167
- import {
168
- Template,
169
- GetPath,
170
- TemplateProps,
171
- TemplateRenderProps,
172
- GetHeadConfig,
173
- HeadConfig,
174
- TagType,
175
- } from "@yext/pages";
176
- import { Render } from "@measured/puck";
177
- import { directoryConfig } from "../ve.config";
178
- import {
179
- applyTheme,
180
- VisualEditorProvider,
181
- normalizeSlug,
182
- getPageMetadata,
183
- applyAnalytics,
184
- } from "@yext/visual-editor";
185
- import { themeConfig } from "../../theme.config";
186
- import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
187
-
188
- export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
189
- document,
190
- }): HeadConfig => {
191
- const { title, description } = getPageMetadata(document);
192
- const faviconUrl = document?._site?.favicon?.url;
193
-
194
- return {
195
- title: title,
196
- charset: "UTF-8",
197
- viewport: "width=device-width, initial-scale=1",
198
- tags: [
199
- {
200
- type: "link",
201
- attributes: {
202
- rel: "icon",
203
- type: "image/x-icon",
204
- },
205
- },
206
- ...(description
207
- ? [
208
- {
209
- type: "meta" as TagType,
210
- attributes: {
211
- name: "description",
212
- content: description,
213
- },
214
- },
215
- ]
216
- : []),
217
- ...(faviconUrl
218
- ? [
219
- {
220
- type: "link" as TagType,
221
- attributes: {
222
- rel: "icon",
223
- type: "image/x-icon",
224
- href: faviconUrl,
225
- },
226
- },
227
- ]
228
- : []),
229
- ],
230
- other: [
231
- applyAnalytics(document),
232
- applyTheme(document, themeConfig),
233
- SchemaWrapper(document._schema),
234
- ].join("\\n"),
235
- };
236
- };
237
-
238
- export const getPath: GetPath<TemplateProps> = ({ document }) => {
239
- if (document.slug) {
240
- return document.slug;
241
- }
242
-
243
- const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
244
- const path = \`\${localePath}\${document.id}\`;
245
-
246
- return normalizeSlug(path);
247
- };
248
-
249
- const Directory: Template<TemplateRenderProps> = (props) => {
250
- const { document } = props;
251
-
252
- return (
253
- <AnalyticsProvider
254
- apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
255
- templateData={props}
256
- currency="USD"
257
- >
258
- <VisualEditorProvider templateProps={props}>
259
- <Render
260
- config={directoryConfig}
261
- data={JSON.parse(document.__.layout)}
262
- />
263
- </VisualEditorProvider>
264
- </AnalyticsProvider>
265
- );
266
- };
267
-
268
- export default Directory;
269
- `, l = {
270
- "src/templates/main.tsx": p,
271
- "src/templates/edit.tsx": d,
272
- "src/templates/directory.tsx": m
273
- }, g = () => {
274
- let e = !1;
275
- const a = [], c = () => {
276
- Object.entries(l).forEach(([n, r]) => {
277
- const o = s.join(process.cwd(), n);
278
- a.push(o), i.mkdirSync(s.dirname(o), { recursive: !0 }), !i.existsSync(o) && i.writeFileSync(o, r);
279
- });
280
- }, t = () => {
281
- a.forEach((n) => {
282
- i.rmSync(n, { force: !0 });
283
- });
284
- };
285
- return process.on("SIGINT", () => {
286
- t(), process.nextTick(() => process.exit(0));
287
- }), process.on("SIGTERM", () => {
288
- t(), process.nextTick(() => process.exit(0));
289
- }), {
290
- name: "vite-plugin-yext-visual-editor",
291
- config(n, { command: r }) {
292
- e = r === "build";
293
- },
294
- configureServer(n) {
295
- e || (c(), n.httpServer?.on("close", () => {
296
- t();
297
- }));
298
- },
299
- buildStart() {
300
- e && c();
301
- },
302
- buildEnd() {
303
- e && t();
304
- },
305
- closeBundle() {
306
- e && t();
307
- }
308
- };
309
- };
1
+ import { y as r } from "./index-C2zkTc1a.js";
310
2
  export {
311
- g as yextVisualEditorPlugin
3
+ r as yextVisualEditorPlugin
312
4
  };