@wix/cli-app 1.1.60 → 1.1.62

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.
Files changed (102) hide show
  1. package/build/{CreateVersionCommand-Z6F5IKH5.js → CreateVersionCommand-IEF6U34E.js} +15 -15
  2. package/build/{DevCommand-YFEZ4QV5.js → DevCommand-SOODXUEP.js} +438 -299
  3. package/build/DevCommand-SOODXUEP.js.map +1 -0
  4. package/build/{GenerateCommand-KCV4YDNN.js → GenerateCommand-ARNW73TM.js} +108 -43
  5. package/build/{GenerateCommand-KCV4YDNN.js.map → GenerateCommand-ARNW73TM.js.map} +1 -1
  6. package/build/{LogsCommand-VBMGVYNU.js → LogsCommand-7TW36YZX.js} +5 -5
  7. package/build/PreviewCommand-ZZKRP2GF.js +23 -0
  8. package/build/{ReleaseCommand-5F3FPBXT.js → ReleaseCommand-SB2WWSVP.js} +15 -15
  9. package/build/{ServeCommand-G4FF4PT3.js → ServeCommand-GZKF6AN3.js} +14 -14
  10. package/build/{build-XZI3USNB.js → build-LHCSCFBM.js} +38 -9
  11. package/build/build-LHCSCFBM.js.map +1 -0
  12. package/build/{chunk-QVGYU6D4.js → chunk-2DRVDGHR.js} +5 -5
  13. package/build/chunk-2DRVDGHR.js.map +1 -0
  14. package/build/{chunk-USAOCISL.js → chunk-4WKSS3PU.js} +4 -4
  15. package/build/{chunk-CNZ3Q5PF.js → chunk-5R5H3Y2D.js} +105 -161
  16. package/build/chunk-5R5H3Y2D.js.map +1 -0
  17. package/build/chunk-6IX6CDWB.js +27644 -0
  18. package/build/chunk-6IX6CDWB.js.map +1 -0
  19. package/build/{chunk-VZJZSWRE.js → chunk-6US7335E.js} +3 -3
  20. package/build/{chunk-WRWNJYKZ.js → chunk-A3FHJ4EK.js} +3 -3
  21. package/build/{chunk-PKSGXFYA.js → chunk-HKX5ODUN.js} +3 -3
  22. package/build/{chunk-HUWYF2ET.js → chunk-KCNEUOW2.js} +8 -8
  23. package/build/{chunk-O42QDBJU.js → chunk-KJR4P55M.js} +3 -3
  24. package/build/{chunk-5QZS3HT7.js → chunk-KVM6MGID.js} +3 -3
  25. package/build/{chunk-VXE3IWKR.js → chunk-LMFNRK6X.js} +2 -2
  26. package/build/{chunk-DGTJGIY2.js → chunk-LULKQBSP.js} +5125 -2917
  27. package/build/chunk-LULKQBSP.js.map +1 -0
  28. package/build/{chunk-IG6IV6VM.js → chunk-MTEB33GR.js} +3 -3
  29. package/build/{chunk-36W5H7IG.js → chunk-PM4M3SGC.js} +195 -177
  30. package/build/chunk-PM4M3SGC.js.map +1 -0
  31. package/build/{chunk-4VTDNX5T.js → chunk-UE7LDQKD.js} +2 -2
  32. package/build/{chunk-2PTCXTKF.js → chunk-UZXKDHQZ.js} +5 -5
  33. package/build/{chunk-WRPV7SLY.js → chunk-V75TFIXI.js} +193 -20
  34. package/build/chunk-V75TFIXI.js.map +1 -0
  35. package/build/{chunk-7CGRTCDC.js → chunk-YW2RBPPY.js} +3 -3
  36. package/build/{chunk-QZOQAFHK.js → chunk-ZR3N5INU.js} +8 -8
  37. package/build/chunk-ZR3N5INU.js.map +1 -0
  38. package/build/cloudflare-runtime/entry.js +7157 -52
  39. package/build/cloudflare-runtime/getRegisteredExtensions.js +7095 -15
  40. package/build/index.js +20 -20
  41. package/build/platform-sdk/chunk-3U6QUCP3.js +2 -0
  42. package/build/platform-sdk/chunk-3U6QUCP3.js.map +1 -0
  43. package/build/platform-sdk/{chunk-QV4VBCJB.js → chunk-FLUCZ5U6.js} +2 -2
  44. package/build/platform-sdk/chunk-VXQAZIAE.js +2 -0
  45. package/build/platform-sdk/{chunk-EERHWVVD.js.map → chunk-VXQAZIAE.js.map} +1 -1
  46. package/build/platform-sdk/chunk-ZM5O3GFB.js +2 -0
  47. package/build/platform-sdk/chunk-ZM5O3GFB.js.map +1 -0
  48. package/build/platform-sdk/dashboard.js +1 -1
  49. package/build/platform-sdk/dashboard.js.map +1 -1
  50. package/build/platform-sdk/editor.js +2 -2
  51. package/build/platform-sdk/editor.js.map +1 -1
  52. package/build/platform-sdk/sdk-context.js +1 -1
  53. package/build/platform-sdk/sdk-context.js.map +1 -1
  54. package/build/platform-sdk/site.js +1 -1
  55. package/build/platform-sdk/site.js.map +1 -1
  56. package/build/platform-sdk/web-methods.js +1 -1
  57. package/build/platform-sdk/web-methods.js.map +1 -1
  58. package/build/{preview-VAHHFTRZ.js → preview-ZAKEXAJH.js} +13 -13
  59. package/build/{render-command-3AYSQXHN.js → render-command-XMQH723O.js} +6 -6
  60. package/package.json +8 -6
  61. package/schemas/custom-element.json +1 -1
  62. package/templates/custom-element/files/element.module.css.ejs +18 -5
  63. package/templates/custom-element/files/element.tsx.ejs +8 -5
  64. package/templates/custom-element/files/panel.tsx.ejs +25 -12
  65. package/templates/web-method/dependencies.json +5 -0
  66. package/templates/web-method/files/placeholder.ts.ejs +9 -2
  67. package/build/DevCommand-YFEZ4QV5.js.map +0 -1
  68. package/build/PreviewCommand-3OMHWDW6.js +0 -23
  69. package/build/build-XZI3USNB.js.map +0 -1
  70. package/build/chunk-36W5H7IG.js.map +0 -1
  71. package/build/chunk-CNZ3Q5PF.js.map +0 -1
  72. package/build/chunk-DGTJGIY2.js.map +0 -1
  73. package/build/chunk-FTC5AK3Y.js +0 -1367
  74. package/build/chunk-FTC5AK3Y.js.map +0 -1
  75. package/build/chunk-QVGYU6D4.js.map +0 -1
  76. package/build/chunk-QZOQAFHK.js.map +0 -1
  77. package/build/chunk-WRPV7SLY.js.map +0 -1
  78. package/build/platform-sdk/chunk-42XIZ4MH.js +0 -2
  79. package/build/platform-sdk/chunk-42XIZ4MH.js.map +0 -1
  80. package/build/platform-sdk/chunk-7EYXEF6M.js +0 -2
  81. package/build/platform-sdk/chunk-7EYXEF6M.js.map +0 -1
  82. package/build/platform-sdk/chunk-EERHWVVD.js +0 -2
  83. /package/build/{CreateVersionCommand-Z6F5IKH5.js.map → CreateVersionCommand-IEF6U34E.js.map} +0 -0
  84. /package/build/{LogsCommand-VBMGVYNU.js.map → LogsCommand-7TW36YZX.js.map} +0 -0
  85. /package/build/{PreviewCommand-3OMHWDW6.js.map → PreviewCommand-ZZKRP2GF.js.map} +0 -0
  86. /package/build/{ReleaseCommand-5F3FPBXT.js.map → ReleaseCommand-SB2WWSVP.js.map} +0 -0
  87. /package/build/{ServeCommand-G4FF4PT3.js.map → ServeCommand-GZKF6AN3.js.map} +0 -0
  88. /package/build/{chunk-USAOCISL.js.map → chunk-4WKSS3PU.js.map} +0 -0
  89. /package/build/{chunk-VZJZSWRE.js.map → chunk-6US7335E.js.map} +0 -0
  90. /package/build/{chunk-WRWNJYKZ.js.map → chunk-A3FHJ4EK.js.map} +0 -0
  91. /package/build/{chunk-PKSGXFYA.js.map → chunk-HKX5ODUN.js.map} +0 -0
  92. /package/build/{chunk-HUWYF2ET.js.map → chunk-KCNEUOW2.js.map} +0 -0
  93. /package/build/{chunk-O42QDBJU.js.map → chunk-KJR4P55M.js.map} +0 -0
  94. /package/build/{chunk-5QZS3HT7.js.map → chunk-KVM6MGID.js.map} +0 -0
  95. /package/build/{chunk-VXE3IWKR.js.map → chunk-LMFNRK6X.js.map} +0 -0
  96. /package/build/{chunk-IG6IV6VM.js.map → chunk-MTEB33GR.js.map} +0 -0
  97. /package/build/{chunk-4VTDNX5T.js.map → chunk-UE7LDQKD.js.map} +0 -0
  98. /package/build/{chunk-2PTCXTKF.js.map → chunk-UZXKDHQZ.js.map} +0 -0
  99. /package/build/{chunk-7CGRTCDC.js.map → chunk-YW2RBPPY.js.map} +0 -0
  100. /package/build/platform-sdk/{chunk-QV4VBCJB.js.map → chunk-FLUCZ5U6.js.map} +0 -0
  101. /package/build/{preview-VAHHFTRZ.js.map → preview-ZAKEXAJH.js.map} +0 -0
  102. /package/build/{render-command-3AYSQXHN.js.map → render-command-XMQH723O.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{b as n}from"./chunk-42XIZ4MH.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function o(e,t=!1){return n(e,t)}var i=["wix.com","editorx.com"];var _=new RegExp(`\\.(${i.join("|")})$`),s=["42.wixprod.net","uw2-edt-1.wixprod.net"],a="dev.wix-code.com";var u=new RegExp(`\\.(${s.join("|")})$`),p=new RegExp(`.*\\.${a}$`);import{wixContext as f}from"@wix/sdk-context";function r(e,t){t==="global"?globalThis.__wix_context__!=null?globalThis.__wix_context__.client=e:globalThis.__wix_context__={client:e}:f.client=e}var b=o(e=>(t,c)=>e.fetchWithAuth(t,c));export{r as enableContext};
1
+ import{a as o}from"./chunk-3U6QUCP3.js";import"./chunk-ZM5O3GFB.js";import"./chunk-SBZEOPXX.js";import{wixContext as n}from"@wix/sdk-context";function r(t,e){e==="global"?globalThis.__wix_context__!=null?globalThis.__wix_context__.client=t:globalThis.__wix_context__={client:t}:n.client=t}var c=o(t=>(e,l)=>t.fetchWithAuth(e,l));export{r as enableContext};
2
2
  //# sourceMappingURL=sdk-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/@wix/sdk-runtime/build/rest-modules.js","../../../node_modules/@wix/sdk/build/enable-context.js","../../../node_modules/@wix/sdk/build/context.js"],"sourcesContent":["import { contextualizeRESTModuleV2 } from './context-v2.js';\nexport function createRESTModule(descriptor, elevated = false) {\n return contextualizeRESTModuleV2(descriptor, elevated);\n}\nexport function toURLSearchParams(params, isComplexRequest) {\n const flatten = flattenParams(params);\n const searchParams = Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {\n // inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2`\n const keyParams = Array.isArray(value) ? value : [value];\n keyParams.forEach((param) => {\n if (param === undefined || param === null) {\n return;\n }\n urlSearchParams.append(key, param);\n });\n return urlSearchParams;\n }, new URLSearchParams());\n if (isComplexRequest) {\n searchParams.append('.r', base64Encode(JSON.stringify(params)));\n }\n return searchParams;\n}\nexport function resolveUrl(opts) {\n const domain = resolveDomain(opts.host);\n const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);\n const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});\n return resolvePathFromMappings(path, mappings);\n}\nfunction flattenParams(data, path = '') {\n const params = {};\n Object.entries(data).forEach(([key, value]) => {\n const isObject = value !== null && typeof value === 'object' && !Array.isArray(value);\n const fieldPath = resolvePath(path, key);\n if (isObject) {\n const serializedObject = flattenParams(value, fieldPath);\n Object.assign(params, serializedObject);\n }\n else {\n params[fieldPath] = value;\n }\n });\n return params;\n}\nfunction resolvePath(path, key) {\n return `${path}${path ? '.' : ''}${key}`;\n}\nconst base64Encode = (value) => {\n const base64 = typeof btoa !== 'undefined'\n ? btoa(value)\n : Buffer.from(value, 'utf-8').toString('base64');\n return base64.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n};\nconst DOMAINS = ['wix.com', 'editorx.com'];\nconst USER_DOMAIN = '_';\nconst REGEX_CAPTURE_DOMAINS = new RegExp(`\\\\.(${DOMAINS.join('|')})$`);\nconst WIX_API_DOMAINS = ['42.wixprod.net', 'uw2-edt-1.wixprod.net'];\nconst DEV_WIX_CODE_DOMAIN = 'dev.wix-code.com';\nconst REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;\nconst REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\\\.(${WIX_API_DOMAINS.join('|')})$`);\nconst REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\\\.${DEV_WIX_CODE_DOMAIN}$`);\nfunction resolveDomain(host) {\n const resolvedHost = fixHostExceptions(host);\n return resolvedHost\n .replace(REGEX_CAPTURE_DOMAINS, '._base_domain_')\n .replace(REGEX_CAPTURE_API_DOMAINS, '._api_base_domain_')\n .replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, '*.dev.wix-code.com');\n}\n// hosts which standard string replacing doesn't apply to them, will be fixed here.\nfunction fixHostExceptions(host) {\n // https://system-kb.wixanswers.com/kb/en/article/editorx-domains-matching-to-wixcom\n return host.replace('create.editorx.com', 'editor.editorx.com');\n}\nfunction resolveMappingsByDomain(domain, domainToMappings) {\n const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];\n if (!mappings) {\n if (isBaseDomain(domain)) {\n // fallback <lang>.wix.com sub domains to www.wix.com\n // since all of the languages subdomain are not mapped automatically in FP and we want to support those kind of calls\n // for example: fr.wix.com\n return domainToMappings[wwwBaseDomain];\n }\n }\n return mappings;\n}\nfunction isBaseDomain(domain) {\n return !!domain.match(/\\._base_domain_$/);\n}\nconst wwwBaseDomain = 'www._base_domain_';\nfunction injectDataIntoProtoPath(protoPath, data) {\n return protoPath\n .split('/')\n .map((path) => maybeProtoPathToData(path, data))\n .join('/');\n}\nfunction maybeProtoPathToData(protoPath, data) {\n const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];\n const field = protoRegExpMatch[1];\n if (field) {\n const suffix = protoPath.replace(protoRegExpMatch[0], '');\n return findByPath(data, field, protoPath, suffix);\n }\n return protoPath;\n}\nfunction findByPath(obj, path, defaultValue, suffix) {\n let result = obj;\n for (const field of path.split('.')) {\n if (!result) {\n return defaultValue;\n }\n result = result[field];\n }\n return `${result}${suffix}`;\n}\nfunction resolvePathFromMappings(protoPath, mappings) {\n const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));\n if (!mapping) {\n // todo: should we return the path? if no - what should we do in case of testings?\n return protoPath;\n }\n return mapping.srcPath + protoPath.slice(mapping.destPath.length);\n}\n","import { wixContext } from '@wix/sdk-context';\nexport function enableContext(wixClient, contextType) {\n if (contextType === 'global') {\n if (globalThis.__wix_context__ != null) {\n globalThis.__wix_context__.client = wixClient;\n }\n else {\n globalThis.__wix_context__ = { client: wixClient };\n }\n }\n else {\n wixContext.client = wixClient;\n }\n}\n","import { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nexport function elevate(restModule) {\n return createRESTModule(restModule, true);\n}\nexport const fetchWithAuth = createRESTModule((restModuleOpts) => {\n return ((url, options) => restModuleOpts.fetchWithAuth(url, options));\n});\nexport { graphql } from './graphql.js';\nexport { setGlobalWixContext } from './wix-context.js';\nexport { enableContext } from './enable-context.js';\n"],"mappings":"gGACO,SAASA,EAAiBC,EAAYC,EAAW,GAAO,CAC3D,OAAOC,EAA0BF,EAAYC,CAAQ,CACzD,CAiDA,IAAME,EAAU,CAAC,UAAW,aAAa,EAEzC,IAAMC,EAAwB,IAAI,OAAO,OAAOC,EAAQ,KAAK,GAAG,CAAC,IAAI,EAC/DC,EAAkB,CAAC,iBAAkB,uBAAuB,EAC5DC,EAAsB,mBAE5B,IAAMC,EAA4B,IAAI,OAAO,OAAOC,EAAgB,KAAK,GAAG,CAAC,IAAI,EAC3EC,EAAoC,IAAI,OAAO,QAAQC,CAAmB,GAAG,EC3DnF,OAAS,cAAAC,MAAkB,mBACpB,SAASC,EAAcC,EAAWC,EAAa,CAC9CA,IAAgB,SACZ,WAAW,iBAAmB,KAC9B,WAAW,gBAAgB,OAASD,EAGpC,WAAW,gBAAkB,CAAE,OAAQA,CAAU,EAIrDF,EAAW,OAASE,CAE5B,CCTO,IAAME,EAAgBC,EAAkBC,GACnC,CAACC,EAAKC,IAAYF,EAAe,cAAcC,EAAKC,CAAO,CACtE","names":["createRESTModule","descriptor","elevated","contextualizeRESTModuleV2","DOMAINS","REGEX_CAPTURE_DOMAINS","DOMAINS","WIX_API_DOMAINS","DEV_WIX_CODE_DOMAIN","REGEX_CAPTURE_API_DOMAINS","WIX_API_DOMAINS","REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN","DEV_WIX_CODE_DOMAIN","wixContext","enableContext","wixClient","contextType","fetchWithAuth","createRESTModule","restModuleOpts","url","options"]}
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk/build/enable-context.js","../../../node_modules/@wix/sdk/build/context.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function enableContext(wixClient, contextType) {\n if (contextType === 'global') {\n if (globalThis.__wix_context__ != null) {\n globalThis.__wix_context__.client = wixClient;\n }\n else {\n globalThis.__wix_context__ = { client: wixClient };\n }\n }\n else {\n wixContext.client = wixClient;\n }\n}\n","import { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nexport function elevate(restModule) {\n return createRESTModule(restModule, true);\n}\nexport const fetchWithAuth = createRESTModule((restModuleOpts) => {\n return ((url, options) => restModuleOpts.fetchWithAuth(url, options));\n});\nexport { graphql } from './graphql.js';\nexport { setGlobalWixContext } from './wix-context.js';\nexport { enableContext } from './enable-context.js';\n"],"mappings":"gGAAA,OAAS,cAAAA,MAAkB,mBACpB,SAASC,EAAcC,EAAWC,EAAa,CAC9CA,IAAgB,SACZ,WAAW,iBAAmB,KAC9B,WAAW,gBAAgB,OAASD,EAGpC,WAAW,gBAAkB,CAAE,OAAQA,CAAU,EAIrDF,EAAW,OAASE,CAE5B,CCTO,IAAME,EAAgBC,EAAkBC,GACnC,CAACC,EAAKC,IAAYF,EAAe,cAAcC,EAAKC,CAAO,CACtE","names":["wixContext","enableContext","wixClient","contextType","fetchWithAuth","createRESTModule","restModuleOpts","url","options"]}
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-EERHWVVD.js";import"./chunk-42XIZ4MH.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function c(){let t=null,n=null;return{promise:new Promise((o,r)=>{t=o,n=r}),resolve:t,reject:n}}var d=t=>{let{createHost:n}=t;return{__type:"host",create:e=>({}),host:e=>{var o,r;let i=n(e),s=p();return{...i,apiBaseUrl:s,essentials:{language:typeof window<"u"?(o=window.commonConfig)==null?void 0:o.language:void 0,locale:typeof window<"u"?(r=window.commonConfig)==null?void 0:r.locale:void 0}}},auth:e=>{let o=typeof window<"u"?window.wixEmbedsAPI:void 0;e||(e=o==null||o.getAccessTokenFunction==null?void 0:o.getAccessTokenFunction());let r=!1,{resolve:i,promise:s}=c();return{getAuthHeaders:async()=>{if(!e&&r&&(e=await s),!e)throw new Error("Failed to resolve auth token");return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(r=!0,m=>{i(m)})}}}};function p(){let t=typeof window<"u"?window.wixEmbedsAPI:void 0,n=t==null||t.getExternalBaseUrl==null?void 0:t.getExternalBaseUrl();if(!n)return;let e=new URL(n);return e!=null&&e.pathname&&e.pathname!=="/"?""+e.hostname+e.pathname:e.hostname}var u=t=>{let{clientSdk:n,applicationId:e}=t;return{invoke:async o=>{let{namespace:r,method:i,args:s}=o;if(!n)throw new Error("Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction");return n.invoke({namespace:r,method:i,args:s,applicationId:e,accessToken:"accessToken"})},getAccessToken:()=>{throw new Error("Not implemented")},observeState:()=>({disconnect:()=>{}})}};var w=function(t){let n=typeof $wixContext<"u"&&$wixContext.clientSdk||t?.clientSdk||window.clientSdk,{applicationId:e}=t||{};if(!e)throw new Error('"createHost" was called without a required field "applicationId"');return{channel:u({clientSdk:n,applicationId:e}),close:()=>{}}};var l=d({createHost:w});var S=t=>{let n=l.host({applicationId:t}),e=l.auth(),o=e.getAccessTokenInjector();return a({auth:e,host:n}).enableContext("module"),{injectGetAccessToken:o}};export{S as enableClient};
1
+ import{a}from"./chunk-VXQAZIAE.js";import"./chunk-ZM5O3GFB.js";import"./chunk-SBZEOPXX.js";function d(){let t=null,n=null;return{promise:new Promise((o,i)=>{t=o,n=i}),resolve:t,reject:n}}var u=t=>{let{createHost:n}=t;return{__type:"host",create:e=>({}),host:e=>{var o,i;let{applicationId:s}=e??{},r=typeof window<"u"?window.wixEmbedsAPI:void 0,l=n(e),p=f();return{...l,apiBaseUrl:p,getMonitoringClient:r==null||r.getMonitoringClientFunction==null?void 0:r.getMonitoringClientFunction(s),essentials:{language:typeof window<"u"?(o=window.commonConfig)==null?void 0:o.language:void 0,locale:typeof window<"u"?(i=window.commonConfig)==null?void 0:i.locale:void 0}}},auth:e=>{let o=typeof window<"u"?window.wixEmbedsAPI:void 0;e||(e=o==null||o.getAccessTokenFunction==null?void 0:o.getAccessTokenFunction());let i=!1,{resolve:s,promise:r}=d();return{getAuthHeaders:async()=>{if(!e&&i&&(e=await r),!e)throw new Error("Failed to resolve auth token");return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(i=!0,l=>{s(l)})}}}};function f(){let t=typeof window<"u"?window.wixEmbedsAPI:void 0,n=t==null||t.getExternalBaseUrl==null?void 0:t.getExternalBaseUrl();if(!n)return;let e=new URL(n);return e!=null&&e.pathname&&e.pathname!=="/"?""+e.hostname+e.pathname:e.hostname}var w=t=>{let{clientSdk:n,applicationId:e}=t;return{invoke:async o=>{let{namespace:i,method:s,args:r}=o;if(!n)throw new Error("Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction");return n.invoke({namespace:i,method:s,args:r,applicationId:e,accessToken:"accessToken"})},getAccessToken:()=>{throw new Error("Not implemented")},observeState:()=>({disconnect:()=>{}})}};var m=function(t){let n=typeof $wixContext<"u"&&$wixContext.clientSdk||t?.clientSdk||window.clientSdk,{applicationId:e}=t||{};if(!e)throw new Error('"createHost" was called without a required field "applicationId"');return{channel:w({clientSdk:n,applicationId:e}),close:()=>{}}};var c=u({createHost:m});var S=t=>{let n=c.host({applicationId:t}),e=c.auth(),o=e.getAccessTokenInjector();return a({auth:e,host:n}).enableContext("module"),{injectGetAccessToken:o}};export{S as enableClient};
2
2
  //# sourceMappingURL=site.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/@wix/site/src/utils.ts","../../../node_modules/@wix/site/src/websiteHostModule.ts","../../../node_modules/@wix/site/src/channel.ts","../../../node_modules/@wix/site/src/hostPlatform.ts","../../../node_modules/@wix/site/src/index.ts","../src/site.ts"],"sourcesContent":["export function withResolvers<T>(): {\n resolve: (value: T | PromiseLike<T>) => void;\n reject: (reason?: any) => void;\n promise: Promise<T>;\n} {\n let resolve = null as any;\n let reject = null as any;\n\n const promise = new Promise<T>((resolveFn, rejectFn) => {\n resolve = resolveFn;\n reject = rejectFn;\n });\n\n return { promise, resolve, reject };\n}\n","import type { HostModule } from '@wix/sdk-types';\nimport { withResolvers } from './utils';\nimport {\n AccessTokenFn,\n CreateAuthStrategy,\n CreateWebsiteHost,\n Host,\n SDK,\n SDKOptions,\n WixEmbedsAPI,\n} from './types';\n\ndeclare global {\n interface Window {\n wixEmbedsAPI?: WixEmbedsAPI;\n commonConfig?: {\n language?: string;\n locale?: string;\n };\n }\n}\n\nexport const createWebsiteModule = ({\n createHost,\n}: {\n createHost: CreateWebsiteHost;\n}): HostModule<SDK, Host> & {\n host: CreateWebsiteHost;\n auth: CreateAuthStrategy;\n} => {\n return {\n __type: 'host',\n create: (_host) => {\n // Here we can implement module methods that could be used by the SDK via \"wixClient.use(website)\" api.\n // We don't have any for now, so we just return an empty object.\n return {};\n },\n host: (options?: SDKOptions) => {\n const host = createHost(options);\n const apiBaseUrl = getApiBaseUrl();\n\n return {\n ...host,\n apiBaseUrl,\n essentials: {\n language:\n typeof window !== 'undefined'\n ? window.commonConfig?.language\n : undefined,\n locale:\n typeof window !== 'undefined'\n ? window.commonConfig?.locale\n : undefined,\n },\n };\n },\n auth: (getAccessTokenFn?: AccessTokenFn) => {\n const wixEmbedsAPI =\n typeof window !== 'undefined' ? window.wixEmbedsAPI : undefined;\n\n if (!getAccessTokenFn) {\n /*\n We must call wixEmbedsAPI.getAccessTokenFunction() in the main frame and not from async callbacks / setTimeout calls\n since it uses document.currentScript API behind the scenes\n https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript\n * */\n getAccessTokenFn = wixEmbedsAPI?.getAccessTokenFunction?.();\n }\n\n let injectorCreated = false;\n\n const { resolve: resolveAccessTokenFn, promise: accessTokenFnPromise } =\n withResolvers<AccessTokenFn>();\n\n return {\n getAuthHeaders: async () => {\n if (!getAccessTokenFn && injectorCreated) {\n getAccessTokenFn = await accessTokenFnPromise;\n }\n\n if (!getAccessTokenFn) {\n throw new Error('Failed to resolve auth token');\n }\n\n return {\n headers: {\n Authorization: await getAccessTokenFn(),\n },\n };\n },\n getAccessTokenInjector: () => {\n injectorCreated = true;\n\n return (_getAccessTokenFn: AccessTokenFn) => {\n resolveAccessTokenFn(_getAccessTokenFn);\n };\n },\n };\n },\n };\n};\n\nfunction getApiBaseUrl() {\n const wixEmbedsAPI =\n typeof window !== 'undefined' ? window.wixEmbedsAPI : undefined;\n const apiBaseUrl = wixEmbedsAPI?.getExternalBaseUrl?.();\n if (!apiBaseUrl) {\n return;\n }\n\n // clean the protocol from the URL\n const parsedUrlObject = new URL(apiBaseUrl);\n if (parsedUrlObject?.pathname && parsedUrlObject.pathname !== '/') {\n return `${parsedUrlObject.hostname}${parsedUrlObject.pathname}`;\n }\n\n return parsedUrlObject.hostname;\n}\n","import { ClientSDK, WebsiteChannel } from './types';\n\nexport const createWebsiteChannel = ({\n clientSdk,\n applicationId,\n}: {\n clientSdk?: ClientSDK;\n applicationId: string;\n}): WebsiteChannel => {\n return {\n invoke: async ({ namespace, method, args }) => {\n if (!clientSdk) {\n throw new Error(\n 'Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction',\n );\n }\n\n return clientSdk.invoke({\n namespace,\n method,\n args,\n applicationId,\n accessToken: 'accessToken',\n });\n },\n getAccessToken: () => {\n throw new Error('Not implemented');\n },\n observeState: () => ({\n disconnect: () => {},\n }),\n };\n};\n","import { createWebsiteChannel } from './channel';\nimport type { CreateWebsiteHost, ClientSDK } from './types';\n\ndeclare global {\n interface Window {\n clientSdk?: ClientSDK;\n }\n}\n\ndeclare const $wixContext: {\n clientSdk: ClientSDK;\n};\n\nexport const createHost: CreateWebsiteHost = function (config) {\n const clientSdk =\n (typeof $wixContext !== 'undefined' && $wixContext.clientSdk) ||\n config?.clientSdk ||\n window.clientSdk;\n const { applicationId } = config || {};\n\n if (!applicationId) {\n throw new Error(\n '\"createHost\" was called without a required field \"applicationId\"',\n );\n }\n\n return {\n // environment: {},\n channel: createWebsiteChannel({ clientSdk, applicationId }),\n close: () => {},\n };\n};\n","import { createWebsiteModule } from './websiteHostModule';\nimport { createHost } from './hostPlatform';\n\nexport const site = createWebsiteModule({ createHost });\n\nexport * from './types';\n","import { site } from '@wix/site';\nimport { createClient } from '@wix/sdk';\n\nexport const enableClient = (applicationId: string) => {\n const host = site.host({ applicationId });\n const auth = site.auth();\n const injectGetAccessToken = auth.getAccessTokenInjector();\n\n const wixClient = createClient({\n auth,\n host,\n });\n wixClient.enableContext('module');\n\n return {\n injectGetAccessToken,\n };\n};\n"],"mappings":"uHAAO,SAASA,GAId,CACA,IAAIC,EAAU,KACVC,EAAS,KAOb,MAAO,CAAEC,QALO,IAAIC,QAAW,CAACC,EAAWC,IAAa,CACtDL,EAAUI,EACVH,EAASI,CACX,CAAC,EAEiBL,QAAAA,EAASC,OAAAA,CAAO,CACpC,CCQO,IAAMK,EAAsBC,GAO9B,CAAA,GAP+B,CAClCC,WAAAA,CAGF,EAACD,EAIC,MAAO,CACLE,OAAQ,OACRC,OAASC,IAGA,CAAC,GAEVC,KAAOC,GAAyB,CAAA,IAAAC,EAAAC,EAC9B,IAAMH,EAAOJ,EAAWK,CAAO,EACzBG,EAAaC,EAAc,EAEjC,MAAO,CACL,GAAGL,EACHI,WAAAA,EACAE,WAAY,CACVC,SACE,OAAOC,OAAW,KAAWN,EACzBM,OAAOC,eAAY,KAAA,OAAnBP,EAAqBK,SACrBG,OACNC,OACE,OAAOH,OAAW,KAAWL,EACzBK,OAAOC,eAAY,KAAA,OAAnBN,EAAqBQ,OACrBD,MACR,CACF,CACF,EACAE,KAAOC,GAAqC,CAC1C,IAAMC,EACJ,OAAON,OAAW,IAAcA,OAAOM,aAAeJ,OAEnDG,IAMHA,EAAmBC,GAAY,MAAZA,EAAcC,wBAAsB,KAAA,OAApCD,EAAcC,uBAAyB,GAG5D,IAAIC,EAAkB,GAEhB,CAAEC,QAASC,EAAsBC,QAASC,CAAqB,EACnEC,EAA6B,EAE/B,MAAO,CACLC,eAAgB,SAAY,CAK1B,GAJI,CAACT,GAAoBG,IACvBH,E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,MAAO,CAELC,QAASC,EAAqB,CAAEN,UAAAA,EAAWG,cAAAA,CAAc,CAAC,EAC1DI,MAAOA,IAAM,CAAC,CAChB,CACF,EC5BO,IAAMC,EAAOC,EAAoB,CAAEC,WAAAA,CAAW,CAAC,ECA/C,IAAMC,EAAgBC,GAA0B,CACrD,IAAMC,EAAOC,EAAK,KAAK,CAAE,cAAAF,CAAc,CAAC,EAClCG,EAAOD,EAAK,KAAK,EACjBE,EAAuBD,EAAK,uBAAuB,EAMzD,OAJkBE,EAAa,CAC7B,KAAAF,EACA,KAAAF,CACF,CAAC,EACS,cAAc,QAAQ,EAEzB,CACL,qBAAAG,CACF,CACF","names":["withResolvers","resolve","reject","promise","Promise","resolveFn","rejectFn","createWebsiteModule","_ref","createHost","__type","create","_host","host","options","_window$commonConfig","_window$commonConfig2","apiBaseUrl","getApiBaseUrl","essentials","language","window","commonConfig","undefined","locale","auth","getAccessTokenFn","wixEmbedsAPI","getAccessTokenFunction","injectorCreated","resolve","resolveAccessTokenFn","promise","accessTokenFnPromise","withResolvers","getAuthHeaders","Error","headers","Authorization","getAccessTokenInjector","_getAccessTokenFn","getExternalBaseUrl","parsedUrlObject","URL","pathname","hostname","createWebsiteChannel","_ref","clientSdk","applicationId","invoke","_ref2","namespace","method","args","Error","accessToken","getAccessToken","observeState","disconnect","createHost","config","clientSdk","$wixContext","window","applicationId","Error","channel","createWebsiteChannel","close","site","createWebsiteModule","createHost","enableClient","applicationId","host","site","auth","injectGetAccessToken","createClient"]}
1
+ {"version":3,"sources":["../../../node_modules/@wix/site/src/utils.ts","../../../node_modules/@wix/site/src/websiteHostModule.ts","../../../node_modules/@wix/site/src/channel.ts","../../../node_modules/@wix/site/src/hostPlatform.ts","../../../node_modules/@wix/site/src/index.ts","../src/site.ts"],"sourcesContent":["export function withResolvers<T>(): {\n resolve: (value: T | PromiseLike<T>) => void;\n reject: (reason?: any) => void;\n promise: Promise<T>;\n} {\n let resolve = null as any;\n let reject = null as any;\n\n const promise = new Promise<T>((resolveFn, rejectFn) => {\n resolve = resolveFn;\n reject = rejectFn;\n });\n\n return { promise, resolve, reject };\n}\n","import type { HostModule } from '@wix/sdk-types';\nimport { withResolvers } from './utils';\nimport {\n AccessTokenFn,\n CreateAuthStrategy,\n CreateWebsiteHost,\n Host,\n SDK,\n SDKOptions,\n WixEmbedsAPI,\n} from './types';\n\ndeclare global {\n interface Window {\n wixEmbedsAPI?: WixEmbedsAPI;\n commonConfig?: {\n language?: string;\n locale?: string;\n };\n }\n}\n\nexport const createWebsiteModule = ({\n createHost,\n}: {\n createHost: CreateWebsiteHost;\n}): HostModule<SDK, Host> & {\n host: CreateWebsiteHost;\n auth: CreateAuthStrategy;\n} => {\n return {\n __type: 'host',\n create: (_host) => {\n // Here we can implement module methods that could be used by the SDK via \"wixClient.use(website)\" api.\n // We don't have any for now, so we just return an empty object.\n return {};\n },\n host: (options?: SDKOptions) => {\n const { applicationId } = options ?? {};\n const wixEmbedsAPI =\n typeof window !== 'undefined' ? window.wixEmbedsAPI : undefined;\n\n const host = createHost(options);\n const apiBaseUrl = getApiBaseUrl();\n\n return {\n ...host,\n apiBaseUrl,\n getMonitoringClient:\n wixEmbedsAPI?.getMonitoringClientFunction?.(applicationId),\n essentials: {\n language:\n typeof window !== 'undefined'\n ? window.commonConfig?.language\n : undefined,\n locale:\n typeof window !== 'undefined'\n ? window.commonConfig?.locale\n : undefined,\n },\n };\n },\n auth: (getAccessTokenFn?: AccessTokenFn) => {\n const wixEmbedsAPI =\n typeof window !== 'undefined' ? window.wixEmbedsAPI : undefined;\n\n if (!getAccessTokenFn) {\n /*\n We must call wixEmbedsAPI.getAccessTokenFunction() in the main frame and not from async callbacks / setTimeout calls\n since it uses document.currentScript API behind the scenes\n https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript\n * */\n getAccessTokenFn = wixEmbedsAPI?.getAccessTokenFunction?.();\n }\n\n let injectorCreated = false;\n\n const { resolve: resolveAccessTokenFn, promise: accessTokenFnPromise } =\n withResolvers<AccessTokenFn>();\n\n return {\n getAuthHeaders: async () => {\n if (!getAccessTokenFn && injectorCreated) {\n getAccessTokenFn = await accessTokenFnPromise;\n }\n\n if (!getAccessTokenFn) {\n throw new Error('Failed to resolve auth token');\n }\n\n return {\n headers: {\n Authorization: await getAccessTokenFn(),\n },\n };\n },\n getAccessTokenInjector: () => {\n injectorCreated = true;\n\n return (_getAccessTokenFn: AccessTokenFn) => {\n resolveAccessTokenFn(_getAccessTokenFn);\n };\n },\n };\n },\n };\n};\n\nfunction getApiBaseUrl() {\n const wixEmbedsAPI =\n typeof window !== 'undefined' ? window.wixEmbedsAPI : undefined;\n const apiBaseUrl = wixEmbedsAPI?.getExternalBaseUrl?.();\n if (!apiBaseUrl) {\n return;\n }\n\n // clean the protocol from the URL\n const parsedUrlObject = new URL(apiBaseUrl);\n if (parsedUrlObject?.pathname && parsedUrlObject.pathname !== '/') {\n return `${parsedUrlObject.hostname}${parsedUrlObject.pathname}`;\n }\n\n return parsedUrlObject.hostname;\n}\n","import { ClientSDK, WebsiteChannel } from './types';\n\nexport const createWebsiteChannel = ({\n clientSdk,\n applicationId,\n}: {\n clientSdk?: ClientSDK;\n applicationId: string;\n}): WebsiteChannel => {\n return {\n invoke: async ({ namespace, method, args }) => {\n if (!clientSdk) {\n throw new Error(\n 'Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction',\n );\n }\n\n return clientSdk.invoke({\n namespace,\n method,\n args,\n applicationId,\n accessToken: 'accessToken',\n });\n },\n getAccessToken: () => {\n throw new Error('Not implemented');\n },\n observeState: () => ({\n disconnect: () => {},\n }),\n };\n};\n","import { createWebsiteChannel } from './channel';\nimport type { CreateWebsiteHost, ClientSDK } from './types';\n\ndeclare global {\n interface Window {\n clientSdk?: ClientSDK;\n }\n}\n\ndeclare const $wixContext: {\n clientSdk: ClientSDK;\n};\n\nexport const createHost: CreateWebsiteHost = function (config) {\n const clientSdk =\n (typeof $wixContext !== 'undefined' && $wixContext.clientSdk) ||\n config?.clientSdk ||\n window.clientSdk;\n const { applicationId } = config || {};\n\n if (!applicationId) {\n throw new Error(\n '\"createHost\" was called without a required field \"applicationId\"',\n );\n }\n\n return {\n // environment: {},\n channel: createWebsiteChannel({ clientSdk, applicationId }),\n close: () => {},\n };\n};\n","import { createWebsiteModule } from './websiteHostModule';\nimport { createHost } from './hostPlatform';\n\nexport const site = createWebsiteModule({ createHost });\n\nexport * from './types';\n","import { site } from '@wix/site';\nimport { createClient } from '@wix/sdk';\n\nexport const enableClient = (applicationId: string) => {\n const host = site.host({ applicationId });\n const auth = site.auth();\n const injectGetAccessToken = auth.getAccessTokenInjector();\n\n const wixClient = createClient({\n auth,\n host,\n });\n wixClient.enableContext('module');\n\n return {\n injectGetAccessToken,\n };\n};\n"],"mappings":"2FAAO,SAASA,GAId,CACA,IAAIC,EAAU,KACVC,EAAS,KAOb,MAAO,CAAEC,QALO,IAAIC,QAAW,CAACC,EAAWC,IAAa,CACtDL,EAAUI,EACVH,EAASI,CACX,CAAC,EAEiBL,QAAAA,EAASC,OAAAA,CAAO,CACpC,CCQO,IAAMK,EAAsBC,GAO9B,CAAA,GAP+B,CAClCC,WAAAA,CAGF,EAACD,EAIC,MAAO,CACLE,OAAQ,OACRC,OAASC,IAGA,CAAC,GAEVC,KAAOC,GAAyB,CAAA,IAAAC,EAAAC,EAC9B,GAAM,CAAEC,cAAAA,CAAc,EAAIH,GAAW,CAAC,EAChCI,EACJ,OAAOC,OAAW,IAAcA,OAAOD,aAAeE,OAElDP,EAAOJ,EAAWK,CAAO,EACzBO,EAAaC,EAAc,EAEjC,MAAO,CACL,GAAGT,EACHQ,WAAAA,EACAE,oBACEL,GAAY,MAAZA,EAAcM,6BAA2B,KAAA,OAAzCN,EAAcM,4BAA8BP,CAAa,EAC3DQ,WAAY,CACVC,SACE,OAAOP,OAAW,KAAWJ,EACzBI,OAAOQ,eAAY,KAAA,OAAnBZ,EAAqBW,SACrBN,OACNQ,OACE,OAA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AAAA,EACAC,KAAAA,EACAL,cAAAA,EACAO,YAAa,aACf,CAAC,CACH,EACAC,eAAgBA,IAAM,CACpB,MAAM,IAAIF,MAAM,iBAAiB,CACnC,EACAG,aAAcA,KAAO,CACnBC,WAAYA,IAAM,CAAC,CACrB,EACF,CACF,ECnBO,IAAMC,EAAgC,SAAUC,EAAQ,CAC7D,IAAMC,EACH,OAAOC,YAAgB,KAAeA,YAAYD,WACnDD,GAAQC,WACRE,OAAOF,UACH,CAAEG,cAAAA,CAAc,EAAIJ,GAAU,CAAC,EAErC,GAAI,CAACI,EACH,MAAM,IAAIC,MACR,kEACF,EAGF,MAAO,CAELC,QAASC,EAAqB,CAAEN,UAAAA,EAAWG,cAAAA,CAAc,CAAC,EAC1DI,MAAOA,IAAM,CAAC,CAChB,CACF,EC5BO,IAAMC,EAAOC,EAAoB,CAAEC,WAAAA,CAAW,CAAC,ECA/C,IAAMC,EAAgBC,GAA0B,CACrD,IAAMC,EAAOC,EAAK,KAAK,CAAE,cAAAF,CAAc,CAAC,EAClCG,EAAOD,EAAK,KAAK,EACjBE,EAAuBD,EAAK,uBAAuB,EAMzD,OAJkBE,EAAa,CAC7B,KAAAF,EACA,KAAAF,CACF,CAAC,EACS,cAAc,QAAQ,EAEzB,CACL,qBAAAG,CACF,CACF","names":["withResolvers","resolve","reject","promise","Promise","resolveFn","rejectFn","createWebsiteModule","_ref","createHost","__type","create","_host","host","options","_window$commonConfig","_window$commonConfig2","applicationId","wixEmbedsAPI","window","undefined","apiBaseUrl","getApiBaseUrl","getMonitoringClient","getMonitoringClientFunction","essentials","language","commonConfig","locale","auth","getAccessTokenFn","getAccessTokenFunction","injectorCreated","resolve","resolveAccessTokenFn","promise","accessTokenFnPromise","withResolvers","getAuthHeaders","Error","headers","Authorization","getAccessTokenInjector","_getAccessTokenFn","getExternalBaseUrl","parsedUrlObject","URL","pathname","hostname","createWebsiteChannel","_ref","clientSdk","applicationId","invoke","_ref2","namespace","method","args","Error","accessToken","getAccessToken","observeState","disconnect","createHost","config","clientSdk","$wixContext","window","applicationId","Error","channel","createWebsiteChannel","close","site","createWebsiteModule","createHost","enableClient","applicationId","host","site","auth","injectGetAccessToken","createClient"]}
@@ -1,2 +1,2 @@
1
- import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";import{wixContext as o}from"@wix/sdk-context";function c(){let n=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(n)return{initWixModules(e,r){return a(()=>n(e,r))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let t=typeof $wixContext<"u"?$wixContext.client:typeof o.client<"u"?o.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,i=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof o.elevatedClient<"u"?o.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!t&&!i))return{initWixModules(e,r){if(r){if(!i)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return a(()=>i.use(e))}if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return a(()=>t.use(e))},fetchWithAuth:(e,r)=>{if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.fetchWithAuth(e,r)},async graphql(e,r,s){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.graphql(e,r,s)}}}function a(n){let t=globalThis.__wix_context__,i={client:o.client,elevatedClient:o.elevatedClient},e;globalThis.__wix_context__=void 0,o.client=void 0,o.elevatedClient=void 0,typeof $wixContext<"u"&&(e={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return n()}finally{globalThis.__wix_context__=t,o.client=i.client,o.elevatedClient=i.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=e.client,$wixContext.elevatedClient=e.elevatedClient)}}function u(n,t){return(...i)=>{let e=c();return e?e.initWixModules(n,t).apply(void 0,i):n.apply(void 0,i)}}function x(n,t=!1){return u(n,t)}var d=["wix.com","editorx.com"];var y=new RegExp(`\\.(${d.join("|")})$`),f=["42.wixprod.net","uw2-edt-1.wixprod.net"],p="dev.wix-code.com";var C=new RegExp(`\\.(${f.join("|")})$`),M=new RegExp(`.*\\.${p}$`);var v=x(n=>async({baseURL:t,filename:i,method:e,args:r})=>{let l=await(await n.fetchWithAuth(`${t}/_webMethods/${i}/${e}.ajax`,{body:JSON.stringify(r),method:"POST"})).json();if(l.exception===!0)throw l.result;return l.result});export{v as callWebMethod};
1
+ import{a as e}from"./chunk-3U6QUCP3.js";import"./chunk-ZM5O3GFB.js";import"./chunk-SBZEOPXX.js";var h=e(o=>async({baseURL:r,filename:s,method:n,args:a})=>{let t=await(await o.fetchWithAuth(`${r}/_webMethods/${s}/${n}.ajax`,{body:JSON.stringify(a),method:"POST"})).json();if(t.exception===!0)throw t.result;return t.result});export{h as callWebMethod};
2
2
  //# sourceMappingURL=web-methods.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/@wix/web-methods-platform/node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/web-methods-platform/node_modules/@wix/sdk-runtime/build/context-v2.js","../../../node_modules/@wix/web-methods-platform/node_modules/@wix/sdk-runtime/build/rest-modules.js","../../../node_modules/@wix/web-methods-platform/build/client/index.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n","import { contextualizeRESTModuleV2 } from './context-v2.js';\nexport function createRESTModule(descriptor, elevated = false) {\n return contextualizeRESTModuleV2(descriptor, elevated);\n}\nexport function toURLSearchParams(params, isComplexRequest) {\n const flatten = flattenParams(params);\n const searchParams = Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {\n // inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2`\n const keyParams = Array.isArray(value) ? value : [value];\n keyParams.forEach((param) => {\n if (param === undefined || param === null) {\n return;\n }\n urlSearchParams.append(key, param);\n });\n return urlSearchParams;\n }, new URLSearchParams());\n if (isComplexRequest) {\n searchParams.append('.r', base64Encode(JSON.stringify(params)));\n }\n return searchParams;\n}\nexport function resolveUrl(opts) {\n const domain = resolveDomain(opts.host);\n const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);\n const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});\n return resolvePathFromMappings(path, mappings);\n}\nfunction flattenParams(data, path = '') {\n const params = {};\n Object.entries(data).forEach(([key, value]) => {\n const isObject = value !== null && typeof value === 'object' && !Array.isArray(value);\n const fieldPath = resolvePath(path, key);\n if (isObject) {\n const serializedObject = flattenParams(value, fieldPath);\n Object.assign(params, serializedObject);\n }\n else {\n params[fieldPath] = value;\n }\n });\n return params;\n}\nfunction resolvePath(path, key) {\n return `${path}${path ? '.' : ''}${key}`;\n}\nconst base64Encode = (value) => {\n const base64 = typeof btoa !== 'undefined'\n ? btoa(value)\n : Buffer.from(value, 'utf-8').toString('base64');\n return base64.replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n};\nconst DOMAINS = ['wix.com', 'editorx.com'];\nconst USER_DOMAIN = '_';\nconst REGEX_CAPTURE_DOMAINS = new RegExp(`\\\\.(${DOMAINS.join('|')})$`);\nconst WIX_API_DOMAINS = ['42.wixprod.net', 'uw2-edt-1.wixprod.net'];\nconst DEV_WIX_CODE_DOMAIN = 'dev.wix-code.com';\nconst REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;\nconst REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\\\.(${WIX_API_DOMAINS.join('|')})$`);\nconst REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\\\.${DEV_WIX_CODE_DOMAIN}$`);\nfunction resolveDomain(host) {\n const resolvedHost = fixHostExceptions(host);\n return resolvedHost\n .replace(REGEX_CAPTURE_DOMAINS, '._base_domain_')\n .replace(REGEX_CAPTURE_API_DOMAINS, '._api_base_domain_')\n .replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, '*.dev.wix-code.com');\n}\n// hosts which standard string replacing doesn't apply to them, will be fixed here.\nfunction fixHostExceptions(host) {\n // https://system-kb.wixanswers.com/kb/en/article/editorx-domains-matching-to-wixcom\n return host.replace('create.editorx.com', 'editor.editorx.com');\n}\nfunction resolveMappingsByDomain(domain, domainToMappings) {\n const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];\n if (!mappings) {\n if (isBaseDomain(domain)) {\n // fallback <lang>.wix.com sub domains to www.wix.com\n // since all of the languages subdomain are not mapped automatically in FP and we want to support those kind of calls\n // for example: fr.wix.com\n return domainToMappings[wwwBaseDomain];\n }\n }\n return mappings;\n}\nfunction isBaseDomain(domain) {\n return !!domain.match(/\\._base_domain_$/);\n}\nconst wwwBaseDomain = 'www._base_domain_';\nfunction injectDataIntoProtoPath(protoPath, data) {\n return protoPath\n .split('/')\n .map((path) => maybeProtoPathToData(path, data))\n .join('/');\n}\nfunction maybeProtoPathToData(protoPath, data) {\n const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];\n const field = protoRegExpMatch[1];\n if (field) {\n const suffix = protoPath.replace(protoRegExpMatch[0], '');\n return findByPath(data, field, protoPath, suffix);\n }\n return protoPath;\n}\nfunction findByPath(obj, path, defaultValue, suffix) {\n let result = obj;\n for (const field of path.split('.')) {\n if (!result) {\n return defaultValue;\n }\n result = result[field];\n }\n return `${result}${suffix}`;\n}\nfunction resolvePathFromMappings(protoPath, mappings) {\n const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));\n if (!mapping) {\n // todo: should we return the path? if no - what should we do in case of testings?\n return protoPath;\n }\n return mapping.srcPath + protoPath.slice(mapping.destPath.length);\n}\n","import { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nexport const callWebMethod = createRESTModule((restModuleOpts) => {\n return async ({ baseURL, filename, method, args }) => {\n const response = await restModuleOpts.fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {\n body: JSON.stringify(args),\n method: 'POST',\n });\n const json = await response.json();\n // request failed\n if (json.exception === true) {\n throw json.result;\n }\n return json.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M,CAKlD,IAAMC,EAAO,MAJI,MAAML,EAAe,cAAc,GAAGC,CAAO,gBAAgBC,CAAQ,IAAIC,CAAM,QAAS,CACrG,KAAM,KAAK,UAAUC,CAAI,EACzB,OAAQ,MACZ,CAAC,GAC2B,KAAK,EAEjC,GAAIC,EAAK,YAAc,GACnB,MAAMA,EAAK,OAEf,OAAOA,EAAK,MAChB,CACH","names":["wixContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext","contextualizeRESTModuleV2","restModule","elevated","args","context","resolveContext","createRESTModule","descriptor","elevated","contextualizeRESTModuleV2","DOMAINS","REGEX_CAPTURE_DOMAINS","DOMAINS","WIX_API_DOMAINS","DEV_WIX_CODE_DOMAIN","REGEX_CAPTURE_API_DOMAINS","WIX_API_DOMAINS","REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN","DEV_WIX_CODE_DOMAIN","callWebMethod","createRESTModule","restModuleOpts","baseURL","filename","method","args","json"]}
1
+ {"version":3,"sources":["../../../node_modules/@wix/web-methods-platform/build/client/index.js"],"sourcesContent":["import { createRESTModule } from '@wix/sdk-runtime/rest-modules';\nexport const callWebMethod = createRESTModule((restModuleOpts) => {\n return async ({ baseURL, filename, method, args }) => {\n const response = await restModuleOpts.fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {\n body: JSON.stringify(args),\n method: 'POST',\n });\n const json = await response.json();\n // request failed\n if (json.exception === true) {\n throw json.result;\n }\n return json.result;\n };\n});\n"],"mappings":"gGACO,IAAMA,EAAgBC,EAAkBC,GACpC,MAAO,CAAE,QAAAC,EAAS,SAAAC,EAAU,OAAAC,EAAQ,KAAAC,CAAK,IAAM,CAKlD,IAAMC,EAAO,MAJI,MAAML,EAAe,cAAc,GAAGC,CAAO,gBAAgBC,CAAQ,IAAIC,CAAM,QAAS,CACrG,KAAM,KAAK,UAAUC,CAAI,EACzB,OAAQ,MACZ,CAAC,GAC2B,KAAK,EAEjC,GAAIC,EAAK,YAAc,GACnB,MAAMA,EAAK,OAEf,OAAOA,EAAK,MAChB,CACH","names":["callWebMethod","createRESTModule","restModuleOpts","baseURL","filename","method","args","json"]}
@@ -2,36 +2,36 @@ import { createRequire as _createRequire } from 'node:module';
2
2
  const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  createPreviewTag
5
- } from "./chunk-VZJZSWRE.js";
5
+ } from "./chunk-6US7335E.js";
6
6
  import {
7
7
  addUserFields
8
- } from "./chunk-7CGRTCDC.js";
9
- import "./chunk-IG6IV6VM.js";
8
+ } from "./chunk-YW2RBPPY.js";
9
+ import "./chunk-MTEB33GR.js";
10
10
  import {
11
11
  ARMClient,
12
12
  SiteListClient,
13
13
  resolveConfiguredSite,
14
14
  resolveDashboardExtensionUrl,
15
15
  resolvePlatformUrl
16
- } from "./chunk-FTC5AK3Y.js";
17
- import "./chunk-WRWNJYKZ.js";
18
- import "./chunk-USAOCISL.js";
19
- import "./chunk-QZOQAFHK.js";
20
- import "./chunk-5QZS3HT7.js";
21
- import "./chunk-WRPV7SLY.js";
22
- import "./chunk-VXE3IWKR.js";
16
+ } from "./chunk-6IX6CDWB.js";
17
+ import "./chunk-A3FHJ4EK.js";
18
+ import "./chunk-4WKSS3PU.js";
19
+ import "./chunk-ZR3N5INU.js";
20
+ import "./chunk-KVM6MGID.js";
21
+ import "./chunk-V75TFIXI.js";
22
+ import "./chunk-LMFNRK6X.js";
23
23
  import {
24
24
  DevCenterComponent,
25
25
  PlatformType,
26
26
  createHttpClient,
27
27
  isLoggedInToAccount,
28
28
  uploadApplication
29
- } from "./chunk-DGTJGIY2.js";
29
+ } from "./chunk-LULKQBSP.js";
30
30
  import {
31
31
  CliError,
32
32
  CliErrorCode,
33
33
  require_lib
34
- } from "./chunk-36W5H7IG.js";
34
+ } from "./chunk-PM4M3SGC.js";
35
35
  import {
36
36
  __toESM,
37
37
  init_esm_shims
@@ -135,4 +135,4 @@ async function nonInteractivePreview(options, model, services) {
135
135
  export {
136
136
  nonInteractivePreview
137
137
  };
138
- //# sourceMappingURL=preview-VAHHFTRZ.js.map
138
+ //# sourceMappingURL=preview-ZAKEXAJH.js.map
@@ -2,14 +2,14 @@ import { createRequire as _createRequire } from 'node:module';
2
2
  const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  messages_default
5
- } from "./chunk-QVGYU6D4.js";
5
+ } from "./chunk-2DRVDGHR.js";
6
6
  import {
7
7
  addUserFields,
8
8
  reportCommandStartEvent
9
- } from "./chunk-7CGRTCDC.js";
9
+ } from "./chunk-YW2RBPPY.js";
10
10
  import {
11
11
  DebugLogProvider
12
- } from "./chunk-5QZS3HT7.js";
12
+ } from "./chunk-KVM6MGID.js";
13
13
  import {
14
14
  AccountAuthProvider,
15
15
  BiProvider,
@@ -17,7 +17,7 @@ import {
17
17
  ProjectModelProvider,
18
18
  getDebugLogFilePath,
19
19
  loadProjectModel
20
- } from "./chunk-DGTJGIY2.js";
20
+ } from "./chunk-LULKQBSP.js";
21
21
  import {
22
22
  CliError,
23
23
  CliErrorCode,
@@ -25,7 +25,7 @@ import {
25
25
  render,
26
26
  require_react,
27
27
  version
28
- } from "./chunk-36W5H7IG.js";
28
+ } from "./chunk-PM4M3SGC.js";
29
29
  import {
30
30
  __toESM,
31
31
  init_esm_shims
@@ -114,4 +114,4 @@ export {
114
114
  renderCommand,
115
115
  runCommand
116
116
  };
117
- //# sourceMappingURL=render-command-3AYSQXHN.js.map
117
+ //# sourceMappingURL=render-command-XMQH723O.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wix/cli-app",
3
3
  "description": "CLI tool for Wix apps",
4
- "version": "1.1.60",
4
+ "version": "1.1.62",
5
5
  "author": "Amit Dahan",
6
6
  "dependencies": {
7
7
  "esbuild": "^0.21.3",
@@ -14,18 +14,20 @@
14
14
  "@types/mustache": "^4.2.5",
15
15
  "@types/react": "^18.3.3",
16
16
  "@types/semver": "^7.5.8",
17
+ "@wix/ambassador-blocks-v1-blocks-app": "^1.0.50",
17
18
  "@wix/ambassador-cli-site-override-service-v1-site-override": "^1.0.7",
18
19
  "@wix/ambassador-ctp-app-cloud-backend-service-v1-app-cloud-backend-deployment": "^1.0.8",
19
- "@wix/ambassador-ctp-gradual-rollout-v1-app-config": "^1.0.68",
20
- "@wix/ambassador-devcenter-apps-v1-app": "^1.0.536",
21
- "@wix/ambassador-devcenter-components-v1-component": "^1.0.435",
22
- "@wix/app-cloud-uploader": "^1.13.0",
20
+ "@wix/ambassador-ctp-gradual-rollout-v1-app-config": "^1.0.73",
21
+ "@wix/ambassador-devcenter-apps-v1-app": "^1.0.538",
22
+ "@wix/ambassador-devcenter-components-v1-component": "^1.0.436",
23
+ "@wix/app-cloud-uploader": "^1.14.0",
23
24
  "@wix/arm-client": "0.0.0",
24
25
  "@wix/bi-logger-dev-tools-data": "^1.89.0",
25
26
  "@wix/cli-app-definitions": "0.0.0",
26
27
  "@wix/cli-app-manifest": "1.0.0",
27
28
  "@wix/cli-app-platform-sdk": "0.0.0",
28
29
  "@wix/cli-auth": "0.0.0",
30
+ "@wix/cli-blocks-editor-comm-api": "1.0.3",
29
31
  "@wix/cli-cloudflare-runtime": "0.0.0",
30
32
  "@wix/cli-command-contract": "0.0.0",
31
33
  "@wix/cli-core-definitions": "0.0.0",
@@ -148,5 +150,5 @@
148
150
  ]
149
151
  }
