打包好的livecode,版本v-46

This commit is contained in:
yangxin
2025-06-11 22:23:49 +08:00
commit 1214258379
1323 changed files with 133464 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
const e=require("fs"),t=require("crypto"),i=async({devMode:i=!1,buildDir:r="build/livecodes/",entryPoint:a="index.js",patchFiles:l=["build/index.html"],hashPattern:s=/{{hash:([\w\.-]+)}}/g}={})=>{let n=["js","css","html","svg","ico","png","json"],o=async t=>(await e.promises.readdir(t)).filter(i=>!e.statSync(t+i).isDirectory()).filter(e=>n.some(t=>e.endsWith("."+t))),f=async e=>{let t=[];for(let i of e)(await o(i)).forEach(e=>{t.push(i+e)});return t},w=async()=>{for(let t of[...l,...await f([r])]){let i=(await e.promises.readFile(t,"utf8")).replace(new RegExp(s),(e,t)=>t);await e.promises.writeFile(t,i,"utf8")}};if(i)return w();let c=(e,t)=>{let i=n.find(t=>e.endsWith("."+t));return i&&(e=u(e).replace(`.${i}`,`.${t}.${i}`)),e},u=e=>{let t=e.split(".");return e.length<35||t.length<3?e:t.filter((e,t)=>32!==e.length||0===t).join(".")},p=e=>t.createHash("md5").update(e).digest("hex"),d={},h=async t=>{if(d[t])return;d[t]="waiting";let a=await e.promises.readFile(r+t,"utf8").catch(e=>{if(i)return"";throw e});for(let e of a.matchAll(new RegExp(s))){let t=e[1];t&&!d[t]&&await h(t)}let l=a.replace(new RegExp(s),(e,t)=>d[t]);if(i){d[t]=t,await e.promises.writeFile(r+t,l,"utf8");return}let n=c(t,p(l));d[t]=n,await e.promises.writeFile(r+n,l,"utf8")};for(let t of(await h(a),Object.keys(d)))d[t]!==t&&await e.promises.unlink(r+t).catch(e=>{if(!i)throw e});for(let t of l){let i=(await e.promises.readFile(t,"utf8")).replace(new RegExp(s),(e,t)=>d[t]);await e.promises.writeFile(t,i,"utf8")}};module.exports={applyHash:i},require.main===module&&i();

View File

@@ -0,0 +1,5 @@
const e=require("fs"),i=require("path"),r=`// @ts-nocheck
// This comment is added by i18n-exclude script and should be automatically removed after build.
// If you see this comment in the file, it means there is something wrong during the build process.
`,t=i.resolve("src/livecodes/i18n/locales");require.main===module&&(()=>{if("true"===process.env.BUILD_INCLUDE_LOCALES)return;let s=process.argv[2];console.log(`Running i18n-exclude in ${s} phase`),e.readdirSync(t,{withFileTypes:!0}).filter(e=>e.isDirectory()&&"en"!==e.name).map(e=>i.join(t,e.name)).forEach(t=>{for(let n of e.readdirSync(t).filter(e=>e.endsWith(".ts")).map(e=>i.join(t,e))){let i=e.readFileSync(n,"utf8");"pre"===s?i.startsWith(r)||(i=r+i):"post"===s&&(i=i.replace(r,"")),e.writeFileSync(n,i,"utf8")}})})(),module.exports={TS_NOCHECK:r};

View File

