@yext/visual-editor 0.0.37 → 0.0.39

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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("node:path"),i=require("fs-extra"),d=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("node:path"),r=require("fs-extra"),d=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
2
2
  import "@yext/visual-editor/style.css";
3
3
  import {
4
4
  Template,
@@ -17,10 +17,10 @@ import {
17
17
  normalizeSlug,
18
18
  getPageMetadata,
19
19
  applyAnalytics,
20
+ applyHeaderScript,
20
21
  } from "@yext/visual-editor";
21
22
  import { themeConfig } from "../../theme.config";
22
- import { buildSchema } from "../utils/buildSchema";
23
- import { AnalyticsProvider } from "@yext/pages-components";
23
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
24
24
 
25
25
  export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
26
26
  document,
@@ -66,8 +66,9 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
66
66
  ],
67
67
  other: [
68
68
  applyAnalytics(document),
69
+ applyHeaderScript(document),
69
70
  applyTheme(document, themeConfig),
70
- buildSchema(document),
71
+ SchemaWrapper(document._schema),
71
72
  ].join("\\n"),
72
73
  };
73
74
  };
@@ -102,7 +103,7 @@ const Location: Template<TemplateRenderProps> = (props) => {
102
103
  };
103
104
 
104
105
  export default Location;
105
- `,l=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
106
+ `,p=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
106
107
  import {
107
108
  applyTheme,
108
109
  Editor,
@@ -135,7 +136,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
135
136
  document,
136
137
  }): HeadConfig => {
137
138
  return {
138
- other: applyTheme(document, themeConfig),
139
+ other: fullStorySnippet + applyTheme(document, themeConfig),
139
140
  };
140
141
  };
141
142
 
@@ -162,4 +163,134 @@ const Edit: () => JSX.Element = () => {
162
163
  };
163
164
 
164
165
  export default Edit;