150
152
  },
151
- "falconPackageHash": "8a63701ca5292cc4ccc25961b1740baa047ec13152cab621ceb5fa38"
153
+ "falconPackageHash": "f1161d5a4a811cb9404e7c98e7656f61c7ade5d0d10772bf26972107"
152
154
  }
@@ -1 +1 @@
1
- {"type":"object","properties":{"$schema":{"type":"string"},"id":{"type":"string","format":"uuid","description":"The ID (GUID) is a unique identifier for your element."},"name":{"type":"string","minLength":1,"maxLength":30,"description":"The name of your element as it will appear in the Wix App Dashboard"},"height":{"type":"object","properties":{"defaultHeight":{"type":"number","description":"Initial height of the widget in pixels when it is first installed on a site"}},"required":["defaultHeight"],"additionalProperties":false},"width":{"type":"object","properties":{"defaultWidth":{"type":"number","description":"Initial width of the widget in pixels when it is first installed on a site"},"stretchByDefault":{"type":"boolean","description":"Sets the widget's stretch on installation. If set to true, it will stretch the widget to the full width of its container"},"allowStretch":{"type":"boolean","description":"Allows a user to stretch the widget to the full width of the container if true"}},"required":["defaultWidth"],"additionalProperties":false},"installation":{"type":"object","properties":{"autoAddToSite":{"type":"boolean","description":"Automatically adds the widget to a site upon installation if true"},"essential":{"type":"boolean","description":"Marks the widget as crucial to your app's functionality or not. If true and a user deletes the widget, the entire app will also be deleted."}},"additionalProperties":false}},"required":["id","name","height","width"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}
1
+ {"type":"object","properties":{"$schema":{"type":"string"},"id":{"type":"string","format":"uuid","description":"The ID (GUID) is a unique identifier for your element."},"name":{"type":"string","minLength":1,"maxLength":30,"description":"The name of your element as it will appear in the Wix App Dashboard"},"height":{"type":"object","properties":{"defaultHeight":{"type":"number","description":"Initial height of the widget in pixels when it is first installed on a site"}},"required":["defaultHeight"],"additionalProperties":false},"width":{"type":"object","properties":{"defaultWidth":{"type":"number","description":"Initial width of the widget in pixels when it is first installed on a site"},"stretchByDefault":{"type":"boolean","description":"Sets the widget's stretch on installation. If set to true, it will stretch the widget to the full width of its container"},"allowStretch":{"type":"boolean","description":"Allows a user to stretch the widget to the full width of the container if true"}},"required":["defaultWidth"],"additionalProperties":false},"installation":{"type":"object","properties":{"autoAddToSite":{"type":"boolean","description":"Automatically adds the widget to a site upon installation if true"},"essential":{"type":"boolean","description":"Marks the widget as crucial to your app's functionality or not. If true and a user deletes the widget, the entire app will also be deleted."}},"additionalProperties":false},"behaviors":{"type":"object","properties":{"dashboard":{"type":"object","properties":{"dashboardPageComponentId":{"type":"string","format":"uuid","description":"The ID of the dashboard page component"}},"required":["dashboardPageComponentId"],"additionalProperties":false}},"additionalProperties":false}},"required":["id","name","height","width"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"}
@@ -1,22 +1,35 @@
1
1
  ---
2
2
  to: element.module.css
3
3
  ---
4
+ :root {
5
+ --background-color: #242A35;
6
+ --text-color: #fcfdfd;
7
+ --secondary-text-color: #c9c9c9;
8
+ --code-color: #d7d7d7;
9
+ }
10
+
4
11
  .root {
5
12
  width: 100%;
6
13
  height: 100%;
14
+ background-color: var(--background-color);
15
+ color: var(--text-color);
16
+ box-sizing: border-box;
17
+ padding: 3rem 1rem;
18
+ font-size: 14px;
7
19
  }
8
20
 
9
21
  .root h2 {
10
- font-size: 20px;
22
+ font-size: 1.5rem;
11
23
  margin-bottom: 5px;
12
24
  }
13
25
 
14
- .root code,
15
26
  .root p {
16
- font-size: 16px;
27
+ color: var(--secondary-text-color);
17
28
  }
18
29
 
19
30
  .root code {
20
- font-style: italic;
21
- color: darkgreen;
31
+ color: var(--code-color);
32
+ font-size: 0.8rem;
33
+ font-weight: bolder;
22
34
  }
35
+
@@ -7,16 +7,19 @@ import reactToWebComponent from 'react-to-webcomponent';
7
7
  import styles from './element.module.css';
8
8
 
9
9
  interface Props {
10
- displayName: string;
10
+ displayName?: string;
11
11
  }
12
12
 
13
- const CustomElement: FC<Props> = (props) => {
13
+ const CustomElement: FC<Props> = ({
14
+ displayName = `Your Widget's Title`,
15
+ }) => {
14
16
  return (
15
17
  <div className={styles.root}>
16
- <h2>Hello {props.displayName || 'Wix CLI'}</h2>
18
+ <h2>{displayName}</h2>
19
+ <hr />
17
20
  <p>
18
- Open <code>`<%- readablePath %>`</code> to start
19
- building your widget
21
+ This is a Site Widget generated by Wix CLI.<br />
22
+ Continue to develop this widget at <code>'<%- readablePath %>'</code>.
20
23
  </p>
21
24
  </div>
22
25
  );
@@ -1,41 +1,54 @@
1
1
  ---
2
2
  to: panel.tsx
3
3
  ---
4
- import React, { type FC, useState, useEffect } from 'react';
4
+ import React, { type FC, useState, useEffect, useCallback } from 'react';
5
5
  import { widget } from '@wix/editor';
6
6
  import {
7
7
  SidePanel,
8
8
  WixDesignSystemProvider,
9
9
  Input,
10
10
  FormField,
11
+ SectionHelper,
11
12
  } from '@wix/design-system';
12
13
  import '@wix/design-system/styles.global.css';
13
14
 
15
+ const SITE_WIDGETS_DOCS = 'https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/site-extensions/site-widgets/site-widget-extension-files-and-code';
16
+
14
17
  const Panel: FC = () => {
15
- const [name, setName] = useState<string>('');
18
+ const [displayName, setDisplayName] = useState<string>('');
16
19
 
17
20
  useEffect(() => {
18
- widget.getProp('display-name').then(name => setName(name || 'Wix CLI'));
19
- }, [setName]);
21
+ widget.getProp('display-name')
22
+ .then(displayName => setDisplayName(displayName || `Your Widget's Title`))
23
+ .catch(error => console.error('Failed to fetch display-name:', error));
24
+ }, [setDisplayName]);
25
+
26
+ const handleDisplayNameChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
27
+ const newDisplayName = event.target.value;
28
+ setDisplayName(newDisplayName);
29
+ widget.setProp('display-name', newDisplayName);
30
+ }, [setDisplayName]);
20
31
 
21
32
  return (
22
33
  <WixDesignSystemProvider>
23
- <SidePanel width="300">
34
+ <SidePanel width="300" height="100vh">
24
35
  <SidePanel.Content noPadding stretchVertically>
25
36
  <SidePanel.Field>
26
- <FormField label="Your name">
37
+ <FormField label="Display Name">
27
38
  <Input
28
39
  type="text"
29
- value={name}
30
- onChange={(event) => {
31
- const newName = event.target.value;
32
- setName(newName);
33
- widget.setProp('display-name', newName);
34
- }}
40
+ value={displayName}
41
+ onChange={handleDisplayNameChange}
42
+ aria-label="Display Name"
35
43
  />
36
44
  </FormField>
37
45
  </SidePanel.Field>
38
46
  </SidePanel.Content>
47
+ <SidePanel.Footer noPadding>
48
+ <SectionHelper fullWidth appearance="success" border="topBottom">
49
+ Learn more about <a href={SITE_WIDGETS_DOCS} target="_blank" rel="noopener noreferrer" title="Site Widget docs">Site Widgets</a>
50
+ </SectionHelper>
51
+ </SidePanel.Footer>
39
52
  </SidePanel>
40
53
  </WixDesignSystemProvider>
41
54
  );
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "@wix/code": "^1.0.2"
4
+ }
5
+ }
@@ -4,10 +4,17 @@ to: <%- filePath -%>.web.ts
4
4
  /**
5
5
  This file allows you to define backend functions that you can call from the front end of this app with type-safety.
6
6
 
7
- To learn more, check out our documentation: https://wix.to/Iabrrso.
7
+ Here's how you can call your web method from your frontend code:
8
+
9
+ import { multiply } from '<path-to-your-web-methods-directory>/<%- fileName -%>.web';
10
+
11
+ multiply(3, 4)
12
+ .then(result => console.log(result));
13
+
14
+ To learn more, check out our documentation: https://wix.to/6LV6Oka.
8
15
  */
9
16
 
10
- import { webMethod, Permissions } from '@wix/web-methods';
17
+ import { webMethod, Permissions } from '@wix/code/web-methods';
11
18
 
12
19
  export const multiply = webMethod(
13
20
  Permissions.Anyone,