@@ -0,0 +1,18 @@
const e=require("fs"),t=require("path"),a=require("jsdom"),r=require("prettier"),n=require("@babel/core"),s=require("@babel/parser"),i=require("../package.json"),o=t.resolve("src/livecodes/i18n/locales/tmp"),l=t.resolve("src/livecodes/i18n/locales/en"),u=t.resolve("src/livecodes"),c=i.prettier,p="// ATTENTION: This file is auto-generated from source code. Do not edit manually!",d={translation:{},"language-info":{}},m={translation:{},"language-info":{}},g=(e,t=2)=>JSON.stringify(e,(e,t)=>t instanceof Object&&!(t instanceof Array)?Object.keys(t).sort().reduce((e,a)=>(e[a]=t[a],e),{}):t,t),h=async(a,n)=>{let s="translation"===a?"translation":"languageInfo",i=`${p}
import type { I18nTranslationTemplate } from '../models';
// This is used as a template for other translations.
// Other translations should be typed like this:
// const ${s}: ${"translation"===a?"I18nTranslation":"I18nLangInfoTranslation"} = { /* translation here */ };
// Since we allow nested objects, it is important to distinguish I18nTranslationTemplate from I18nAttributes.
// In view of this, properties declared in I18nAttributes (and those attributes might be used in future) shall not be used as a nested key.
const ${s} = ${g(d[a])} as const satisfies I18nTranslationTemplate;
export default ${s};
`,u=await r.format(i,{parser:"typescript",...c});m[a].$comment=p.substring(3);let h=n?o:l;e.existsSync(h)||e.mkdirSync(h,{recursive:!0}),await Promise.all([e.promises.writeFile(t.join(h,a+".ts"),u),e.promises.writeFile(t.join(h,a+".lokalise.json"),await r.format(g(m[a]).replace(/<(\/?)(\d+)>/g,"<$1tag-$2>"),{parser:"json",...c}))]),console.log(`Generated namespace ${a} in ${h}.`)},f=(e,t,a,r)=>{let n=(e=e.split(":")).pop(),s=1===e.length?e.pop():"translation",i=n.split("."),o=d[s];i.forEach((e,a)=>{o[e]?a===i.length-1&&o[e]!==t&&console.error(`Duplicate key: ${n}`):o[e]=a===i.length-1?t:{},o=o[e]}),r&&1!==r.length?r.forEach(e=>{m[s][n+`#${e}`]={translation:t[e],notes:a[e]}}):m[s][n]={translation:t,notes:a}},y=e=>{let t=new a.JSDOM(e).window.document,r=[],n=0,s=e=>{if(e.nodeType!==t.ELEMENT_NODE)return;e.childNodes.forEach(e=>{s(e)});let a=e.tagName.toLowerCase();if("body"===a)return;let i=0===e.attributes.length?void 0:Array.from(e.attributes).reduce((e,t)=>(e[t.name]=t.value,e),{});r.push({name:a,attributes:i});let o=t.createElement(`tag-${n}`);for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode.replaceChild(o,e),n++};s(t.body);let i=1,o=[],l=t.body.innerHTML.replace(/tag-/g,""),u=[];return l=l.replace(/<(\d+)>/g,(e,t)=>(u.push(r[t]),o.push({from:RegExp(`</${t}>`,"g"),to:`<*/${i}>`}),`<${i++}>`)),o.forEach(({from:e,to:t})=>{l=l.replace(e,t)}),{html:l=l.replace(/<\*\//g,"</"),elements:u}},v=e=>e.map((e,t)=>`### <${t+1}> ###
<${e.name} ${e.attributes?Object.keys(e.attributes).map(t=>`${t}="${e.attributes[t]}"`).join(" "):""} />
`).join(""),b=async t=>{let r=(e,t)=>{if("innerHTML"===t){let{html:t,elements:a}=y(e.innerHTML);return{value:t.trim(),desc:v(a)}}return{value:(t.startsWith("data-")?e.dataset[t.slice(5)]:e[t]||e.getAttribute(t)).trim(),desc:""}};f("translation:splash.loading","Loading LiveCodes\u2026","",["textContent"]),await Promise.all(t.map(async t=>{try{let n=(await e.promises.readFile(t,"utf8")).replace(/\s+/g," ").trim();new a.JSDOM(n).window.document.querySelectorAll("[data-i18n]").forEach(e=>{let t=e.getAttribute("data-i18n"),a=(e.getAttribute("data-i18n-prop")??"textContent").split(" "),{value:n,desc:s}=1===a.length?r(e,a[0]):a.reduce((t,a)=>{let n=r(e,a);return t.value[a]=n.value,t.desc[a]=n.desc,t},{value:{},desc:{}});f(t,n,s,a)})}catch(e){console.error(e)}}))},$=async t=>{await Promise.all(t.map(async t=>{try{let a=await e.promises.readFile(t,"utf8"),r=s.parse(a,{sourceType:"module",plugins:["typescript"]});n.traverse(r,{CallExpression(e){if("MemberExpression"===e.node.callee.type&&"Identifier"===e.node.callee.property.type&&"translateString"===e.node.callee.property.name&&e.node.arguments.length>=2&&"StringLiteral"===e.node.arguments[0].type&&"StringLiteral"===e.node.arguments[1].type){if(!e.node.arguments[2]||e.node.arguments[2].properties.every(e=>!e.key||!e.value||"isHTML"!==e.key.name||"isHTML"===e.key.name&&!0!==e.value.value))f(e.node.arguments[0].value,e.node.arguments[1].value,"",void 0);else{let{html:t,elements:a}=y(e.node.arguments[1].value);f(e.node.arguments[0].value,t.trim(),v(a),void 0)}}}})}catch(e){console.error(e)}}))},w=function(a,r=[]){return e.readdirSync(a).forEach(function(n){let s=a+t.sep+n;e.statSync(s).isDirectory()?r=w(s,r):r.push(s)}),r},T=async()=>{let e=process.argv.slice(2).filter(e=>!e.startsWith("-")),a=process.argv.includes("--save-temp"),r=[],n=[];e.length||e.push(...w(u)),r.push(...e.filter(e=>e.endsWith(".html")&&e.startsWith(t.resolve(u,`html${t.sep}`))).map(e=>t.resolve(u,e))),n.push(...e.filter(e=>e.endsWith(".ts")).map(e=>t.resolve(u,e))),await b(r),await $(n),h("translation",a),Object.keys(d["language-info"]).length>0&&h("language-info",a)};module.exports={generateTranslation:T,sortedJSONify:g,prettierConfig:c,autoGeneratedWarning:p},require.main===module&&T();

View File

@@ -0,0 +1,8 @@
import{LokaliseApi as e}from"@lokalise/node-api";import{execSync as o}from"child_process";import i from"fs";import r from"path";import a from"prettier";import{exit as s}from"process";import{autoGeneratedWarning as t,prettierConfig as n,sortedJSONify as l}from"./i18n-export.js";let p=r.resolve("src/livecodes/i18n/locales"),c=r.join(p,"tmp"),f=new e({apiKey:process.env.LOKALISE_API_TOKEN}),d=process.env.LOKALISE_PROJECT_ID,m=async(e,o)=>{let r=JSON.parse(await i.promises.readFile(e,"utf-8")),a={};for(let e in r){if(!o.has(e))continue;let i=e.split("."),s=i.pop(),t=a;i.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[s]=r[e].replace(/tag-/g,"")}return a};(async()=>{let e="true"===process.env.CI,u=process.argv.slice(2).includes("--force"),g=process.argv.slice(2).includes("--local");e||u||(console.error("This script is intended to be run in CI mode or with --force flag."),s(1));let w=process.argv[2];w||(console.error("Branch name is required"),s(1));let $=r.resolve(process.env.LOKALISE_TEMP);if(!g){let e;console.log("Fetching translations from Lokalise...");let a=`${d}:${w}`,t=await f.files().async_download(a,{format:"json",original_filenames:!0,json_unescaped_slashes:!0,replace_breaks:!1,placeholder_format:"i18n"}),n=Date.now();for(;;){let o=await f.queuedProcesses().get(t.process_id,{project_id:a});if("finished"===o.status){e=o.details;break}Date.now()-n>6e4&&(console.error("Timeout exceeded. Aborting..."),s(1)),await new Promise(e=>setTimeout(e,2500))}console.log(`Downloading zip file from ${e.download_url}`);let l=r.join($,"locales.zip"),p=await fetch(e.download_url);await i.promises.writeFile(l,Buffer.from(await p.arrayBuffer())),console.log(`Extracting zip file to ${$}...`),o(`unzip -o ${l} -d ${$}`),await i.promises.unlink(l)}let _=await i.promises.readdir($);console.log(`Extracted languages to tmp directory, ${_.length} languages (including English) found.`),console.log("Checking if translation keys are outdated...");let h={},j={};for(let e of(o("npm run i18n-export -- --save-temp",{stdio:"pipe"}),(await i.promises.readdir(c)).filter(e=>e.endsWith(".lokalise.json")))){let o=e.split(".")[0],a=r.join(c,e),s=JSON.parse(await i.promises.readFile(a,"utf-8"));for(let e in h[o]={},s)h[o][e]=s[e].translation}let y=r.join($,"en");for(let e of(await i.promises.readdir(y))){let o=e.split(".")[0],a=r.join(y,e),s=JSON.parse(await i.promises.readFile(a,"utf-8"));for(let e in j[o]=new Set,s){if(h[o][e]){if(h[o][e]!==s[e]){console.warn(`Skipping: Key ${e} in namespace ${o} is outdated.`);continue}}else{console.warn(`Skipping: Key ${e} in namespace ${o} is missing in local translation.`);continue}j[o].add(e)}}for(let e of _){let o=r.join($,e);if(!(await i.promises.stat(o)).isDirectory()||"en"===e)continue;e=e.replace(/_/g,"-");let s=r.join(p,e);console.log(`Importing language ${e}...`),await i.promises.mkdir(s,{recursive:!0});let c=(await i.promises.readdir(o)).map(async e=>{let p=r.join(o,e),c=r.join(s,e.replace(".lokalise.json",".ts")),f=e.split(".")[0],d="translation"===f?"translation":"languageInfo",u="translation"===f?"I18nTranslation":"I18nLangInfoTranslation",g=l(await m(p,j[f])),w=`${t}
import type { ${u} } from '../models';
const ${d}: ${u} = ${g};
export default ${d};
`,$=await a.format(w,{parser:"typescript",...n});return i.promises.writeFile(c,$)});await Promise.all(c)}})();

View File

@@ -0,0 +1 @@
import e from"@babel/core";import r from"@babel/parser";import t from"fs";import s from"path";import{autoGeneratedWarning as o,sortedJSONify as l}from"./i18n-export.js";let a=(e,r="")=>Object.keys(e).reduce((t,s)=>{let o=e[s];return"object"==typeof o?{...t,...a(o,`${r}${s}.`)}:{...t,[`${r}${s}`]:o}},{}),n=e=>{if(!e)throw Error("Node is undefined or null");let r={};return e.properties.forEach(e=>{r[e.key.name||e.key.value]=i(e.value)}),r},i=e=>{switch(e.type){case"ObjectExpression":return n(e);case"ArrayExpression":return e.elements.map(i);case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":return e.value;case"NullLiteral":return null;default:throw Error(`Unsupported node type: ${e.type}`)}},c=async i=>{let c=s.resolve("src/livecodes/i18n/locales/"+i);if(t.existsSync(c)){if("en"===i){console.warn("This script is not intended to be run for English language.\nPlease use `npm run i18n-export` instead.");return}}else{console.error(`Language ${c} does not exist.`);return}return Promise.all(t.readdirSync(c).filter(e=>e.endsWith(".ts")).map(e=>s.resolve(c,e)).map(async p=>{try{let u;console.log(`Generating Lokalise JSON for ${p} in language ${i}...`);let m=await t.promises.readFile(p,"utf8"),d=r.parse(m,{sourceType:"module",plugins:["typescript"]});e.traverse(d,{ObjectExpression(e){u=n(e.node),e.stop()}});let f={$comment:o.substring(3)};for(let[e,r]of Object.entries(a(u)))f[e]={translation:r};let y=s.resolve(c,p.replace(".ts",".lokalise.json"));await t.promises.writeFile(y,l(f).replace(/<(\/?)(\d+)>/g,"<$1tag-$2>"))}catch(e){console.error(e)}}))};(async()=>{let e=new Set(process.argv.slice(2));if(e.has("all")){e.delete("all");let r=s.resolve("src/livecodes/i18n/locales");t.readdirSync(r).filter(e=>t.statSync(s.resolve(r,e)).isDirectory()&&"en"!==e&&"tmp"!==e).forEach(r=>e.add(r))}await Promise.all([...e].map(c))})();

View File

@@ -0,0 +1,38 @@
name: i18n-update-notify
on:
pull_request_target:
branches: [develop]
types: [closed]
paths: ['src/livecodes/i18n/locales/**']
jobs:
notify:
name: Notify
runs-on: ubuntu-latest
if: github.event.pull_request.merged && github.event.sender.login != 'github-actions[bot]' && !startsWith(github.head_ref, 'i18n/')
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Create comment on PR
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const commentBody = `## i18n Actions
Source PR has been merged into the default branch.
Maintainers can comment \`.i18n-update-push\` to trigger the i18n update workflow and push the changes to Lokalise.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})

View File

@@ -0,0 +1,235 @@
name: i18n-update-pull
on:
issue_comment:
types: [created]
env:
LOKALISE_PROJECT_ID: ${{ vars.LOKALISE_PROJECT_ID }}
LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_API_TOKEN }}
NODE_VERSION: 18.x
CI: true
jobs:
precheck:
name: Pre-check
runs-on: ubuntu-latest
if: github.event.issue.pull_request && github.event.issue.pull_request.merged_at && github.event.issue.state == 'closed' && github.event.comment.body == '.i18n-update-pull' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
outputs:
skip: ${{ steps.fetch-pr.outputs.skip }}
skipReason: ${{ steps.fetch-pr.outputs.skipReason }}
newBranch: ${{ steps.fetch-pr.outputs.newBranch }}
branch: ${{ steps.fetch-pr.outputs.branch }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Fetch PR details
id: fetch-pr
run: |
PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}")
PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref')
skip () {
echo "$1 Exiting..."
echo "skip=true" >> $GITHUB_OUTPUT
echo "skipReason=$1" >> $GITHUB_OUTPUT
}
if [[ $PR_BRANCH == "i18n/"* ]]; then
skip "Branch \`$PR_BRANCH\` is a i18n branch."
fi
PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g')
NEW_BRANCH="i18n/$PR_BRANCH"
echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT
echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT
git config --global user.name "livecodes-ci[bot]"
git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com"
if [[ ! $(git ls-remote --heads origin $NEW_BRANCH) ]]; then
skip "Branch \`$NEW_BRANCH\` does not exist."
fi
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
runner:
name: Runner
runs-on: ubuntu-latest
needs: precheck
if: needs.precheck.outputs.skip != 'true'
env:
NEW_BRANCH: ${{ needs.precheck.outputs.newBranch }}
PR_BRANCH: ${{ needs.precheck.outputs.branch }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ needs.precheck.outputs.newBranch }}
token: ${{ steps.generate-token.outputs.token }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Import from Lokalise
run: |
mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $PR_BRANCH && rm -rf $LOKALISE_TEMP
env:
LOKALISE_TEMP: lokalise_tmp
- name: Generate Lokalise JSON files
run: npm run i18n-lokalise-json all
- name: Linting and fixing
run: npm run fix
- name: Commit changes
run: |
git config --global user.name "livecodes-ci[bot]"
git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com"
git add .
# Only commit if there are changes
git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise"
# Save SHA of the latest commit to locale
echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV
- name: Push changes
run: git push origin $NEW_BRANCH
- name: Create a new i18n PR, comment on source PR and reaction
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const repoURL = context.payload.repository.html_url;
const branchURL = `${repoURL}/tree/${process.env.NEW_BRANCH}`;
const prTitle = `i18n: ${{ github.event.issue.title }}`;
const prBody = `## What type of PR is this? (check all applicable)
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 📝 Documentation Update
- [ ] 🎨 Style
- [ ] ♻️ Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore (Release)
- [ ] ⏩ Revert
- [x] 🌐 Internationalization / Translation
## Description
### i18n Actions: \`.i18n-update-pull\`
Localization pulled from Lokalise.
| Name | Description |
| --- | --- |
| **i18n Branch** | [\`${process.env.NEW_BRANCH}\`](${branchURL}) |
| **Last Commit SHA** | ${process.env.LAST_COMMIT_SHA} |
## Related Tickets & Documents
- **Source PR**: #${{ github.event.issue.number }}
`;
const prInfo = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: prTitle,
body: prBody,
head: process.env.NEW_BRANCH,
base: '${{ github.event.repository.default_branch }}'
});
const commentBody = `## i18n Actions: \`.i18n-update-pull\`
Localization pulled from Lokalise.
| Name | Description |
| --- | --- |
| **i18n Branch** | [\`${process.env.NEW_BRANCH}\`](${branchURL}) |
| **Last Commit SHA** | ${process.env.LAST_COMMIT_SHA} |
| **i18n PR** | #${prInfo.data.number} |
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: 'rocket'
});
exception:
name: Exception
runs-on: ubuntu-latest
needs: precheck
if: needs.precheck.outputs.skip == 'true'
env:
SKIP_REASON: ${{ needs.precheck.outputs.skipReason }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Create reaction on PR
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const runURL = `${context.payload.repository.html_url}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commentBody = `## i18n Actions: \`.i18n-update-pull\`
Failed to perform action due to following reason: **${process.env.SKIP_REASON}**
Please check [action logs](${runURL}) for more details.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: 'confused'
});

View File

@@ -0,0 +1,195 @@
name: i18n-update-push
on:
issue_comment:
types: [created]
env:
LOKALISE_PROJECT_ID: ${{ vars.LOKALISE_PROJECT_ID }}
LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_API_TOKEN }}
NODE_VERSION: 18.x
CI: true
jobs:
precheck:
name: Pre-check
runs-on: ubuntu-latest
if: github.event.issue.pull_request && github.event.issue.pull_request.merged_at && github.event.issue.state == 'closed' && github.event.comment.body == '.i18n-update-push' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
outputs:
skip: ${{ steps.fetch-pr.outputs.skip }}
skipReason: ${{ steps.fetch-pr.outputs.skipReason }}
newBranch: ${{ steps.fetch-pr.outputs.newBranch }}
branch: ${{ steps.fetch-pr.outputs.branch }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Fetch PR details
id: fetch-pr
run: |
PR_DETAILS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "${{ github.event.issue.pull_request.url }}")
PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.ref')
if [[ $PR_BRANCH == "i18n/"* ]]; then
SKIP_REASON="Branch \`$PR_BRANCH\` is a i18n branch."
echo "$SKIP_REASON Exiting..."
echo "skip=true" >> $GITHUB_OUTPUT
echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT
fi
# Use branch name prefixed with owner name
PR_BRANCH=$(echo "$PR_DETAILS" | jq -r '.head.label' | sed 's/:/\//g')
NEW_BRANCH="i18n/$PR_BRANCH"
echo "newBranch=$NEW_BRANCH" >> $GITHUB_OUTPUT
echo "branch=$PR_BRANCH" >> $GITHUB_OUTPUT
git config --global user.name "livecodes-ci[bot]"
git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com"
if [[ $(git ls-remote --heads origin $NEW_BRANCH) ]]; then
SKIP_REASON="Branch \`$NEW_BRANCH\` already exists."
echo "$SKIP_REASON Exiting..."
echo "skip=true" >> $GITHUB_OUTPUT
echo "skipReason=$SKIP_REASON" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
runner:
name: Runner
runs-on: ubuntu-latest
needs: precheck
if: needs.precheck.outputs.skip != 'true'
env:
NEW_BRANCH: ${{ needs.precheck.outputs.newBranch }}
PR_BRANCH: ${{ needs.precheck.outputs.branch }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Create new branch
run: git checkout -b $NEW_BRANCH
- name: Linting and fixing
run: npm run fix
- name: Commit changes
run: |
git config --global user.name "livecodes-ci[bot]"
git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com"
git add .
# Only commit if there are changes
git diff-index --quiet HEAD || git commit -m "i18n: update source texts"
# Save SHA of the latest commit to English locale
echo "LAST_COMMIT_SHA=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV
- name: Push changes
run: git push origin $NEW_BRANCH
- name: Push source texts to Lokalise
run: npm run i18n-update-push -- $PR_BRANCH
- name: Create comment and reaction on PR
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const repoURL = context.payload.repository.html_url;
const branchURL = `${repoURL}/tree/${process.env.NEW_BRANCH}`;
const commentBody = `## i18n Actions: \`.i18n-update-push\`
Localization updated and pushed to [Lokalise](https://app.lokalise.com/project/${process.env.LOKALISE_PROJECT_ID}/?branch=${process.env.PR_BRANCH}).
| Name | Description |
| --- | --- |
| **New Branch for i18n** | [\`${process.env.NEW_BRANCH}\`](${branchURL}) |
| **Last Commit SHA** | ${process.env.LAST_COMMIT_SHA} |
Maintainers can comment \`.i18n-update-pull\` after translation is done to trigger the i18n pull workflow and pull the changes back to Github.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: 'rocket'
});
exception:
name: Exception
runs-on: ubuntu-latest
needs: precheck
if: needs.precheck.outputs.skip == 'true'
env:
SKIP_REASON: ${{ needs.precheck.outputs.skipReason }}
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Create comment and reaction on PR
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const runURL = `${context.payload.repository.html_url}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const commentBody = `## i18n Actions: \`.i18n-update-push\`
Failed to perform action due to following reason: **${process.env.SKIP_REASON}**
Please check [action logs](${runURL}) for more details.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ github.event.comment.id }},
content: 'confused'
});

View File

@@ -0,0 +1,179 @@
name: i18n-update-scheduled
# Triggered weekly to update source texts and push them to Lokalise, then pull the translations back to Github.
# Work on i18n/develop branch.
on:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- develop
workflow_dispatch:
env:
LOKALISE_PROJECT_ID: ${{ vars.LOKALISE_PROJECT_ID }}
LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_API_TOKEN }}
BRANCH: i18n/develop
LOKALISE_BRANCH: master
NODE_VERSION: 18.x
CI: true
jobs:
update:
name: Push and Pull
runs-on: ubuntu-latest
steps:
- name: Generate Github Token for CI Bot
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Switch to i18n branch
run: |
git config --global user.name "livecodes-ci[bot]"
git config --global user.email "186997172+livecodes-ci[bot]@users.noreply.github.com"
if [[ $(git ls-remote --heads origin $BRANCH) ]]; then
git config pull.rebase false
git fetch origin $BRANCH:$BRANCH
git checkout $BRANCH
else
git checkout -b $BRANCH
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install dependencies
run: npm ci
# - name: Linting and fixing
# run: npm run fix
# - name: Commit changes
# run: |
# git add .
# # Only commit if there are changes
# git diff-index --quiet HEAD || git commit -m "i18n: update source texts"
# # Save SHA of the latest commit to English locale
# echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV
# - name: Push changes
# run: git push origin $BRANCH
# - name: Push source texts to Lokalise
# run: npm run i18n-update-push -- $LOKALISE_BRANCH
- name: Import from Lokalise
run: |
mkdir -p $LOKALISE_TEMP && touch $LOKALISE_TEMP/locales.zip && npm run i18n-update-pull -- $LOKALISE_BRANCH && rm -rf $LOKALISE_TEMP
env:
LOKALISE_TEMP: lokalise_tmp
- name: Linting and fixing
run: npm run fix
- name: Commit changes
run: |
git add .
# Only commit if there are changes
git diff-index --quiet HEAD || git commit -m "i18n: pull translation from Lokalise"
# Save SHA of the latest commit to locale
echo "LAST_COMMIT_SHA_PULL=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales)" >> $GITHUB_ENV
- name: Push changes
run: |
git pull origin ${{ github.event.repository.default_branch }} || {
echo "Failed to pull from ${{ github.event.repository.default_branch }}."
echo "Please manually pull the changes, solve potential conflicts, and re-run the workflow."
echo "::error title=Pull failed::Failed to pull from ${{ github.event.repository.default_branch }}."
exit 1
}
git push origin $BRANCH
- name: Check if has differences between ${{ env.BRANCH }} and ${{ github.event.repository.default_branch }}
id: check-diff
run: |
DIFF=$(git diff --name-only $BRANCH origin/${{ github.event.repository.default_branch }})
if [[ -z $DIFF ]]; then
echo "No difference between $BRANCH and ${{ github.event.repository.default_branch }}."
echo "SKIP=true" >> $GITHUB_OUTPUT
fi
echo "LAST_COMMIT_SHA_PUSH=$(git log -n 1 --format="%H" -- src/livecodes/i18n/locales/en)" >> $GITHUB_ENV
- name: Create a new i18n PR if not exists
uses: actions/github-script@v7
if: steps.check-diff.outputs.SKIP != 'true'
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const prInfo = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: process.env.BRANCH
});
if (prInfo.data.length > 0) {
return;
}
console.log(`Creating a new i18n PR from ${process.env.BRANCH}...`);
const repoURL = context.payload.repository.html_url;
const branchURL = `${repoURL}/tree/${process.env.BRANCH}`;
const prTitle = `i18n: scheduled update from ${process.env.BRANCH}`;
const prBody = `## What type of PR is this? (check all applicable)
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 📝 Documentation Update
- [ ] 🎨 Style
- [ ] ♻️ Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore (Release)
- [ ] ⏩ Revert
- [x] 🌐 Internationalization / Translation
## Description
### i18n Actions: \`.i18n-update-scheduled\`
Scheduled update of source texts and translations.
| Name | Description |
| --- | --- |
| **Last Commit SHA (Push)** | ${process.env.LAST_COMMIT_SHA_PUSH} |
| **Last Commit SHA (Pull)** | ${process.env.LAST_COMMIT_SHA_PULL} |
`;
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: prTitle,
body: prBody,
head: process.env.BRANCH,
base: '${{ github.event.repository.default_branch }}'
});

View File

@@ -0,0 +1,2 @@
import{LokaliseApi as e}from"@lokalise/node-api";import o from"fs";import r from"path";import{exit as s}from"process";let i=r.resolve("src/livecodes/i18n/locales/en"),a=new e({apiKey:process.env.LOKALISE_API_TOKEN}),n=process.env.LOKALISE_PROJECT_ID,t={cleanup_mode:!0,replace_modified:!0,convert_placeholders:!1};(()=>{let e="true"===process.env.CI,l=process.argv.slice(2).includes("--force");e||l||(console.error("This script is intended to be run in CI mode or with --force flag."),s(1));let c=process.argv[2];c||(console.error("Branch name is required"),s(1)),o.existsSync(i)||(console.error(`Directory ${i} doesn't exist, please run i18n-export first`),s(1)),o.readdir(i,async(e,l)=>{e&&(console.error(e),s(1));let p=l.filter(e=>e.endsWith(".lokalise.json")).map(e=>({data:o.readFileSync(r.join(i,e)).toString("base64"),filename:e,lang_iso:"en"}));console.log(`Following files will be uploaded to Lokalise:
${p.map(e=>e.filename).join("\n")}`),(await a.branches().list({project_id:n})).items.some(e=>e.name===c)||(console.log(`Branch ${c} doesn't exist. Creating...`),await a.branches().create({name:c},{project_id:n}));let d=(await Promise.all(p.map(e=>a.files().upload(`${n}:${c}`,{...e,...t})))).map(e=>e.process_id);console.log("Waiting for files to be processed...");let m=Date.now();for(;!(await Promise.all(d.map(e=>a.queuedProcesses().get(e,{project_id:`${n}:${c}`})))).every(e=>"finished"===e.status);)Date.now()-m>6e4&&(console.error("Timeout exceeded. Aborting..."),s(1)),await new Promise(e=>setTimeout(e,2500))})})();

View File

@@ -0,0 +1 @@
const e=require("fs"),t=require("path"),a={version:1.1,globalAttributes:[{name:"data-i18n",description:"The key of the translation for current element."},{name:"data-i18n-prop",description:"Attributes of the element that should be translated, separated by space.",valueSet:"i18nProps"},{name:"data-hint",description:"The tooltip of the element."}],valueSets:[]},l=async()=>{await new Promise((t,l)=>{e.readFile("src/livecodes/i18n/locales/models.ts","utf8",(e,s)=>{if(e)console.error(e),l(e);else{let e=s.match(/I18nAttributes.+?{([\s\S]*?)}/)[1].split("\n").map(e=>e.trim().replace(/['|;?]/g,"").split(":")[0]).filter(e=>""!==e);a.valueSets.push({name:a.globalAttributes[1].valueSet,values:e.map(e=>({name:e}))}),t()}})});let l=t.resolve(__dirname,"../.vscode/html.html-data.json");e.writeFileSync(l,JSON.stringify(a,null,2)),console.log(`HTML Intellisense schema generated at ${l}`)};module.exports={generateHTMLIntellisense:l},require.main===module&&l();

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["1024"],{327:function(e,t,n){n.r(t),n.d(t,{default:()=>u,frontMatter:()=>r,metadata:()=>o,assets:()=>a,toc:()=>d,contentTitle:()=>c});var o=JSON.parse('{"id":"gh-action","title":"GitHub Action \u26A1","description":"The Preview in LiveCodes GitHub Action generates preview links to playgrounds for code changes in pull requests and posts them as pull request comments.","source":"@site/docs/gh-action.mdx","sourceDirName":".","slug":"/gh-action","permalink":"/docs/gh-action","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/gh-action.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Bookmarklet","permalink":"/docs/bookmarklet"},"next":{"title":"Markdown to LiveCodes","permalink":"/docs/markdown-to-livecodes"}}'),i=n("5893"),s=n("65");let r={},c="GitHub Action \u26A1",a={},d=[];function l(e){let t={a:"a",h1:"h1",header:"header",img:"img",p:"p",strong:"strong",...(0,s.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"github-action-",children:"GitHub Action \u26A1"})}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.a,{href:"https://github.com/live-codes/preview-in-livecodes",children:"Preview in LiveCodes"})," GitHub Action generates preview links to playgrounds for code changes in pull requests and posts them as pull request comments."]}),"\n",(0,i.jsx)(t.p,{children:"Once added to a repo, it runs when a pull request is created or updated. The new code is optionally built. The action posts in a pull request comment links to playgrounds that can use the new code."}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.strong,{children:"Screenshot:"})}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{alt:"Screenshot of the action",src:n(4926).Z+"",width:"1603",height:"931"})}),"\n",(0,i.jsxs)(t.p,{children:["For usage and more information, see the ",(0,i.jsx)(t.a,{href:"https://github.com/live-codes/preview-in-livecodes",children:"action docs"})," on GitHub. Also check the ",(0,i.jsx)(t.a,{href:"https://github.com/hatemhosny/preview-in-livecodes-demo",children:"example repo"})," for a working demo."]})]})}function u(e={}){let{wrapper:t}={...(0,s.a)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(l,{...e})}):l(e)}},4926:function(e,t,n){n.d(t,{Z:function(){return o}});let o=n.p+"assets/images/preview-in-livecodes-gh-action-b5fb7b1cb63d1e5bfbce956185166e10.png"},65:function(e,t,n){n.d(t,{Z:function(){return c},a:function(){return r}});var o=n(7294);let i={},s=o.createContext(i);function r(e){let t=o.useContext(s);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),o.createElement(s.Provider,{value:t},e.children)}}}]);

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["4878"],{3322:function(e,n,t){t.r(n),t.d(n,{default:()=>h,frontMatter:()=>c,metadata:()=>s,assets:()=>d,toc:()=>l,contentTitle:()=>o});var s=JSON.parse('{"id":"api/internal/type-aliases/WatchDestroy","title":"Type Alias: WatchDestroy()","description":"WatchDestroy: (event, fn) => object","source":"@site/docs/api/internal/type-aliases/WatchDestroy.md","sourceDirName":"api/internal/type-aliases","slug":"/api/internal/type-aliases/WatchDestroy","permalink":"/docs/api/internal/type-aliases/WatchDestroy","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/api/internal/type-aliases/WatchDestroy.md","tags":[],"version":"current","frontMatter":{}}'),r=t("5893"),i=t("65");let c={},o="Type Alias: WatchDestroy()",d={},l=[{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"remove()",id:"remove",level:3},{value:"Returns",id:"returns-1",level:4},{value:"Defined in",id:"defined-in",level:2}];function a(e){let n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",p:"p",strong:"strong",...(0,i.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"type-alias-watchdestroy",children:"Type Alias: WatchDestroy()"})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"WatchDestroy"}),": (",(0,r.jsx)(n.code,{children:"event"}),", ",(0,r.jsx)(n.code,{children:"fn"}),") => ",(0,r.jsx)(n.code,{children:"object"})]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"event"}),": ",(0,r.jsx)(n.code,{children:'"destroy"'})]}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"fn"})]}),"\n",(0,r.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"object"})}),"\n",(0,r.jsx)(n.h3,{id:"remove",children:"remove()"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"remove"}),": () => ",(0,r.jsx)(n.code,{children:"void"})]}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"returns-1",children:"Returns"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"void"})}),"\n",(0,r.jsx)(n.h2,{id:"defined-in",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L263",children:"models.ts:263"})})]})}function h(e={}){let{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},65:function(e,n,t){t.d(n,{Z:function(){return o},a:function(){return c}});var s=t(7294);let r={},i=s.createContext(r);function c(e){let n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]);

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["4054"],{9827:function(e,n,t){t.r(n),t.d(n,{default:()=>u,frontMatter:()=>s,metadata:()=>r,assets:()=>c,toc:()=>i,contentTitle:()=>d});var r=JSON.parse('{"id":"languages/markdown","title":"Markdown","description":"TODO...","source":"@site/docs/languages/markdown.mdx","sourceDirName":"languages","slug":"/languages/markdown","permalink":"/docs/languages/markdown","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/languages/markdown.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Malina.js","permalink":"/docs/languages/malina"},"next":{"title":"MDX","permalink":"/docs/languages/mdx"}}'),a=t("5893"),o=t("65");let s={},d="Markdown",c={},i=[];function l(e){let n={h1:"h1",header:"header",p:"p",...(0,o.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"markdown",children:"Markdown"})}),"\n",(0,a.jsx)(n.p,{children:"TODO..."})]})}function u(e={}){let{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(l,{...e})}):l(e)}},65:function(e,n,t){t.d(n,{Z:function(){return d},a:function(){return s}});var r=t(7294);let a={},o=r.createContext(a);function s(e){let n=r.useContext(o);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["7801"],{3161:function(e,n,t){t.r(n),t.d(n,{default:()=>d,frontMatter:()=>o,metadata:()=>a,assets:()=>l,toc:()=>c,contentTitle:()=>i});var a=JSON.parse('{"id":"languages/malina","title":"Malina.js","description":"TODO...","source":"@site/docs/languages/malina.mdx","sourceDirName":"languages","slug":"/languages/malina","permalink":"/docs/languages/malina","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/languages/malina.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Lua","permalink":"/docs/languages/lua"},"next":{"title":"Markdown","permalink":"/docs/languages/markdown"}}'),s=t("5893"),r=t("65");let o={},i="Malina.js",l={},c=[];function u(e){let n={h1:"h1",header:"header",p:"p",...(0,r.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"malinajs",children:"Malina.js"})}),"\n",(0,s.jsx)(n.p,{children:"TODO..."})]})}function d(e={}){let{wrapper:n}={...(0,r.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},65:function(e,n,t){t.d(n,{Z:function(){return i},a:function(){return o}});var a=t(7294);let s={},r=a.createContext(s);function o(e){let n=a.useContext(r);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),a.createElement(r.Provider,{value:n},e.children)}}}]);

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["3142"],{4609:function(e,n,s){s.r(n),s.d(n,{default:()=>u,frontMatter:()=>o,metadata:()=>t,assets:()=>l,toc:()=>c,contentTitle:()=>d});var t=JSON.parse('{"id":"api/functions/getPlaygroundUrl","title":"Function: getPlaygroundUrl()","description":"getPlaygroundUrl(options): string","source":"@site/docs/api/functions/getPlaygroundUrl.md","sourceDirName":"api/functions","slug":"/api/functions/getPlaygroundUrl","permalink":"/docs/api/functions/getPlaygroundUrl","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/api/functions/getPlaygroundUrl.md","tags":[],"version":"current","frontMatter":{}}'),r=s("5893"),i=s("65");let o={},d="Function: getPlaygroundUrl()",l={},c=[{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Defined in",id:"defined-in",level:2}];function a(e){let n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,i.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"function-getplaygroundurl",children:"Function: getPlaygroundUrl()"})}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"getPlaygroundUrl"}),"(",(0,r.jsx)(n.code,{children:"options"}),"): ",(0,r.jsx)(n.code,{children:"string"})]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Gets the URL to a LiveCodes playground (as a string) from the provided ",(0,r.jsx)(n.a,{href:"https://livecodes.io/docs/sdk/js-ts#embed-options",children:"options"}),".\nThis can be useful for providing links to run code in playgrounds."]}),"\n",(0,r.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(n.p,{children:["\u2022 ",(0,r.jsx)(n.strong,{children:"options"}),": ",(0,r.jsx)(n.a,{href:"/docs/api/interfaces/EmbedOptions",children:(0,r.jsx)(n.code,{children:"EmbedOptions"})})," = ",(0,r.jsx)(n.code,{children:"{}"})]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.a,{href:"https://livecodes.io/docs/sdk/js-ts#embed-options",children:"options"})," for the playground."]}),"\n",(0,r.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"string"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"The URL of the playground (as a string)."}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"large objects like config and params are store in the url hash params while the rest are in the search params\nunless config is a string in which case it is stored in searchParams"}),"\n",(0,r.jsx)(n.h2,{id:"defined-in",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/index.ts#L391",children:"index.ts:391"})})]})}function u(e={}){let{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},65:function(e,n,s){s.d(n,{Z:function(){return d},a:function(){return o}});var t=s(7294);let r={},i=t.createContext(r);function o(e){let n=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]);

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["2976"],{4544:function(e,n,i){i.r(n),i.d(n,{default:()=>u,frontMatter:()=>s,metadata:()=>t,assets:()=>c,toc:()=>l,contentTitle:()=>d});var t=JSON.parse('{"id":"api/internal/interfaces/EditorPosition","title":"Interface: EditorPosition","description":"Properties","source":"@site/docs/api/internal/interfaces/EditorPosition.md","sourceDirName":"api/internal/interfaces","slug":"/api/internal/interfaces/EditorPosition","permalink":"/docs/api/internal/interfaces/EditorPosition","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/api/internal/interfaces/EditorPosition.md","tags":[],"version":"current","frontMatter":{}}'),r=i("5893"),o=i("65");let s={},d="Interface: EditorPosition",c={},l=[{value:"Properties",id:"properties",level:2},{value:"column?",id:"column",level:3},{value:"Defined in",id:"defined-in",level:4},{value:"lineNumber",id:"linenumber",level:3},{value:"Defined in",id:"defined-in-1",level:4}];function a(e){let n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",hr:"hr",p:"p",strong:"strong",...(0,o.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"interface-editorposition",children:"Interface: EditorPosition"})}),"\n",(0,r.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsx)(n.h3,{id:"column",children:"column?"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"optional"})," ",(0,r.jsx)(n.strong,{children:"column"}),": ",(0,r.jsx)(n.code,{children:"number"})]}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1165",children:"models.ts:1165"})}),"\n",(0,r.jsx)(n.hr,{}),"\n",(0,r.jsx)(n.h3,{id:"linenumber",children:"lineNumber"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"lineNumber"}),": ",(0,r.jsx)(n.code,{children:"number"})]}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"defined-in-1",children:"Defined in"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1164",children:"models.ts:1164"})})]})}function u(e={}){let{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},65:function(e,n,i){i.d(n,{Z:function(){return d},a:function(){return s}});var t=i(7294);let r={},o=t.createContext(r);function s(e){let n=t.useContext(o);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([["8076"],{9661:function(e,t,s){s.r(t),s.d(t,{default:()=>d,frontMatter:()=>c,metadata:()=>n,assets:()=>l,toc:()=>i,contentTitle:()=>a});var n=JSON.parse('{"id":"languages/postcssPresetEnv","title":"Preset Env","description":"TODO...","source":"@site/docs/languages/postcssPresetEnv.mdx","sourceDirName":"languages","slug":"/languages/postcssPresetEnv","permalink":"/docs/languages/postcssPresetEnv","draft":false,"unlisted":false,"editUrl":"https://github.com/live-codes/livecodes/tree/develop/docs/docs/languages/postcssPresetEnv.mdx","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"Import Url","permalink":"/docs/languages/postcssImportUrl"},"next":{"title":"PostgreSQL","permalink":"/docs/languages/postgresql"}}'),r=s("5893"),o=s("65");let c={},a="Preset Env",l={},i=[];function u(e){let t={h1:"h1",header:"header",p:"p",...(0,o.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"preset-env",children:"Preset Env"})}),"\n",(0,r.jsx)(t.p,{children:"TODO..."})]})}function d(e={}){let{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(u,{...e})}):u(e)}},65:function(e,t,s){s.d(t,{Z:function(){return a},a:function(){return c}});var n=s(7294);let r={},o=n.createContext(r);function c(e){let t=n.useContext(o);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More