165
- `,m={"src/templates/main.tsx":d,"src/templates/edit.tsx":l},p=()=>{let e=!1;const a=[],s=()=>{Object.entries(m).forEach(([n,r])=>{const o=c.join(process.cwd(),n);a.push(o),i.mkdirSync(c.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||(s(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&s()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=p;
166
+
167
+ const fullStorySnippet = \`<script>
168
+ window['_fs_run_in_iframe'] = true;
169
+ window['_fs_debug'] = false;
170
+ window['_fs_host'] = 'fullstory.com';
171
+ window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
172
+ window['_fs_org'] = 'o-1RWKDJ-na1';
173
+ window['_fs_namespace'] = 'FS';
174
+ !function(m,n,e,t,l,o,g,y){var s,f,a=function(h){
175
+ return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e)
176
+ ;function j(b){var h,d=[];function k(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))}
177
+ d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],k())}}return b(r(0),r(1)),{
178
+ then:function(b,h){return j((function(r,i){d.push([b,h,r,i]),k()}))}}}a&&(g=m[e]=function(){var b=function(b,d,k,r){function i(i,c){
179
+ h(b,d,k,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):j(i)):h(b,d,k,c,c,r)}
180
+ ;function h(h,d,k,r,i,c){return b._api?b._api(h,d,k,r,i,c):(b.q&&b.q.push([h,d,k,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){
181
+ "function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var k=0;k<d.length;k++)h(d[k]);d.length=0,d.push=h}},function(){
182
+ (o=n.createElement(t)).async=!0,o.crossOrigin="anonymous",o.src="https://"+l,o.onerror=function(){y("Error loading "+l)}
183
+ ;var b=n.getElementsByTagName(t)[0];b.parentNode.insertBefore(o,b)}(),function(){function b(){}function h(b,h,d){g(b,h,d,1)}function d(b,d,k){
184
+ h("setProperties",{type:b,properties:d},k)}function k(b,h){d("user",b,h)}function r(b,h,d){k({uid:b},d),h&&k(h,d)}g.identify=r,g.setUserVars=k,
185
+ g.identifyAccount=b,g.clearUserCookie=b,g.setVars=d,g.event=function(b,d,k){h("trackEvent",{name:b,properties:d},k)},g.anonymize=function(){r(!1)
186
+ },g.shutdown=function(){h("shutdown")},g.restart=function(){h("restart")},g.log=function(b,d){h("log",{level:b,msg:d})},g.consent=function(b){
187
+ h("setIdentity",{consent:!arguments.length||b})}}(),s="fetch",f="XMLHttpRequest",g._w={},g._w[f]=m[f],g._w[s]=m[s],m[s]&&(m[s]=function(){
188
+ return g._w[s].apply(this,arguments)}),g._v="2.0.0")}(window,document,window._fs_namespace,"script",window._fs_script);
189
+ <\/script>\`;
190
+ `,l=`/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
191
+ import "@yext/visual-editor/style.css";
192
+ import {
193
+ Template,
194
+ GetPath,
195
+ TemplateProps,
196
+ TemplateRenderProps,
197
+ GetHeadConfig,
198
+ HeadConfig,
199
+ TagType,
200
+ } from "@yext/pages";
201
+ import { Render } from "@measured/puck";
202
+ import { directoryConfig } from "../ve.config";
203
+ import {
204
+ applyTheme,
205
+ VisualEditorProvider,
206
+ normalizeSlug,
207
+ getPageMetadata,
208
+ applyAnalytics,
209
+ applyHeaderScript,
210
+ } from "@yext/visual-editor";
211
+ import { themeConfig } from "../../theme.config";
212
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
213
+
214
+ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
215
+ document,
216
+ }): HeadConfig => {
217
+ const { title, description } = getPageMetadata(document);
218
+ const faviconUrl = document?._site?.favicon?.url;
219
+
220
+ return {
221
+ title: title,
222
+ charset: "UTF-8",
223
+ viewport: "width=device-width, initial-scale=1",
224
+ tags: [
225
+ {
226
+ type: "link",
227
+ attributes: {
228
+ rel: "icon",
229
+ type: "image/x-icon",
230
+ },
231
+ },
232
+ ...(description
233
+ ? [
234
+ {
235
+ type: "meta" as TagType,
236
+ attributes: {
237
+ name: "description",
238
+ content: description,
239
+ },
240
+ },
241
+ ]
242
+ : []),
243
+ ...(faviconUrl
244
+ ? [
245
+ {
246
+ type: "link" as TagType,
247
+ attributes: {
248
+ rel: "icon",
249
+ type: "image/x-icon",
250
+ href: faviconUrl,
251
+ },
252
+ },
253
+ ]
254
+ : []),
255
+ ],
256
+ other: [
257
+ applyAnalytics(document),
258
+ applyHeaderScript(document),
259
+ applyTheme(document, themeConfig),
260
+ SchemaWrapper(document._schema),
261
+ ].join("\\n"),
262
+ };
263
+ };
264
+
265
+ export const getPath: GetPath<TemplateProps> = ({ document }) => {
266
+ if (document.slug) {
267
+ return document.slug;
268
+ }
269
+
270
+ const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
271
+ const path = \`\${localePath}\${document.id}\`;
272
+
273
+ return normalizeSlug(path);
274
+ };
275
+
276
+ const Directory: Template<TemplateRenderProps> = (props) => {
277
+ const { document } = props;
278
+
279
+ return (
280
+ <AnalyticsProvider
281
+ apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
282
+ templateData={props}
283
+ currency="USD"
284
+ >
285
+ <VisualEditorProvider templateProps={props}>
286
+ <Render
287
+ config={directoryConfig}
288
+ data={JSON.parse(document.__.layout)}
289
+ />
290
+ </VisualEditorProvider>
291
+ </AnalyticsProvider>
292
+ );
293
+ };
294
+
295
+ export default Directory;
296
+ `,m={"src/templates/main.tsx":d,"src/templates/edit.tsx":p,"src/templates/directory.tsx":l},u=()=>{let e=!1;const a=[],c=()=>{Object.entries(m).forEach(([n,i])=>{const o=s.join(process.cwd(),n);a.push(o),r.mkdirSync(s.dirname(o),{recursive:!0}),!r.existsSync(o)&&r.writeFileSync(o,i)})},t=()=>{a.forEach(n=>{r.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:i}){e=i==="build"},configureServer(n){e||(c(),n.httpServer?.on("close",()=>{t()}))},buildStart(){e&&c()},buildEnd(){e&&t()},closeBundle(){e&&t()}}};exports.yextVisualEditorPlugin=u;
@@ -1,5 +1,5 @@
1
- import c from "node:path";
2
- import i from "fs-extra";
1
+ import s from "node:path";
2
+ import r from "fs-extra";
3
3
  const d = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
4
4
  import "@yext/visual-editor/style.css";
5
5
  import {
@@ -19,10 +19,10 @@ import {
19
19
  normalizeSlug,
20
20
  getPageMetadata,
21
21
  applyAnalytics,
22
+ applyHeaderScript,
22
23
  } from "@yext/visual-editor";
23
24
  import { themeConfig } from "../../theme.config";
24
- import { buildSchema } from "../utils/buildSchema";
25
- import { AnalyticsProvider } from "@yext/pages-components";
25
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
26
26
 
27
27
  export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
28
28
  document,
@@ -68,8 +68,9 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
68
68
  ],
69
69
  other: [
70
70
  applyAnalytics(document),
71
+ applyHeaderScript(document),
71
72
  applyTheme(document, themeConfig),
72
- buildSchema(document),
73
+ SchemaWrapper(document._schema),
73
74
  ].join("\\n"),
