42 lines
7.5 KiB
JavaScript
42 lines
7.5 KiB
JavaScript
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["7773"],{7512:function(e,s,n){n.r(s),n.d(s,{Code:()=>h,AppVersionLink:()=>p,default:()=>v,GetPermanentUrl:()=>u,frontMatter:()=>a,metadata:()=>t,assets:()=>c,FullCode:()=>m,toc:()=>f,contentTitle:()=>d});var t=JSON.parse('{"id":"features/permanent-url","title":"Permanent URL","description":"Any specific version of LiveCodes app can be accessed through the permanent unique URL:","source":"@site/docs/features/permanent-url.mdx","sourceDirName":"features","slug":"/features/permanent-url","permalink":"/docs/features/permanent-url","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/features/permanent-url.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Read-Only","permalink":"/docs/features/read-only"},"next":{"title":"Code Prefill","permalink":"/docs/features/code-prefill"}}'),r=n("5893"),i=n("65"),o=n("7262"),l=n("1705");let a={},d="Permanent URL",c={},p=()=>{let{siteConfig:e}=(0,o.Z)();return(0,r.jsxs)("a",{href:`https://v${e.customFields.appVersion}.livecodes.io`,target:"\\_blank",children:["https://v",e.customFields.appVersion,".livecodes.io"]})},h=()=>{let{siteConfig:e}=(0,o.Z)();return(0,r.jsx)(l.Z,{title:"index.html",language:"html",children:`<div id="container"></div>
|
|
<script type="module">
|
|
// specific SDK version
|
|
// highlight-next-line
|
|
import { createPlayground } from 'https://cdn.jsdelivr.net/npm/livecodes@${e.customFields.sdkVersion}';
|
|
|
|
createPlayground('#container', {
|
|
// App permanent URL
|
|
// highlight-next-line
|
|
appUrl: 'https://v${e.customFields.appVersion}.livecodes.io',
|
|
template: 'react',
|
|
});
|
|
</script>`})},u=()=>{let{siteConfig:e}=(0,o.Z)();return(0,r.jsx)(l.Z,{language:"js",children:`await livecodes.exec('showVersion');
|
|
|
|
// output:
|
|
// App Version: ${e.customFields.appVersion} (https://github.com/live-codes/livecodes/releases/tag/v${e.customFields.appVersion})
|
|
// SDK Version: ${e.customFields.sdkVersion} (https://www.npmjs.com/package/livecodes/v/${e.customFields.sdkVersion})
|
|
// Git commit: 0698f9f (https://github.com/live-codes/livecodes/commit/0698f9f)
|
|
// App Permanent URL: https://v${e.customFields.appVersion}.livecodes.io/
|
|
// SDK Permanent URL: https://cdn.jsdelivr.net/npm/livecodes@${e.customFields.sdkVersion}/livecodes.js
|
|
`})},m=()=>{let{siteConfig:e}=(0,o.Z)();return(0,r.jsx)(l.Z,{title:"index.html",language:"html",children:`<div id="container"></div>
|
|
<script type="module">
|
|
// specific SDK version
|
|
// highlight-next-line
|
|
import { createPlayground } from 'https://cdn.jsdelivr.net/npm/livecodes@${e.customFields.sdkVersion}';
|
|
|
|
createPlayground('#container', {
|
|
// App permanent URL
|
|
// highlight-next-line
|
|
appUrl: 'https://v${e.customFields.appVersion}.livecodes.io',
|
|
config: {
|
|
script: {
|
|
language: 'javascript',
|
|
// project code imports package with specific version
|
|
// highlight-next-line
|
|
content: 'import lodash from "lodash@4.17.21";\\nconsole.log(lodash.VERSION);',
|
|
},
|
|
activeEditor: 'script',
|
|
tools: { status: 'open', active: 'console' },
|
|
},
|
|
});
|
|
</script>`})},f=[{value:"Get Permanent URL",id:"get-permanent-url",level:2},{value:"Full Example:",id:"full-example",level:4},{value:"Related",id:"related",level:2}];function x(e){let s={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.header,{children:(0,r.jsx)(s.h1,{id:"permanent-url",children:"Permanent URL"})}),"\n",(0,r.jsx)(s.p,{children:"Any specific version of LiveCodes app can be accessed through the permanent unique URL:"}),"\n","\n","\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.code,{children:"{version}.livecodes.io"}),"\n(e.g. ",(0,r.jsx)(p,{}),")"]}),"\n",(0,r.jsxs)(s.p,{children:["This allows ",(0,r.jsx)(s.a,{href:"/docs/features/embeds",children:"embedded playgrounds"})," to use a pinned version of the LiveCodes app and its dependencies and avoid any breaking changes that may occur in later versions."]}),"\n",(0,r.jsxs)(s.p,{children:["Permanent URL is used by default in the code generated by the ",(0,r.jsx)(s.a,{href:"/docs/features/embeds",children:"embed screen UI"}),".\nIt is also available when ",(0,r.jsx)(s.a,{href:"/docs/features/share",children:"sharing"})," projects from the share screen."]}),"\n",(0,r.jsxs)(s.p,{children:["The ",(0,r.jsx)(s.a,{href:"/docs/sdk/",children:"SDK"})," embed option ",(0,r.jsx)(s.a,{href:"/docs/sdk/js-ts#appurl",children:(0,r.jsx)(s.code,{children:"appUrl"})})," allows specifying the URL for the app to be used.\nIn addition, it is always a good practice to use a specific version of the SDK."]}),"\n",(0,r.jsx)(s.p,{children:"Example:"}),"\n","\n",(0,r.jsx)(h,{}),"\n",(0,r.jsx)(s.h2,{id:"get-permanent-url",children:"Get Permanent URL"}),"\n",(0,r.jsxs)(s.p,{children:["You can get the permanent URL for the app from the ",(0,r.jsx)(s.a,{href:"pathname:///../?screen=about",children:"About screen"})," (Help menu \u2192 About). By default, the code generated in the ",(0,r.jsx)(s.a,{href:"/docs/features/embeds#app-embed-screen",children:"Embed screen"})," uses permanent URL.\nAlternatively, open the browser console of the standalone app (e.g. ",(0,r.jsx)(s.a,{href:"https://livecodes.io",children:"https://livecodes.io"}),"), and run this:"]}),"\n","\n",(0,r.jsx)(u,{}),"\n",(0,r.jsxs)(s.admonition,{type:"caution",children:[(0,r.jsxs)(s.p,{children:["Please note that this only applies to the LiveCodes app and its dependencies.\n",(0,r.jsx)(s.a,{href:"/docs/features/module-resolution",children:"NPM imports"})," in ",(0,r.jsx)(s.a,{href:"/docs/features/projects#script-editor",children:"project code"})," that do not specify versions use the latest version.\n",(0,r.jsx)(s.a,{href:"/docs/features/module-resolution#package-version",children:"Package versions"})," can be specified in the import.\n",(0,r.jsx)(s.a,{href:"/docs/features/module-resolution#custom-module-resolution",children:"Custom import maps"})," can be set to control the module import behavior."]}),(0,r.jsx)(s.p,{children:"Example:"}),(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-js",children:"import lodash from 'lodash@4.17.21';\n\nconsole.log(lodash.VERSION); // -> 4.17.21\n"})}),(0,r.jsxs)(s.p,{children:["It is recommended to also specify versions of ",(0,r.jsx)(s.a,{href:"/docs/features/external-resources",children:"external resources"}),"."]})]}),"\n",(0,r.jsx)(s.h4,{id:"full-example",children:"Full Example:"}),"\n","\n",(0,r.jsx)(m,{}),"\n",(0,r.jsx)(s.h2,{id:"related",children:"Related"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"/docs/features/embeds",children:"Embedded playgrounds"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"/docs/features/share",children:"Share"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"/docs/sdk/",children:"SDK"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsxs)(s.a,{href:"/docs/sdk/js-ts#exec",children:[(0,r.jsx)(s.code,{children:"exec"})," SDK method"]})}),"\n"]})]})}function v(e={}){let{wrapper:s}={...(0,i.a)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(x,{...e})}):x(e)}},65:function(e,s,n){n.d(s,{Z:function(){return l},a:function(){return o}});var t=n(7294);let r={},i=t.createContext(r);function o(e){let s=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),t.createElement(i.Provider,{value:s},e.children)}}}]); |