74
75
  };
75
76
  };
@@ -104,7 +105,7 @@ const Location: Template<TemplateRenderProps> = (props) => {
104
105
  };
105
106
 
106
107
  export default Location;
107
- `, m = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
108
+ `, p = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
108
109
  import {
109
110
  applyTheme,
110
111
  Editor,
@@ -137,7 +138,7 @@ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
137
138
  document,
138
139
  }): HeadConfig => {
139
140
  return {
140
- other: applyTheme(document, themeConfig),
141
+ other: fullStorySnippet + applyTheme(document, themeConfig),
141
142
  };
142
143
  };
143
144
 
@@ -164,19 +165,150 @@ const Edit: () => JSX.Element = () => {
164
165
  };
165
166
 
166
167
  export default Edit;
167
- `, l = {
168
+
169
+ const fullStorySnippet = \`<script>
170
+ window['_fs_run_in_iframe'] = true;
171
+ window['_fs_debug'] = false;
172
+ window['_fs_host'] = 'fullstory.com';
173
+ window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
174
+ window['_fs_org'] = 'o-1RWKDJ-na1';
175
+ window['_fs_namespace'] = 'FS';
176
+ !function(m,n,e,t,l,o,g,y){var s,f,a=function(h){
177
+ return!(h in m)||(m.console&&m.console.log&&m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].'),!1)}(e)
178
+ ;function j(b){var h,d=[];function k(){h&&(d.forEach((function(b){var d;try{d=b[h[0]]&&b[h[0]](h[1])}catch(h){return void(b[3]&&b[3](h))}
179
+ d&&d.then?d.then(b[2],b[3]):b[2]&&b[2](d)})),d.length=0)}function r(b){return function(d){h||(h=[b,d],k())}}return b(r(0),r(1)),{
180
+ then:function(b,h){return j((function(r,i){d.push([b,h,r,i]),k()}))}}}a&&(g=m[e]=function(){var b=function(b,d,k,r){function i(i,c){
181
+ h(b,d,k,i,c,r)}r=r||2;var c,u=/Async$/;return u.test(b)?(b=b.replace(u,""),"function"==typeof Promise?new Promise(i):j(i)):h(b,d,k,c,c,r)}
182
+ ;function h(h,d,k,r,i,c){return b._api?b._api(h,d,k,r,i,c):(b.q&&b.q.push([h,d,k,r,i,c]),null)}return b.q=[],b}(),y=function(b){function h(h){
183
+ "function"==typeof h[4]&&h[4](new Error(b))}var d=g.q;if(d){for(var k=0;k<d.length;k++)h(d[k]);d.length=0,d.push=h}},function(){
184
+ (o=n.createElement(t)).async=!0,o.crossOrigin="anonymous",o.src="https://"+l,o.onerror=function(){y("Error loading "+l)}
185
+ ;var b=n.getElementsByTagName(t)[0];b.parentNode.insertBefore(o,b)}(),function(){function b(){}function h(b,h,d){g(b,h,d,1)}function d(b,d,k){
186
+ h("setProperties",{type:b,properties:d},k)}function k(b,h){d("user",b,h)}function r(b,h,d){k({uid:b},d),h&&k(h,d)}g.identify=r,g.setUserVars=k,
187
+ g.identifyAccount=b,g.clearUserCookie=b,g.setVars=d,g.event=function(b,d,k){h("trackEvent",{name:b,properties:d},k)},g.anonymize=function(){r(!1)
188
+ },g.shutdown=function(){h("shutdown")},g.restart=function(){h("restart")},g.log=function(b,d){h("log",{level:b,msg:d})},g.consent=function(b){
189
+ h("setIdentity",{consent:!arguments.length||b})}}(),s="fetch",f="XMLHttpRequest",g._w={},g._w[f]=m[f],g._w[s]=m[s],m[s]&&(m[s]=function(){
190
+ return g._w[s].apply(this,arguments)}),g._v="2.0.0")}(window,document,window._fs_namespace,"script",window._fs_script);
191
+ <\/script>\`;
192
+ `, l = `/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */
193
+ import "@yext/visual-editor/style.css";
194
+ import {
195
+ Template,
196
+ GetPath,
197
+ TemplateProps,
198
+ TemplateRenderProps,
199
+ GetHeadConfig,
200
+ HeadConfig,
201
+ TagType,
202
+ } from "@yext/pages";
203
+ import { Render } from "@measured/puck";
204
+ import { directoryConfig } from "../ve.config";
205
+ import {
206
+ applyTheme,
207
+ VisualEditorProvider,
208
+ normalizeSlug,
209
+ getPageMetadata,
210
+ applyAnalytics,
211
+ applyHeaderScript,
212
+ } from "@yext/visual-editor";
213
+ import { themeConfig } from "../../theme.config";
214
+ import { AnalyticsProvider, SchemaWrapper } from "@yext/pages-components";
215
+
216
+ export const getHeadConfig: GetHeadConfig<TemplateRenderProps> = ({
217
+ document,
218
+ }): HeadConfig => {
219
+ const { title, description } = getPageMetadata(document);
220
+ const faviconUrl = document?._site?.favicon?.url;
221
+
222
+ return {
223
+ title: title,
224
+ charset: "UTF-8",
225
+ viewport: "width=device-width, initial-scale=1",
226
+ tags: [
227
+ {
228
+ type: "link",
229
+ attributes: {
230
+ rel: "icon",
231
+ type: "image/x-icon",
232
+ },
233
+ },
234
+ ...(description
235
+ ? [
236
+ {
237
+ type: "meta" as TagType,
238
+ attributes: {
239
+ name: "description",
240
+ content: description,
241
+ },
242
+ },
243
+ ]
244
+ : []),
245
+ ...(faviconUrl
246
+ ? [
247
+ {
248
+ type: "link" as TagType,
249
+ attributes: {
250
+ rel: "icon",
251
+ type: "image/x-icon",
252
+ href: faviconUrl,
253
+ },
254
+ },
255
+ ]
256
+ : []),
257
+ ],
258
+ other: [
259
+ applyAnalytics(document),
260
+ applyHeaderScript(document),
261
+ applyTheme(document, themeConfig),
262
+ SchemaWrapper(document._schema),
263
+ ].join("\\n"),
264
+ };
265
+ };
266
+
267
+ export const getPath: GetPath<TemplateProps> = ({ document }) => {
268
+ if (document.slug) {
269
+ return document.slug;
270
+ }
271
+
272
+ const localePath = document.locale !== "en" ? \`\${document.locale}/\` : "";
273
+ const path = \`\${localePath}\${document.id}\`;
274
+
275
+ return normalizeSlug(path);
276
+ };
277
+
278
+ const Directory: Template<TemplateRenderProps> = (props) => {
279
+ const { document } = props;
280
+
281
+ return (
282
+ <AnalyticsProvider
283
+ apiKey={document?._env?.YEXT_PUBLIC_EVENTS_API_KEY}
284
+ templateData={props}
285
+ currency="USD"
286
+ >
287
+ <VisualEditorProvider templateProps={props}>
288
+ <Render
289
+ config={directoryConfig}
290
+ data={JSON.parse(document.__.layout)}
291
+ />
292
+ </VisualEditorProvider>
293
+ </AnalyticsProvider>
294
+ );
295
+ };
296
+
297
+ export default Directory;
298
+ `, m = {
168
299
  "src/templates/main.tsx": d,
169
- "src/templates/edit.tsx": m
170
- }, f = () => {
300
+ "src/templates/edit.tsx": p,
301
+ "src/templates/directory.tsx": l
302
+ }, g = () => {
171
303
  let e = !1;
172
- const a = [], s = () => {
173
- Object.entries(l).forEach(([n, r]) => {
174
- const o = c.join(process.cwd(), n);
175
- a.push(o), i.mkdirSync(c.dirname(o), { recursive: !0 }), !i.existsSync(o) && i.writeFileSync(o, r);
304
+ const a = [], c = () => {
305
+ Object.entries(m).forEach(([n, i]) => {
306
+ const o = s.join(process.cwd(), n);
307
+ a.push(o), r.mkdirSync(s.dirname(o), { recursive: !0 }), !r.existsSync(o) && r.writeFileSync(o, i);
176
308
  });
177
309
  }, t = () => {
178
310
  a.forEach((n) => {
179
- i.rmSync(n, { force: !0 });
311
+ r.rmSync(n, { force: !0 });
180
312
  });
181
313
  };
182
314
  return process.on("SIGINT", () => {
@@ -185,16 +317,16 @@ export default Edit;
185
317
  t(), process.nextTick(() => process.exit(0));
186
318
  }), {
187
319
  name: "vite-plugin-yext-visual-editor",
188
- config(n, { command: r }) {
189
- e = r === "build";
320
+ config(n, { command: i }) {
321
+ e = i === "build";
190
322
  },
191
323
  configureServer(n) {
192
- e || (s(), n.httpServer?.on("close", () => {
324
+ e || (c(), n.httpServer?.on("close", () => {
193
325
  t();
194
326
  }));
195
327
  },
196
328
  buildStart() {
197
- e && s();
329
+ e && c();
198
330
  },
199
331
  buildEnd() {
200
332
  e && t();
@@ -205,5 +337,5 @@ export default Edit;
205
337
  };
206
338
  };
207
339
  export {
208
- f as yextVisualEditorPlugin
340
+ g as yextVisualEditorPlugin
209
341
  };