打包好的livecode,版本v-46
This commit is contained in:
commit
1214258379
1
404.html
Normal file
1
404.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>404</title><link rel="alternate" type="application/json+oembed" href="/oembed?url=https%3A%2F%2Flivecodes.io&format=json" title="LiveCodes oEmbed"><link rel="apple-touch-icon" sizes="180x180" href="/livecodes/assets/images/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/livecodes/assets/images/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/livecodes/assets/images/favicon-16x16.png"><link rel="icon" type="image/x-icon" href="favicon.ico"><link rel="manifest" href="/livecodes/assets/site.webmanifest"><link rel="mask-icon" href="/livecodes/assets/images/safari-pinned-tab.svg" color="#5bbad5"><meta name="apple-mobile-web-app-title" content="livecodes"><meta name="application-name" content="livecodes"><meta name="msapplication-TileColor" content="#da532c"><meta name="msapplication-config" content="/livecodes/assets/browserconfig.xml"><meta name="theme-color" content="#ffffff"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet"><style>body,html{margin:0;padding:0;width:100vw;overflow-x:hidden}body{font-family:system-ui,'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;background-color:#f5f5f5}#header{display:flex;flex-direction:row;justify-content:space-between}#logo{margin:1em}#text{margin-left:2em}.news>span{font-family:Pacifico,'Brush Script MT',cursive;font-size:2em}.news>p{margin-left:2em}#frame-container{text-align:right;padding:1em;width:calc(100vw - 3em)}iframe{border:1px solid #000;border-radius:8px;box-shadow:0 0 20px #a4a6a8;height:50vh;min-height:350px;width:calc(100% - 2em);margin-top:1em;z-index:10}#img404{position:absolute;top:30px;right:30px;width:30%;min-width:100px;max-width:300px;z-index:1}#footer{margin:0;margin-top:2em;padding:1em;padding-bottom:2em;background-color:#303846;color:#f5f5f5;width:100vw;overflow:hidden}#footer .title{font-weight:700;margin:1em}#footer a{color:#f5f5f5;text-decoration:none;margin:1em}</style></head><body><div id="header"><div><a href="/" title="LiveCodes App"><img src="/livecodes/assets/images/livecodes-logo.svg" alt="LiveCodes logo" id="logo" width="80"></a></div></div><div id="text"><div class="news"><span>The bad news</span><p>The page you requested is not found!</p></div><div class="news"><span>The good news</span><p>You can have some fun with this interactive playground 🎉</p></div></div><div id="frame-container"><iframe src="/?embed&template=react" title="LiveCodes Playground"></iframe></div><img id="img404" src="/livecodes/assets/images/404.png" alt="LiveCodes with 404 stamp"><div id="footer"><div class="title">LiveCodes</div><div class="links"><a href="/docs">Home</a> <a href="/">App</a> <a href="/docs/overview">Docs</a> <a href="https://github.com/live-codes/livecodes">GitHub</a></div></div><script></script></body></html>
|
||||||
1
app.html
Normal file
1
app.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="codeium:type" content="monaco"><title>LiveCodes</title><script>const params=new URLSearchParams(location.search),disableAI=null!=params.get("disableAI")&&"false"!==params.get("disableAI");disableAI&&document.querySelector('meta[name="codeium:type"]')?.setAttribute("content","none"),window.addEventListener("message",(function(e){e.origin===window.location.origin&&e.source===parent&&e.data.content&&(document.write(e.data.content),document.close())}))</script></head><body></body></html>
|
||||||
0
docs/.nojekyll
Normal file
0
docs/.nojekyll
Normal file
3
docs/404.html
Normal file
3
docs/404.html
Normal file
File diff suppressed because one or more lines are too long
11
docs/about.html.md
Normal file
11
docs/about.html.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# About us
|
||||||
|
|
||||||
|
LiveCodes is built and maintained by [Hatem Hosny](https://github.com/hatemhosny), and wonderful [contributors](https://github.com/live-codes/livecodes/graphs/contributors).
|
||||||
|
|
||||||
|
Feature requests and bug reports are received on the [GitHub repo](https://github.com/live-codes/livecodes/issues).
|
||||||
|
|
||||||
|
Contributions are most welcome. Please open an issue on the GitHub repo to discuss your potential contribution before submitting a pull request.
|
||||||
|
|
||||||
|
Reach out to us using this [contact form](./contact.html.md).
|
||||||
|
|
||||||
|
Please consider [sponsoring LiveCodes](./sponsor.html.md) to support its maintenance and continued development.
|
||||||
16
docs/about/index.html
Normal file
16
docs/about/index.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/advanced/custom-settings.html.md
Normal file
1
docs/advanced/custom-settings.html.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Custom Settings
|
||||||
11
docs/advanced/custom-settings/index.html
Normal file
11
docs/advanced/custom-settings/index.html
Normal file
File diff suppressed because one or more lines are too long
13
docs/advanced/index.html
Normal file
13
docs/advanced/index.html
Normal file
File diff suppressed because one or more lines are too long
8
docs/advanced/index.html.md
Normal file
8
docs/advanced/index.html.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Advanced Topics {#advanced-topics-custom-content-top}
|
||||||
|
|
||||||
|
```mdx-code-block
|
||||||
|
import DocCardList from '@theme/DocCardList';
|
||||||
|
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
|
<DocCardList items={useCurrentSidebarCategory().items.filter(item => item.docId !== 'languages/index')}/>
|
||||||
|
```
|
||||||
30
docs/advanced/services.html.md
Normal file
30
docs/advanced/services.html.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Services
|
||||||
|
|
||||||
|
LiveCodes (being a client-side app) uses multiple services (for example for authentication, sharing, module resolution, etc).
|
||||||
|
|
||||||
|
These services are [defined here](https://github.com/live-codes/livecodes/tree/develop/src/livecodes/services).
|
||||||
|
|
||||||
|
Some of the services are not supported on [self-hosted](../features/self-hosting.html.md) deploys and are either replaced by other compatible services or require you to provide an alternative service.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- The [share](../features/share.html.md) service in [self-hosted](../features/self-hosting.html.md) apps uses [dpaste](https://dpaste.com/) for short URLs, which are [**deleted after 365 days**](https://dpaste.com/help).
|
||||||
|
- [Firebase configuration](https://github.com/live-codes/livecodes/tree/develop/src/livecodes/services/firebase.ts) for authentication.
|
||||||
|
|
||||||
|
:::info
|
||||||
|
|
||||||
|
LiveCodes [sponsors](../sponsor.html.md) (Bronze sponsors and above) get access to managed custom services.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
If you [self-host](../features/self-hosting.html.md) your app and need to change any of these services, start by following the [guide described there](../features/self-hosting.html.md).
|
||||||
|
|
||||||
|
Then, edit the services you want (in [`src/livecodes/services`](https://github.com/live-codes/livecodes/tree/develop/src/livecodes/services)). The used services need to have the same interface.
|
||||||
|
|
||||||
|
The app then needs to be re-built using the command:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
The built app is in `build` directory. This can be hosted on any static file server.
|
||||||
25
docs/advanced/services/index.html
Normal file
25
docs/advanced/services/index.html
Normal file
File diff suppressed because one or more lines are too long
44
docs/api/functions/createPlayground.html.md
Normal file
44
docs/api/functions/createPlayground.html.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Function: createPlayground()
|
||||||
|
|
||||||
|
## createPlayground(container, options)
|
||||||
|
|
||||||
|
> **createPlayground**(`container`, `options`?): `Promise`\<[`Playground`](../interfaces/Playground.md)\>
|
||||||
|
|
||||||
|
Creates a LiveCodes playground.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
• **container**: `string` \| `HTMLElement`
|
||||||
|
|
||||||
|
`HTMLElement` or a string representing a CSS selector. This is the container where the playground is rendered.
|
||||||
|
If not found, an error is thrown (except in [headless mode](https://livecodes.io/docs/sdk/headless), in which this parameter is optional and can be omitted).
|
||||||
|
|
||||||
|
• **options?**: [`EmbedOptions`](../interfaces/EmbedOptions.md)
|
||||||
|
|
||||||
|
The [embed options](https://livecodes.io/docs/sdk/js-ts#embed-options) for the playground (optional).
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Playground`](../interfaces/Playground.md)\>
|
||||||
|
|
||||||
|
- A promise that resolves to a [`Playground`](https://livecodes.io/docs/api/interfaces/Playground/) object which exposes many [SDK methods](https://livecodes.io/docs/sdk/js-ts/#sdk-methods) that can be used to interact with the playground.
|
||||||
|
|
||||||
|
### Defined in
|
||||||
|
|
||||||
|
[index.ts:26](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/index.ts#L26)
|
||||||
|
|
||||||
|
## createPlayground(options)
|
||||||
|
|
||||||
|
> **createPlayground**(`options`): `Promise`\<[`Playground`](../interfaces/Playground.md)\>
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
• **options**: [`EmbedOptions`](../interfaces/EmbedOptions.md) & `object`
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Playground`](../interfaces/Playground.md)\>
|
||||||
|
|
||||||
|
### Defined in
|
||||||
|
|
||||||
|
[index.ts:30](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/index.ts#L30)
|
||||||
39
docs/api/functions/createPlayground/index.html
Normal file
39
docs/api/functions/createPlayground/index.html
Normal file
File diff suppressed because one or more lines are too long
25
docs/api/functions/getPlaygroundUrl.html.md
Normal file
25
docs/api/functions/getPlaygroundUrl.html.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Function: getPlaygroundUrl()
|
||||||
|
|
||||||
|
> **getPlaygroundUrl**(`options`): `string`
|
||||||
|
|
||||||
|
Gets the URL to a LiveCodes playground (as a string) from the provided [options](https://livecodes.io/docs/sdk/js-ts#embed-options).
|
||||||
|
This can be useful for providing links to run code in playgrounds.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **options**: [`EmbedOptions`](../interfaces/EmbedOptions.md) = `{}`
|
||||||
|
|
||||||
|
The [options](https://livecodes.io/docs/sdk/js-ts#embed-options) for the playground.
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`string`
|
||||||
|
|
||||||
|
- The URL of the playground (as a string).
|
||||||
|
|
||||||
|
large objects like config and params are store in the url hash params while the rest are in the search params
|
||||||
|
unless config is a string in which case it is stored in searchParams
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[index.ts:391](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/index.ts#L391)
|
||||||
28
docs/api/functions/getPlaygroundUrl/index.html
Normal file
28
docs/api/functions/getPlaygroundUrl/index.html
Normal file
File diff suppressed because one or more lines are too long
31
docs/api/globals/index.html
Normal file
31
docs/api/globals/index.html
Normal file
File diff suppressed because one or more lines are too long
167
docs/api/index.html
Normal file
167
docs/api/index.html
Normal file
File diff suppressed because one or more lines are too long
82
docs/api/interfaces/Code.html.md
Normal file
82
docs/api/interfaces/Code.html.md
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# Interface: Code
|
||||||
|
|
||||||
|
An object that contains the language, content and compiled code for each of the 3 [code editors](https://livecodes.io/docs/features/projects)
|
||||||
|
and the [result page](https://livecodes.io/docs/features/result) HTML.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/api/interfaces/Code) for details.
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### markup
|
||||||
|
|
||||||
|
> **markup**: `object`
|
||||||
|
|
||||||
|
#### compiled
|
||||||
|
|
||||||
|
> **compiled**: `string`
|
||||||
|
|
||||||
|
#### content
|
||||||
|
|
||||||
|
> **content**: `string`
|
||||||
|
|
||||||
|
#### language
|
||||||
|
|
||||||
|
> **language**: [`Language`](../type-aliases/Language.md)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1908](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1908)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### result
|
||||||
|
|
||||||
|
> **result**: `string`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1923](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1923)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### script
|
||||||
|
|
||||||
|
> **script**: `object`
|
||||||
|
|
||||||
|
#### compiled
|
||||||
|
|
||||||
|
> **compiled**: `string`
|
||||||
|
|
||||||
|
#### content
|
||||||
|
|
||||||
|
> **content**: `string`
|
||||||
|
|
||||||
|
#### language
|
||||||
|
|
||||||
|
> **language**: [`Language`](../type-aliases/Language.md)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1918](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1918)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### style
|
||||||
|
|
||||||
|
> **style**: `object`
|
||||||
|
|
||||||
|
#### compiled
|
||||||
|
|
||||||
|
> **compiled**: `string`
|
||||||
|
|
||||||
|
#### content
|
||||||
|
|
||||||
|
> **content**: `string`
|
||||||
|
|
||||||
|
#### language
|
||||||
|
|
||||||
|
> **language**: [`Language`](../type-aliases/Language.md)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1913](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1913)
|
||||||
78
docs/api/interfaces/Code/index.html
Normal file
78
docs/api/interfaces/Code/index.html
Normal file
File diff suppressed because one or more lines are too long
2420
docs/api/interfaces/Config.html.md
Normal file
2420
docs/api/interfaces/Config.html.md
Normal file
File diff suppressed because it is too large
Load Diff
1788
docs/api/interfaces/Config/index.html
Normal file
1788
docs/api/interfaces/Config/index.html
Normal file
File diff suppressed because one or more lines are too long
3807
docs/api/interfaces/EmbedOptions.html.md
Normal file
3807
docs/api/interfaces/EmbedOptions.html.md
Normal file
File diff suppressed because one or more lines are too long
3336
docs/api/interfaces/EmbedOptions/index.html
Normal file
3336
docs/api/interfaces/EmbedOptions/index.html
Normal file
File diff suppressed because one or more lines are too long
492
docs/api/interfaces/Playground.html.md
Normal file
492
docs/api/interfaces/Playground.html.md
Normal file
@ -0,0 +1,492 @@
|
|||||||
|
# Interface: Playground
|
||||||
|
|
||||||
|
An object that represents the LiveCodes playground instance.
|
||||||
|
|
||||||
|
The object exposes multiple [methods](https://livecodes.io/docs/sdk/js-ts/#sdk-methods) that can be used to interact with the playground.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts) for details.
|
||||||
|
|
||||||
|
## Extends
|
||||||
|
|
||||||
|
- [`API`](../internal/interfaces/API.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### destroy()
|
||||||
|
|
||||||
|
> **destroy**: () => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Destroys the playground instance, and removes event listeners.
|
||||||
|
|
||||||
|
Further call to any SDK methods throws an error.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.destroy();
|
||||||
|
// playground destroyed
|
||||||
|
// any further SDK call throws an error
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`destroy`](../internal/interfaces/API.md#destroy)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:211](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L211)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### exec()
|
||||||
|
|
||||||
|
> **exec**: (`command`, ...`args`) => `Promise`\<`object` \| `object`\>
|
||||||
|
|
||||||
|
Executes custom commands, including: `"setBroadcastToken"` and `"showVersion"`.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#exec) for details.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **command**: [`APICommands`](../internal/type-aliases/APICommands.md)
|
||||||
|
|
||||||
|
• ...**args**: `any`[]
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`object` \| `object`\>
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`exec`](../internal/interfaces/API.md#exec)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:194](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L194)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### format()
|
||||||
|
|
||||||
|
> **format**: (`allEditors`?) => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Formats the code.
|
||||||
|
|
||||||
|
By default, the code in all editors (markup, style and script) is formatted.
|
||||||
|
To format only the active editor, the value `false` should be passed as an argument.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **allEditors?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.format();
|
||||||
|
// code in editors is formatted
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`format`](../internal/interfaces/API.md#format)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:31](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L31)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getCode()
|
||||||
|
|
||||||
|
> **getCode**: () => `Promise`\<[`Code`](Code.md)\>
|
||||||
|
|
||||||
|
Gets the playground code (including source code, source language and compiled code) for each editor (markup, style, script), in addition to result page HTML.
|
||||||
|
|
||||||
|
See [Code](https://livecodes.io/docs/api/interfaces/Code) for the structure of the returned object.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Code`](Code.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const code = await playground.getCode();
|
||||||
|
|
||||||
|
// source code, language and compiled code for the script editor
|
||||||
|
const { content, language, compiled } = code.script;
|
||||||
|
|
||||||
|
// result page HTML
|
||||||
|
const result = code.result;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`getCode`](../internal/interfaces/API.md#getcode)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:105](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L105)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getConfig()
|
||||||
|
|
||||||
|
> **getConfig**: (`contentOnly`?) => `Promise`\<[`Config`](Config.md)\>
|
||||||
|
|
||||||
|
Gets a [configuration object](https://livecodes.io/docs/configuration/configuration-object) representing the playground state.
|
||||||
|
|
||||||
|
This can be used to restore state if passed as an [EmbedOptions](https://livecodes.io/docs/sdk/js-ts#embed-options) property when [creating playgrounds](https://livecodes.io/docs/sdk/js-ts/#createplayground),
|
||||||
|
or can be manipulated and loaded in run-time using [`setConfig`](https://livecodes.io/docs/sdk/js-ts#setconfig) method.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **contentOnly?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Config`](Config.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const config = await playground.getConfig();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`getConfig`](../internal/interfaces/API.md#getconfig)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:64](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L64)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getShareUrl()
|
||||||
|
|
||||||
|
> **getShareUrl**: (`shortUrl`?) => `Promise`\<`string`\>
|
||||||
|
|
||||||
|
Gets a [share url](https://livecodes.io/docs/features/share) for the current project.
|
||||||
|
|
||||||
|
By default, the url has a long query string representing the compressed encoded config object.
|
||||||
|
If the argument `shortUrl` was set to `true`, a short url is generated.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **shortUrl?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`string`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const longUrl = await playground.getShareUrl();
|
||||||
|
const shortUrl = await playground.getShareUrl(true);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`getShareUrl`](../internal/interfaces/API.md#getshareurl)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:48](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L48)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### load()
|
||||||
|
|
||||||
|
> **load**: () => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Loads the playground, if not already loaded.
|
||||||
|
|
||||||
|
When the embed option [loading](https://livecodes.io/docs/sdk/js-ts#loading) is set to `"click"`, the playground is not loaded automatically.
|
||||||
|
Instead, a screen is shown with "Click to load" button. Calling the SDK method `load()` allows loading the playground.
|
||||||
|
|
||||||
|
If the playground was not loaded, calling any other method will load the playground first before executing.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:298](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L298)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### ~~onChange()~~
|
||||||
|
|
||||||
|
> **onChange**: (`fn`) => `object`
|
||||||
|
|
||||||
|
Runs a callback function when code changes.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
##### ~~remove()~~
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
###### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
#### Deprecated
|
||||||
|
|
||||||
|
Use [`watch`](https://livecodes.io/docs/sdk/js-ts#watch) method instead.
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`onChange`](../internal/interfaces/API.md#onchange)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:142](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L142)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### run()
|
||||||
|
|
||||||
|
> **run**: () => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Runs the [result page](https://livecodes.io/docs/features/result) (after any required compilation for code).
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.run();
|
||||||
|
// new result page is displayed
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`run`](../internal/interfaces/API.md#run)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:14](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L14)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### runTests()
|
||||||
|
|
||||||
|
> **runTests**: () => `Promise`\<`object`\>
|
||||||
|
|
||||||
|
Runs project [tests](https://livecodes.io/docs/features/tests) (if present) and gets test results.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`object`\>
|
||||||
|
|
||||||
|
##### results
|
||||||
|
|
||||||
|
> **results**: [`TestResult`](../internal/interfaces/TestResult.md)[]
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const { results } = await playground.runTests();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`runTests`](../internal/interfaces/API.md#runtests)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:135](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L135)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### setConfig()
|
||||||
|
|
||||||
|
> **setConfig**: (`config`) => `Promise`\<[`Config`](Config.md)\>
|
||||||
|
|
||||||
|
Loads a new project using the passed configuration object.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **config**: `Partial`\<[`Config`](Config.md)\>
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Config`](Config.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const config = {
|
||||||
|
markup: {
|
||||||
|
language: "html",
|
||||||
|
content: "Hello World!",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const newConfig = await playground.setConfig(config);
|
||||||
|
// new project loaded
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`setConfig`](../internal/interfaces/API.md#setconfig)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:84](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L84)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### show()
|
||||||
|
|
||||||
|
> **show**: (`panel`, `options`?) => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Shows the selected panel.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#show) for details.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **panel**: `"result"` \| [`EditorId`](../internal/type-aliases/EditorId.md) \| `"console"` \| `"compiled"` \| `"tests"` \| `"editor"` \| `"toggle-result"`
|
||||||
|
|
||||||
|
• **options?**
|
||||||
|
|
||||||
|
• **options.column?**: `number`
|
||||||
|
|
||||||
|
• **options.full?**: `boolean`
|
||||||
|
|
||||||
|
• **options.line?**: `number`
|
||||||
|
|
||||||
|
• **options.zoom?**: `1` \| `0.5` \| `0.25`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await playground.show("style");
|
||||||
|
await playground.show("toggle-result");
|
||||||
|
await playground.show("result", { full: true });
|
||||||
|
await playground.show("script");
|
||||||
|
await playground.show("result", { zoom: 0.5 });
|
||||||
|
await playground.show("console", { full: true });
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`show`](../internal/interfaces/API.md#show)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:119](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L119)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### watch
|
||||||
|
|
||||||
|
> **watch**: [`WatchLoad`](../internal/type-aliases/WatchLoad.md) & [`WatchReady`](../internal/type-aliases/WatchReady.md) & [`WatchCode`](../internal/type-aliases/WatchCode.md) & [`WatchConsole`](../internal/type-aliases/WatchConsole.md) & [`WatchTests`](../internal/type-aliases/WatchTests.md) & [`WatchDestroy`](../internal/type-aliases/WatchDestroy.md)
|
||||||
|
|
||||||
|
Allows to watch for various playground events.
|
||||||
|
It takes 2 arguments: event name and a callback function that will be called on every event.
|
||||||
|
|
||||||
|
event name can be one of: `"load" | "ready" | "code" | "console" | "tests" | "destroy"`
|
||||||
|
|
||||||
|
In some events, the callback function will be called with an object that supplies relevant data to the callback function (e.g. code, console output, test results).
|
||||||
|
|
||||||
|
The watch method returns an object with a single method (`remove`), which when called will remove the callback from watching further events.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#watch) for details.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then((playground) => {
|
||||||
|
const codeWatcher = playground.watch("code", ({ code, config }) => {
|
||||||
|
// this will run on every code change
|
||||||
|
console.log("code:", code);
|
||||||
|
console.log("config:", config);
|
||||||
|
});
|
||||||
|
|
||||||
|
const consoleWatcher = playground.watch("console", ({ method, args }) => {
|
||||||
|
// this will run on every console output
|
||||||
|
console[method](...args);
|
||||||
|
});
|
||||||
|
|
||||||
|
const testsWatcher = playground.watch("tests", ({ results }) => {
|
||||||
|
// this will run when tests run
|
||||||
|
results.forEach((testResult) => {
|
||||||
|
console.log("status:", testResult.status); // "pass", "fail" or "skip"
|
||||||
|
console.log(testResult.errors); // array of errors as strings
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// then later
|
||||||
|
codeWatcher.remove();
|
||||||
|
consoleWatcher.remove();
|
||||||
|
testsWatcher.remove();
|
||||||
|
// events are no longer watched
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`API`](../internal/interfaces/API.md).[`watch`](../internal/interfaces/API.md#watch)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:187](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L187)
|
||||||
240
docs/api/interfaces/Playground/index.html
Normal file
240
docs/api/interfaces/Playground/index.html
Normal file
File diff suppressed because one or more lines are too long
46
docs/api/internal/index.html
Normal file
46
docs/api/internal/index.html
Normal file
File diff suppressed because one or more lines are too long
37
docs/api/internal/index.html.md
Normal file
37
docs/api/internal/index.html.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# \_internal
|
||||||
|
|
||||||
|
## Index
|
||||||
|
|
||||||
|
### Interfaces
|
||||||
|
|
||||||
|
- [API](interfaces/API.md)
|
||||||
|
- [AppConfig](interfaces/AppConfig.md)
|
||||||
|
- [ContentConfig](interfaces/ContentConfig.md)
|
||||||
|
- [EditorConfig](interfaces/EditorConfig.md)
|
||||||
|
- [EditorPosition](interfaces/EditorPosition.md)
|
||||||
|
- [FormatterConfig](interfaces/FormatterConfig.md)
|
||||||
|
- [TestResult](interfaces/TestResult.md)
|
||||||
|
- [Types](interfaces/Types.md)
|
||||||
|
- [UserConfig](interfaces/UserConfig.md)
|
||||||
|
|
||||||
|
### Type Aliases
|
||||||
|
|
||||||
|
- [APICommands](type-aliases/APICommands.md)
|
||||||
|
- [AppLanguage](type-aliases/AppLanguage.md)
|
||||||
|
- [CDN](type-aliases/CDN.md)
|
||||||
|
- [CodejarTheme](type-aliases/CodejarTheme.md)
|
||||||
|
- [CodemirrorTheme](type-aliases/CodemirrorTheme.md)
|
||||||
|
- [CssPresetId](type-aliases/CssPresetId.md)
|
||||||
|
- [EditorId](type-aliases/EditorId.md)
|
||||||
|
- [EditorTheme](type-aliases/EditorTheme.md)
|
||||||
|
- [MonacoTheme](type-aliases/MonacoTheme.md)
|
||||||
|
- [Processor](type-aliases/Processor.md)
|
||||||
|
- [TemplateName](type-aliases/TemplateName.md)
|
||||||
|
- [Theme](type-aliases/Theme.md)
|
||||||
|
- [ToolsPaneStatus](type-aliases/ToolsPaneStatus.md)
|
||||||
|
- [WatchCode](type-aliases/WatchCode.md)
|
||||||
|
- [WatchConsole](type-aliases/WatchConsole.md)
|
||||||
|
- [WatchDestroy](type-aliases/WatchDestroy.md)
|
||||||
|
- [WatchLoad](type-aliases/WatchLoad.md)
|
||||||
|
- [WatchReady](type-aliases/WatchReady.md)
|
||||||
|
- [WatchTests](type-aliases/WatchTests.md)
|
||||||
417
docs/api/internal/interfaces/API.html.md
Normal file
417
docs/api/internal/interfaces/API.html.md
Normal file
@ -0,0 +1,417 @@
|
|||||||
|
# Interface: API
|
||||||
|
|
||||||
|
## Extended by
|
||||||
|
|
||||||
|
- [`Playground`](../../interfaces/Playground.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### destroy()
|
||||||
|
|
||||||
|
> **destroy**: () => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Destroys the playground instance, and removes event listeners.
|
||||||
|
|
||||||
|
Further call to any SDK methods throws an error.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.destroy();
|
||||||
|
// playground destroyed
|
||||||
|
// any further SDK call throws an error
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:211](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L211)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### exec()
|
||||||
|
|
||||||
|
> **exec**: (`command`, ...`args`) => `Promise`\<`object` \| `object`\>
|
||||||
|
|
||||||
|
Executes custom commands, including: `"setBroadcastToken"` and `"showVersion"`.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#exec) for details.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **command**: [`APICommands`](../type-aliases/APICommands.md)
|
||||||
|
|
||||||
|
• ...**args**: `any`[]
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`object` \| `object`\>
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:194](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L194)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### format()
|
||||||
|
|
||||||
|
> **format**: (`allEditors`?) => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Formats the code.
|
||||||
|
|
||||||
|
By default, the code in all editors (markup, style and script) is formatted.
|
||||||
|
To format only the active editor, the value `false` should be passed as an argument.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **allEditors?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.format();
|
||||||
|
// code in editors is formatted
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:31](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L31)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getCode()
|
||||||
|
|
||||||
|
> **getCode**: () => `Promise`\<[`Code`](../../interfaces/Code.md)\>
|
||||||
|
|
||||||
|
Gets the playground code (including source code, source language and compiled code) for each editor (markup, style, script), in addition to result page HTML.
|
||||||
|
|
||||||
|
See [Code](https://livecodes.io/docs/api/interfaces/Code) for the structure of the returned object.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Code`](../../interfaces/Code.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const code = await playground.getCode();
|
||||||
|
|
||||||
|
// source code, language and compiled code for the script editor
|
||||||
|
const { content, language, compiled } = code.script;
|
||||||
|
|
||||||
|
// result page HTML
|
||||||
|
const result = code.result;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:105](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L105)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getConfig()
|
||||||
|
|
||||||
|
> **getConfig**: (`contentOnly`?) => `Promise`\<[`Config`](../../interfaces/Config.md)\>
|
||||||
|
|
||||||
|
Gets a [configuration object](https://livecodes.io/docs/configuration/configuration-object) representing the playground state.
|
||||||
|
|
||||||
|
This can be used to restore state if passed as an [EmbedOptions](https://livecodes.io/docs/sdk/js-ts#embed-options) property when [creating playgrounds](https://livecodes.io/docs/sdk/js-ts/#createplayground),
|
||||||
|
or can be manipulated and loaded in run-time using [`setConfig`](https://livecodes.io/docs/sdk/js-ts#setconfig) method.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **contentOnly?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Config`](../../interfaces/Config.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const config = await playground.getConfig();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:64](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L64)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### getShareUrl()
|
||||||
|
|
||||||
|
> **getShareUrl**: (`shortUrl`?) => `Promise`\<`string`\>
|
||||||
|
|
||||||
|
Gets a [share url](https://livecodes.io/docs/features/share) for the current project.
|
||||||
|
|
||||||
|
By default, the url has a long query string representing the compressed encoded config object.
|
||||||
|
If the argument `shortUrl` was set to `true`, a short url is generated.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **shortUrl?**: `boolean`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`string`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const longUrl = await playground.getShareUrl();
|
||||||
|
const shortUrl = await playground.getShareUrl(true);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:48](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L48)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### ~~onChange()~~
|
||||||
|
|
||||||
|
> **onChange**: (`fn`) => `object`
|
||||||
|
|
||||||
|
Runs a callback function when code changes.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
##### ~~remove()~~
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
###### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
#### Deprecated
|
||||||
|
|
||||||
|
Use [`watch`](https://livecodes.io/docs/sdk/js-ts#watch) method instead.
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:142](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L142)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### run()
|
||||||
|
|
||||||
|
> **run**: () => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Runs the [result page](https://livecodes.io/docs/features/result) (after any required compilation for code).
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
await playground.run();
|
||||||
|
// new result page is displayed
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:14](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L14)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### runTests()
|
||||||
|
|
||||||
|
> **runTests**: () => `Promise`\<`object`\>
|
||||||
|
|
||||||
|
Runs project [tests](https://livecodes.io/docs/features/tests) (if present) and gets test results.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`object`\>
|
||||||
|
|
||||||
|
##### results
|
||||||
|
|
||||||
|
> **results**: [`TestResult`](TestResult.md)[]
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const { results } = await playground.runTests();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:135](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L135)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### setConfig()
|
||||||
|
|
||||||
|
> **setConfig**: (`config`) => `Promise`\<[`Config`](../../interfaces/Config.md)\>
|
||||||
|
|
||||||
|
Loads a new project using the passed configuration object.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **config**: `Partial`\<[`Config`](../../interfaces/Config.md)\>
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<[`Config`](../../interfaces/Config.md)\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then(async (playground) => {
|
||||||
|
const config = {
|
||||||
|
markup: {
|
||||||
|
language: "html",
|
||||||
|
content: "Hello World!",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const newConfig = await playground.setConfig(config);
|
||||||
|
// new project loaded
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:84](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L84)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### show()
|
||||||
|
|
||||||
|
> **show**: (`panel`, `options`?) => `Promise`\<`void`\>
|
||||||
|
|
||||||
|
Shows the selected panel.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#show) for details.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
• **panel**: `"result"` \| [`EditorId`](../type-aliases/EditorId.md) \| `"console"` \| `"compiled"` \| `"tests"` \| `"editor"` \| `"toggle-result"`
|
||||||
|
|
||||||
|
• **options?**
|
||||||
|
|
||||||
|
• **options.column?**: `number`
|
||||||
|
|
||||||
|
• **options.full?**: `boolean`
|
||||||
|
|
||||||
|
• **options.line?**: `number`
|
||||||
|
|
||||||
|
• **options.zoom?**: `1` \| `0.5` \| `0.25`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`Promise`\<`void`\>
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await playground.show("style");
|
||||||
|
await playground.show("toggle-result");
|
||||||
|
await playground.show("result", { full: true });
|
||||||
|
await playground.show("script");
|
||||||
|
await playground.show("result", { zoom: 0.5 });
|
||||||
|
await playground.show("console", { full: true });
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:119](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L119)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### watch
|
||||||
|
|
||||||
|
> **watch**: [`WatchLoad`](../type-aliases/WatchLoad.md) & [`WatchReady`](../type-aliases/WatchReady.md) & [`WatchCode`](../type-aliases/WatchCode.md) & [`WatchConsole`](../type-aliases/WatchConsole.md) & [`WatchTests`](../type-aliases/WatchTests.md) & [`WatchDestroy`](../type-aliases/WatchDestroy.md)
|
||||||
|
|
||||||
|
Allows to watch for various playground events.
|
||||||
|
It takes 2 arguments: event name and a callback function that will be called on every event.
|
||||||
|
|
||||||
|
event name can be one of: `"load" | "ready" | "code" | "console" | "tests" | "destroy"`
|
||||||
|
|
||||||
|
In some events, the callback function will be called with an object that supplies relevant data to the callback function (e.g. code, console output, test results).
|
||||||
|
|
||||||
|
The watch method returns an object with a single method (`remove`), which when called will remove the callback from watching further events.
|
||||||
|
|
||||||
|
See [docs](https://livecodes.io/docs/sdk/js-ts#watch) for details.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { createPlayground } from "livecodes";
|
||||||
|
|
||||||
|
createPlayground("#container").then((playground) => {
|
||||||
|
const codeWatcher = playground.watch("code", ({ code, config }) => {
|
||||||
|
// this will run on every code change
|
||||||
|
console.log("code:", code);
|
||||||
|
console.log("config:", config);
|
||||||
|
});
|
||||||
|
|
||||||
|
const consoleWatcher = playground.watch("console", ({ method, args }) => {
|
||||||
|
// this will run on every console output
|
||||||
|
console[method](...args);
|
||||||
|
});
|
||||||
|
|
||||||
|
const testsWatcher = playground.watch("tests", ({ results }) => {
|
||||||
|
// this will run when tests run
|
||||||
|
results.forEach((testResult) => {
|
||||||
|
console.log("status:", testResult.status); // "pass", "fail" or "skip"
|
||||||
|
console.log(testResult.errors); // array of errors as strings
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// then later
|
||||||
|
codeWatcher.remove();
|
||||||
|
consoleWatcher.remove();
|
||||||
|
testsWatcher.remove();
|
||||||
|
// events are no longer watched
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:187](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L187)
|
||||||
200
docs/api/internal/interfaces/API/index.html
Normal file
200
docs/api/internal/interfaces/API/index.html
Normal file
File diff suppressed because one or more lines are too long
138
docs/api/internal/interfaces/AppConfig.html.md
Normal file
138
docs/api/internal/interfaces/AppConfig.html.md
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
# Interface: AppConfig
|
||||||
|
|
||||||
|
These are properties that define how the app behaves.
|
||||||
|
|
||||||
|
## Extended by
|
||||||
|
|
||||||
|
- [`Config`](../../interfaces/Config.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### allowLangChange
|
||||||
|
|
||||||
|
> **allowLangChange**: `boolean`
|
||||||
|
|
||||||
|
If `false`, the UI will not show the menu that allows changing editor language.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:603](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L603)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### mode
|
||||||
|
|
||||||
|
> **mode**: `"focus"` \| `"full"` \| `"result"` \| `"editor"` \| `"lite"` \| `"simple"` \| `"codeblock"`
|
||||||
|
|
||||||
|
Sets the [display mode](https://livecodes.io/docs/features/display-modes).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"full"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:615](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L615)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### readonly
|
||||||
|
|
||||||
|
> **readonly**: `boolean`
|
||||||
|
|
||||||
|
If `true`, editors are loaded in read-only mode, where the user is not allowed to change the code.
|
||||||
|
|
||||||
|
By default, when readonly is set to true, the light-weight code editor [CodeJar](https://livecodes.io/docs/features/editor-settings#code-editor) is used.
|
||||||
|
If you wish to use another editor, set the [editor](https://livecodes.io/docs/configuration/configuration-object#editor) property.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:597](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L597)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### tools
|
||||||
|
|
||||||
|
> **tools**: `Partial`\<`object`\>
|
||||||
|
|
||||||
|
Sets enabled and active tools and status of [tools pane](https://livecodes.io/docs/features/tools-pane).
|
||||||
|
|
||||||
|
#### Type declaration
|
||||||
|
|
||||||
|
##### active
|
||||||
|
|
||||||
|
> **active**: `""` \| `"console"` \| `"compiled"` \| `"tests"`
|
||||||
|
|
||||||
|
##### enabled
|
||||||
|
|
||||||
|
> **enabled**: `"all"` \| (`"console"` \| `"compiled"` \| `"tests"`)[]
|
||||||
|
|
||||||
|
##### status
|
||||||
|
|
||||||
|
> **status**: [`ToolsPaneStatus`](../type-aliases/ToolsPaneStatus.md)
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
{ enabled: "all", active: "", status: "" }
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"tools": {
|
||||||
|
"enabled": ["console", "compiled"],
|
||||||
|
"active": "console",
|
||||||
|
"status": "open"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:631](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L631)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### view?
|
||||||
|
|
||||||
|
> `optional` **view**: `"split"` \| `"result"` \| `"editor"`
|
||||||
|
|
||||||
|
Sets the [default view](https://livecodes.io/docs/features/default-view) for the playground.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"split"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:609](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L609)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### zoom
|
||||||
|
|
||||||
|
> **zoom**: `0.25` \| `0.5` \| `1`
|
||||||
|
|
||||||
|
Sets result page [zoom level](https://livecodes.io/docs/features/result#result-page-zoom).
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:640](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L640)
|
||||||
91
docs/api/internal/interfaces/AppConfig/index.html
Normal file
91
docs/api/internal/interfaces/AppConfig/index.html
Normal file
File diff suppressed because one or more lines are too long
1555
docs/api/internal/interfaces/ContentConfig.html.md
Normal file
1555
docs/api/internal/interfaces/ContentConfig.html.md
Normal file
File diff suppressed because it is too large
Load Diff
1313
docs/api/internal/interfaces/ContentConfig/index.html
Normal file
1313
docs/api/internal/interfaces/ContentConfig/index.html
Normal file
File diff suppressed because one or more lines are too long
294
docs/api/internal/interfaces/EditorConfig.html.md
Normal file
294
docs/api/internal/interfaces/EditorConfig.html.md
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
# Interface: EditorConfig
|
||||||
|
|
||||||
|
## Extended by
|
||||||
|
|
||||||
|
- [`UserConfig`](UserConfig.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### closeBrackets
|
||||||
|
|
||||||
|
> **closeBrackets**: `boolean`
|
||||||
|
|
||||||
|
Use auto-complete to close brackets and quotes.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:801](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L801)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editor
|
||||||
|
|
||||||
|
> **editor**: `undefined` \| `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"`
|
||||||
|
|
||||||
|
Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use.
|
||||||
|
|
||||||
|
If `undefined` (the default), Monaco editor is used on desktop,
|
||||||
|
CodeMirror is used on mobile and in `simple` mode,
|
||||||
|
while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds.
|
||||||
|
|
||||||
|
If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:722](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L722)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editorMode
|
||||||
|
|
||||||
|
> **editorMode**: `undefined` \| `"vim"` \| `"emacs"`
|
||||||
|
|
||||||
|
Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes).
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:812](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L812)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editorTheme
|
||||||
|
|
||||||
|
> **editorTheme**: `undefined` \| `string` \| [`EditorTheme`](../type-aliases/EditorTheme.md)[]
|
||||||
|
|
||||||
|
Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes.
|
||||||
|
|
||||||
|
See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details.
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"vs"
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"monaco:twilight, codemirror:one-dark"
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["vs@light"]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["vs@light", "vs-dark@dark"]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:748](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L748)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### emmet
|
||||||
|
|
||||||
|
> **emmet**: `boolean`
|
||||||
|
|
||||||
|
Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:807](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L807)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### enableAI
|
||||||
|
|
||||||
|
> **enableAI**: `boolean`
|
||||||
|
|
||||||
|
If `true`, [AI code assistant](https://livecodes.io/docs/features/ai) is enabled.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:818](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L818)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### foldRegions
|
||||||
|
|
||||||
|
> **foldRegions**: `boolean`
|
||||||
|
|
||||||
|
When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:795](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L795)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### fontFamily
|
||||||
|
|
||||||
|
> **fontFamily**: `undefined` \| `string`
|
||||||
|
|
||||||
|
Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family.
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:753](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L753)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### fontSize
|
||||||
|
|
||||||
|
> **fontSize**: `undefined` \| `number`
|
||||||
|
|
||||||
|
Sets the font size.
|
||||||
|
|
||||||
|
If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:761](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L761)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### lineNumbers
|
||||||
|
|
||||||
|
> **lineNumbers**: `boolean` \| `"relative"`
|
||||||
|
|
||||||
|
Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:783](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L783)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### tabSize
|
||||||
|
|
||||||
|
> **tabSize**: `number`
|
||||||
|
|
||||||
|
The number of spaces per indentation-level.
|
||||||
|
|
||||||
|
Also used in [code formatting](https://livecodes.io/docs/features/code-format).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
2
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:777](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L777)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### theme
|
||||||
|
|
||||||
|
> **theme**: [`Theme`](../type-aliases/Theme.md)
|
||||||
|
|
||||||
|
Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"dark"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:728](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L728)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### themeColor
|
||||||
|
|
||||||
|
> **themeColor**: `undefined` \| `string`
|
||||||
|
|
||||||
|
Sets the app theme color.
|
||||||
|
If `undefined`, it is set to `"hsl(214, 40%, 50%)"`.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:735](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L735)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### useTabs
|
||||||
|
|
||||||
|
> **useTabs**: `boolean`
|
||||||
|
|
||||||
|
If `true`, lines are indented with tabs instead of spaces.
|
||||||
|
|
||||||
|
Also used in [code formatting](https://livecodes.io/docs/features/code-format).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:769](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L769)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### wordWrap
|
||||||
|
|
||||||
|
> **wordWrap**: `boolean`
|
||||||
|
|
||||||
|
Enables word-wrap for long lines.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:789](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L789)
|
||||||
174
docs/api/internal/interfaces/EditorConfig/index.html
Normal file
174
docs/api/internal/interfaces/EditorConfig/index.html
Normal file
File diff suppressed because one or more lines are too long
21
docs/api/internal/interfaces/EditorPosition.html.md
Normal file
21
docs/api/internal/interfaces/EditorPosition.html.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Interface: EditorPosition
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### column?
|
||||||
|
|
||||||
|
> `optional` **column**: `number`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1165](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1165)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### lineNumber
|
||||||
|
|
||||||
|
> **lineNumber**: `number`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1164](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1164)
|
||||||
25
docs/api/internal/interfaces/EditorPosition/index.html
Normal file
25
docs/api/internal/interfaces/EditorPosition/index.html
Normal file
File diff suppressed because one or more lines are too long
95
docs/api/internal/interfaces/FormatterConfig.html.md
Normal file
95
docs/api/internal/interfaces/FormatterConfig.html.md
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
# Interface: FormatterConfig
|
||||||
|
|
||||||
|
## Extended by
|
||||||
|
|
||||||
|
- [`UserConfig`](UserConfig.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### semicolons
|
||||||
|
|
||||||
|
> **semicolons**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:838](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L838)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### singleQuote
|
||||||
|
|
||||||
|
> **singleQuote**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:843](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L843)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### tabSize
|
||||||
|
|
||||||
|
> **tabSize**: `number`
|
||||||
|
|
||||||
|
The number of spaces per indentation-level.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
2
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:832](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L832)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### trailingComma
|
||||||
|
|
||||||
|
> **trailingComma**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:849](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L849)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### useTabs
|
||||||
|
|
||||||
|
> **useTabs**: `boolean`
|
||||||
|
|
||||||
|
If `true`, lines are indented with tabs instead of spaces.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:826](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L826)
|
||||||
65
docs/api/internal/interfaces/FormatterConfig/index.html
Normal file
65
docs/api/internal/interfaces/FormatterConfig/index.html
Normal file
File diff suppressed because one or more lines are too long
41
docs/api/internal/interfaces/TestResult.html.md
Normal file
41
docs/api/internal/interfaces/TestResult.html.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Interface: TestResult
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### duration
|
||||||
|
|
||||||
|
> **duration**: `number`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1979](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1979)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### errors
|
||||||
|
|
||||||
|
> **errors**: `string`[]
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1980](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1980)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### status
|
||||||
|
|
||||||
|
> **status**: `"fail"` \| `"pass"` \| `"skip"`
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1981](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1981)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### testPath
|
||||||
|
|
||||||
|
> **testPath**: `string`[]
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:1982](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1982)
|
||||||
39
docs/api/internal/interfaces/TestResult/index.html
Normal file
39
docs/api/internal/interfaces/TestResult/index.html
Normal file
File diff suppressed because one or more lines are too long
5
docs/api/internal/interfaces/Types.html.md
Normal file
5
docs/api/internal/interfaces/Types.html.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Interface: Types
|
||||||
|
|
||||||
|
## Indexable
|
||||||
|
|
||||||
|
\[`key`: `string`\]: `string` \| `object`
|
||||||
13
docs/api/internal/interfaces/Types/index.html
Normal file
13
docs/api/internal/interfaces/Types/index.html
Normal file
File diff suppressed because one or more lines are too long
599
docs/api/internal/interfaces/UserConfig.html.md
Normal file
599
docs/api/internal/interfaces/UserConfig.html.md
Normal file
@ -0,0 +1,599 @@
|
|||||||
|
# Interface: UserConfig
|
||||||
|
|
||||||
|
## Extends
|
||||||
|
|
||||||
|
- [`EditorConfig`](EditorConfig.md).[`FormatterConfig`](FormatterConfig.md)
|
||||||
|
|
||||||
|
## Extended by
|
||||||
|
|
||||||
|
- [`Config`](../../interfaces/Config.md)
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
### appLanguage
|
||||||
|
|
||||||
|
> **appLanguage**: `undefined` \| [`AppLanguage`](../type-aliases/AppLanguage.md)
|
||||||
|
|
||||||
|
Sets the app UI language used.
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:707](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L707)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### autosave
|
||||||
|
|
||||||
|
> **autosave**: `boolean`
|
||||||
|
|
||||||
|
If `true`, the project is automatically saved on code change,
|
||||||
|
after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:656](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L656)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### autotest
|
||||||
|
|
||||||
|
> **autotest**: `boolean`
|
||||||
|
|
||||||
|
If `true`, the project is watched for code changes which trigger tests to auto-run.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:662](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L662)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### autoupdate
|
||||||
|
|
||||||
|
> **autoupdate**: `boolean`
|
||||||
|
|
||||||
|
If `true`, the result page is automatically updated on code change,
|
||||||
|
after time [delay](https://livecodes.io/docs/configuration/configuration-object#delay).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:649](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L649)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### closeBrackets
|
||||||
|
|
||||||
|
> **closeBrackets**: `boolean`
|
||||||
|
|
||||||
|
Use auto-complete to close brackets and quotes.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`closeBrackets`](EditorConfig.md#closebrackets)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:801](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L801)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### delay
|
||||||
|
|
||||||
|
> **delay**: `number`
|
||||||
|
|
||||||
|
Time delay (in milliseconds) following code change,
|
||||||
|
after which the result page is updated (if [`autoupdate`](https://livecodes.io/docs/configuration/configuration-object#autoupdate) is `true`)
|
||||||
|
and/or the project is saved (if [`autosave`](https://livecodes.io/docs/configuration/configuration-object#autosave) is `true`).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
1500
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:670](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L670)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editor
|
||||||
|
|
||||||
|
> **editor**: `undefined` \| `"auto"` \| `"monaco"` \| `"codemirror"` \| `"codejar"`
|
||||||
|
|
||||||
|
Selects the [code editor](https://livecodes.io/docs/features/editor-settings#code-editor) to use.
|
||||||
|
|
||||||
|
If `undefined` (the default), Monaco editor is used on desktop,
|
||||||
|
CodeMirror is used on mobile and in `simple` mode,
|
||||||
|
while CodeJar is used in `codeblock` mode, in `lite` mode and in `readonly` playgrounds.
|
||||||
|
|
||||||
|
If set to `auto`, Monaco editor is used on desktop and CodeMirror is used on mobile regardless of other settings.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`editor`](EditorConfig.md#editor)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:722](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L722)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editorMode
|
||||||
|
|
||||||
|
> **editorMode**: `undefined` \| `"vim"` \| `"emacs"`
|
||||||
|
|
||||||
|
Sets [editor mode](https://livecodes.io/docs/features/editor-settings#editor-modes).
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`editorMode`](EditorConfig.md#editormode)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:812](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L812)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### editorTheme
|
||||||
|
|
||||||
|
> **editorTheme**: `undefined` \| `string` \| [`EditorTheme`](../type-aliases/EditorTheme.md)[]
|
||||||
|
|
||||||
|
Sets the [code editor](https://livecodes.io/docs/features/editor-settings) themes.
|
||||||
|
|
||||||
|
See docs for [editor themes](https://livecodes.io/docs/configuration/configuration-object#editortheme) for details.
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"vs"
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"monaco:twilight, codemirror:one-dark"
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["vs@light"]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["vs@light", "vs-dark@dark"]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
["monaco:vs@light", "codemirror:github-light@light", "dracula@dark"]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`editorTheme`](EditorConfig.md#editortheme)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:748](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L748)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### emmet
|
||||||
|
|
||||||
|
> **emmet**: `boolean`
|
||||||
|
|
||||||
|
Enables [Emmet](https://livecodes.io/docs/features/editor-settings#emmet).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`emmet`](EditorConfig.md#emmet)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:807](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L807)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### enableAI
|
||||||
|
|
||||||
|
> **enableAI**: `boolean`
|
||||||
|
|
||||||
|
If `true`, [AI code assistant](https://livecodes.io/docs/features/ai) is enabled.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`enableAI`](EditorConfig.md#enableai)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:818](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L818)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### foldRegions
|
||||||
|
|
||||||
|
> **foldRegions**: `boolean`
|
||||||
|
|
||||||
|
When set to `true`, regions marked by `#region` and `#endregion` comments are folded when the project is loaded.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`foldRegions`](EditorConfig.md#foldregions)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:795](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L795)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### fontFamily
|
||||||
|
|
||||||
|
> **fontFamily**: `undefined` \| `string`
|
||||||
|
|
||||||
|
Sets the [code editor](https://livecodes.io/docs/features/editor-settings) font family.
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`fontFamily`](EditorConfig.md#fontfamily)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:753](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L753)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### fontSize
|
||||||
|
|
||||||
|
> **fontSize**: `undefined` \| `number`
|
||||||
|
|
||||||
|
Sets the font size.
|
||||||
|
|
||||||
|
If `undefined` (the default), the font size is set to 14 for the full app and 12 for [embeds](https://livecodes.io/docs/features/embeds).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`fontSize`](EditorConfig.md#fontsize)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:761](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L761)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### formatOnsave
|
||||||
|
|
||||||
|
> **formatOnsave**: `boolean`
|
||||||
|
|
||||||
|
If `true`, the code is automatically [formatted](https://livecodes.io/docs/features/code-format) on saving the project.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:676](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L676)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### layout
|
||||||
|
|
||||||
|
> **layout**: `undefined` \| `"horizontal"` \| `"vertical"` \| `"responsive"`
|
||||||
|
|
||||||
|
Sets the app layout to horizontal or vertical.
|
||||||
|
If set to `"responsive"` (the default) or `undefined`,
|
||||||
|
the layout is vertical in small screens when the playground height is larger than its width,
|
||||||
|
otherwise horizontal.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"responsive"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:685](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L685)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### lineNumbers
|
||||||
|
|
||||||
|
> **lineNumbers**: `boolean` \| `"relative"`
|
||||||
|
|
||||||
|
Show line numbers in [code editor](https://livecodes.io/docs/features/editor-settings).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`lineNumbers`](EditorConfig.md#linenumbers)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:783](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L783)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### recoverUnsaved
|
||||||
|
|
||||||
|
> **recoverUnsaved**: `boolean`
|
||||||
|
|
||||||
|
Enables [recovering last unsaved project](https://livecodes.io/docs/features/recover) when the app is reopened.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:691](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L691)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### semicolons
|
||||||
|
|
||||||
|
> **semicolons**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use semi-colons.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`FormatterConfig`](FormatterConfig.md).[`semicolons`](FormatterConfig.md#semicolons)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:838](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L838)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### showSpacing
|
||||||
|
|
||||||
|
> **showSpacing**: `boolean`
|
||||||
|
|
||||||
|
Enables [showing element spacing](https://livecodes.io/docs/features/result#show-spacings) in the result page.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:697](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L697)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### singleQuote
|
||||||
|
|
||||||
|
> **singleQuote**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use single quotes instead of double quotes.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`FormatterConfig`](FormatterConfig.md).[`singleQuote`](FormatterConfig.md#singlequote)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:843](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L843)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### tabSize
|
||||||
|
|
||||||
|
> **tabSize**: `number`
|
||||||
|
|
||||||
|
The number of spaces per indentation-level.
|
||||||
|
|
||||||
|
Also used in [code formatting](https://livecodes.io/docs/features/code-format).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
2
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`FormatterConfig`](FormatterConfig.md).[`tabSize`](FormatterConfig.md#tabsize)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:777](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L777)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### theme
|
||||||
|
|
||||||
|
> **theme**: [`Theme`](../type-aliases/Theme.md)
|
||||||
|
|
||||||
|
Sets the app [theme](https://livecodes.io/docs/features/themes) to light/dark mode.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"dark"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`theme`](EditorConfig.md#theme)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:728](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L728)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### themeColor
|
||||||
|
|
||||||
|
> **themeColor**: `undefined` \| `string`
|
||||||
|
|
||||||
|
Sets the app theme color.
|
||||||
|
If `undefined`, it is set to `"hsl(214, 40%, 50%)"`.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
undefined
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`themeColor`](EditorConfig.md#themecolor)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:735](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L735)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### trailingComma
|
||||||
|
|
||||||
|
> **trailingComma**: `boolean`
|
||||||
|
|
||||||
|
Configures Prettier [code formatter](https://livecodes.io/docs/features/code-format) to use [trailing commas](https://prettier.io/docs/en/options.html#trailing-commas).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`FormatterConfig`](FormatterConfig.md).[`trailingComma`](FormatterConfig.md#trailingcomma)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:849](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L849)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### useTabs
|
||||||
|
|
||||||
|
> **useTabs**: `boolean`
|
||||||
|
|
||||||
|
If `true`, lines are indented with tabs instead of spaces.
|
||||||
|
|
||||||
|
Also used in [code formatting](https://livecodes.io/docs/features/code-format).
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`FormatterConfig`](FormatterConfig.md).[`useTabs`](FormatterConfig.md#usetabs)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:769](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L769)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### welcome
|
||||||
|
|
||||||
|
> **welcome**: `boolean`
|
||||||
|
|
||||||
|
If `true`, the [welcome screen](https://livecodes.io/docs/features/welcome) is displayed when the app loads.
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:702](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L702)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### wordWrap
|
||||||
|
|
||||||
|
> **wordWrap**: `boolean`
|
||||||
|
|
||||||
|
Enables word-wrap for long lines.
|
||||||
|
|
||||||
|
#### Default
|
||||||
|
|
||||||
|
```ts
|
||||||
|
false
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Inherited from
|
||||||
|
|
||||||
|
[`EditorConfig`](EditorConfig.md).[`wordWrap`](EditorConfig.md#wordwrap)
|
||||||
|
|
||||||
|
#### Defined in
|
||||||
|
|
||||||
|
[models.ts:789](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L789)
|
||||||
347
docs/api/internal/interfaces/UserConfig/index.html
Normal file
347
docs/api/internal/interfaces/UserConfig/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/APICommands.html.md
Normal file
7
docs/api/internal/type-aliases/APICommands.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: APICommands
|
||||||
|
|
||||||
|
> **APICommands**: `"setBroadcastToken"` \| `"showVersion"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:280](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L280)
|
||||||
16
docs/api/internal/type-aliases/APICommands/index.html
Normal file
16
docs/api/internal/type-aliases/APICommands/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/AppLanguage.html.md
Normal file
7
docs/api/internal/type-aliases/AppLanguage.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: AppLanguage
|
||||||
|
|
||||||
|
> **AppLanguage**: `"auto"` \| `"ar"` \| `"de"` \| `"en"` \| `"es"` \| `"fr"` \| `"hi"` \| `"it"` \| `"ja"` \| `"pt"` \| `"ru"` \| `"ur"` \| `"zh-CN"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1778](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1778)
|
||||||
16
docs/api/internal/type-aliases/AppLanguage/index.html
Normal file
16
docs/api/internal/type-aliases/AppLanguage/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/CDN.html.md
Normal file
7
docs/api/internal/type-aliases/CDN.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: CDN
|
||||||
|
|
||||||
|
> **CDN**: `"jspm"` \| `"skypack"` \| `"jsdelivr"` \| `"fastly.jsdelivr"` \| `"gcore.jsdelivr"` \| `"testingcf.jsdelivr"` \| `"jsdelivr.b-cdn"` \| `"jsdelivr.gh"` \| `"fastly.jsdelivr.gh"` \| `"gcore.jsdelivr.gh"` \| `"testingcf.jsdelivr.gh"` \| `"jsdelivr.b-cdn.gh"` \| `"jsdelivr.esm"` \| `"fastly.jsdelivr.esm"` \| `"gcore.jsdelivr.esm"` \| `"testingcf.jsdelivr.esm"` \| `"jsdelivr.b-cdn.esm"` \| `"esm.run"` \| `"esm.sh"` \| `"esbuild"` \| `"bundle.run"` \| `"unpkg"` \| `"npmcdn"` \| `"statically"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1861](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1861)
|
||||||
16
docs/api/internal/type-aliases/CDN/index.html
Normal file
16
docs/api/internal/type-aliases/CDN/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/CodejarTheme.html.md
Normal file
7
docs/api/internal/type-aliases/CodejarTheme.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: CodejarTheme
|
||||||
|
|
||||||
|
> **CodejarTheme**: `"a11y-dark"` \| `"atom-dark"` \| `"base16-ateliersulphurpool-light"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"cb"` \| `"coldark-cold"` \| `"coldark-dark"` \| `"coy"` \| `"coy-without-shadows"` \| `"darcula"` \| `"dark"` \| `"dracula"` \| `"duotone-dark"` \| `"duotone-earth"` \| `"duotone-forest"` \| `"duotone-light"` \| `"duotone-sea"` \| `"duotone-space"` \| `"funky"` \| `"ghcolors"` \| `"gruvbox-dark"` \| `"gruvbox-light"` \| `"holi-theme"` \| `"hopscotch"` \| `"laserwave"` \| `"lucario"` \| `"material-dark"` \| `"material-light"` \| `"material-oceanic"` \| `"monochrome"` \| `"monochrome-dark"` \| `"night-owl"` \| `"nord"` \| `"nord-2"` \| `"okaidia"` \| `"one-dark"` \| `"one-light"` \| `"pojoaque"` \| `"shades-of-purple"` \| `"solarized-dark-atom"` \| `"solarized-light"` \| `"synthwave84"` \| `"tomorrow"` \| `"twilight"` \| `"vs"` \| `"vsc-dark-plus"` \| `"xonokai"` \| `"z-touchs"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1687](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1687)
|
||||||
16
docs/api/internal/type-aliases/CodejarTheme/index.html
Normal file
16
docs/api/internal/type-aliases/CodejarTheme/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/CodemirrorTheme.html.md
Normal file
7
docs/api/internal/type-aliases/CodemirrorTheme.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: CodemirrorTheme
|
||||||
|
|
||||||
|
> **CodemirrorTheme**: `"amy"` \| `"aura"` \| `"ayu-light"` \| `"barf"` \| `"basic-light"` \| `"basic-dark"` \| `"bespin"` \| `"birds-of-paradise"` \| `"boys-and-girls"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"clouds"` \| `"cm-light"` \| `"cobalt"` \| `"cool-glow"` \| `"dracula"` \| `"espresso"` \| `"github-dark"` \| `"github-light"` \| `"gruvbox-dark"` \| `"gruvbox-light"` \| `"material-dark"` \| `"material-light"` \| `"monochrome"` \| `"monochrome-dark"` \| `"noctis-lilac"` \| `"nord"` \| `"one-dark"` \| `"rose-pine-dawn"` \| `"smoothy"` \| `"solarized-light"` \| `"solarized-dark"` \| `"tokyo-night"` \| `"tokyo-night-day"` \| `"tokyo-night-storm"` \| `"tomorrow"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1647](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1647)
|
||||||
16
docs/api/internal/type-aliases/CodemirrorTheme/index.html
Normal file
16
docs/api/internal/type-aliases/CodemirrorTheme/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/CssPresetId.html.md
Normal file
7
docs/api/internal/type-aliases/CssPresetId.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: CssPresetId
|
||||||
|
|
||||||
|
> **CssPresetId**: `""` \| `"normalize.css"` \| `"reset-css"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1269](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1269)
|
||||||
16
docs/api/internal/type-aliases/CssPresetId/index.html
Normal file
16
docs/api/internal/type-aliases/CssPresetId/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/EditorId.html.md
Normal file
7
docs/api/internal/type-aliases/EditorId.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: EditorId
|
||||||
|
|
||||||
|
> **EditorId**: `"markup"` \| `"style"` \| `"script"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1168](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1168)
|
||||||
16
docs/api/internal/type-aliases/EditorId/index.html
Normal file
16
docs/api/internal/type-aliases/EditorId/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/EditorTheme.html.md
Normal file
7
docs/api/internal/type-aliases/EditorTheme.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: EditorTheme
|
||||||
|
|
||||||
|
> **EditorTheme**: [`MonacoTheme`](MonacoTheme.md) \| [`CodemirrorTheme`](CodemirrorTheme.md) \| [`CodejarTheme`](CodejarTheme.md) \| \`$\{MonacoTheme\}@$\{Theme\}\` \| \`$\{CodemirrorTheme\}@$\{Theme\}\` \| \`$\{CodejarTheme\}@$\{Theme\}\` \| \`monaco:$\{MonacoTheme\}\` \| \`codemirror:$\{CodemirrorTheme\}\` \| \`codejar:$\{CodejarTheme\}\` \| \`monaco:$\{MonacoTheme\}@$\{Theme\}\` \| \`codemirror:$\{CodemirrorTheme\}@$\{Theme\}\` \| \`codejar:$\{CodejarTheme\}@$\{Theme\}\`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1740](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1740)
|
||||||
16
docs/api/internal/type-aliases/EditorTheme/index.html
Normal file
16
docs/api/internal/type-aliases/EditorTheme/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/MonacoTheme.html.md
Normal file
7
docs/api/internal/type-aliases/MonacoTheme.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: MonacoTheme
|
||||||
|
|
||||||
|
> **MonacoTheme**: `"active4d"` \| `"all-hallows-eve"` \| `"amy"` \| `"birds-of-paradise"` \| `"blackboard"` \| `"brilliance-black"` \| `"brilliance-dull"` \| `"catppuccin-latte"` \| `"catppuccin-frappe"` \| `"catppuccin-macchiato"` \| `"catppuccin-mocha"` \| `"chrome-devtools"` \| `"clouds-midnight"` \| `"clouds"` \| `"cobalt"` \| `"cobalt2"` \| `"custom-vs-light"` \| `"custom-vs-dark"` \| `"dawn"` \| `"dracula"` \| `"dreamweaver"` \| `"eiffel"` \| `"espresso-libre"` \| `"github"` \| `"github-dark"` \| `"github-light"` \| `"hc-black"` \| `"hc-light"` \| `"idle"` \| `"idlefingers"` \| `"iplastic"` \| `"katzenmilch"` \| `"krtheme"` \| `"kuroir"` \| `"lazy"` \| `"magicwb-amiga"` \| `"merbivore-soft"` \| `"merbivore"` \| `"monochrome"` \| `"monochrome-dark"` \| `"monokai"` \| `"monokai-bright"` \| `"monoindustrial"` \| `"night-owl"` \| `"nord"` \| `"oceanic-next"` \| `"pastels-on-dark"` \| `"slush-and-poppies"` \| `"solarized-dark"` \| `"solarized-light"` \| `"spacecadet"` \| `"sunburst"` \| `"textmate-mac-classic"` \| `"tomorrow"` \| `"tomorrow-night"` \| `"tomorrow-night-blue"` \| `"tomorrow-night-bright"` \| `"tomorrow-night-eighties"` \| `"twilight"` \| `"upstream-sunburst"` \| `"vibrant-ink"` \| `"vs"` \| `"vs-dark"` \| `"xcode-default"` \| `"zenburnesque"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1580](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1580)
|
||||||
16
docs/api/internal/type-aliases/MonacoTheme/index.html
Normal file
16
docs/api/internal/type-aliases/MonacoTheme/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/Processor.html.md
Normal file
7
docs/api/internal/type-aliases/Processor.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: Processor
|
||||||
|
|
||||||
|
> **Processor**: `"postcss"` \| `"postcssImportUrl"` \| `"tailwindcss"` \| `"windicss"` \| `"unocss"` \| `"tokencss"` \| `"lightningcss"` \| `"autoprefixer"` \| `"postcssPresetEnv"` \| `"cssmodules"` \| `"purgecss"` \| `"cssnano"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1226](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1226)
|
||||||
16
docs/api/internal/type-aliases/Processor/index.html
Normal file
16
docs/api/internal/type-aliases/Processor/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/TemplateName.html.md
Normal file
7
docs/api/internal/type-aliases/TemplateName.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: TemplateName
|
||||||
|
|
||||||
|
> **TemplateName**: `"blank"` \| `"javascript"` \| `"typescript"` \| `"react"` \| `"react-native"` \| `"vue2"` \| `"vue"` \| `"angular"` \| `"preact"` \| `"svelte"` \| `"solid"` \| `"lit"` \| `"stencil"` \| `"mdx"` \| `"astro"` \| `"riot"` \| `"malina"` \| `"jquery"` \| `"backbone"` \| `"knockout"` \| `"jest"` \| `"jest-react"` \| `"bootstrap"` \| `"tailwindcss"` \| `"shadcn-ui"` \| `"daisyui"` \| `"d3"` \| `"phaser"` \| `"coffeescript"` \| `"livescript"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"rescript"` \| `"reason"` \| `"ocaml"` \| `"python"` \| `"pyodide"` \| `"python-wasm"` \| `"r"` \| `"ruby"` \| `"ruby-wasm"` \| `"go"` \| `"php"` \| `"php-wasm"` \| `"cpp"` \| `"clang"` \| `"cpp-wasm"` \| `"java"` \| `"csharp-wasm"` \| `"perl"` \| `"lua"` \| `"lua-wasm"` \| `"teal"` \| `"fennel"` \| `"julia"` \| `"scheme"` \| `"commonlisp"` \| `"clojurescript"` \| `"gleam"` \| `"tcl"` \| `"markdown"` \| `"assemblyscript"` \| `"wat"` \| `"sql"` \| `"postgresql"` \| `"prolog"` \| `"blockly"` \| `"diagrams"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1376](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1376)
|
||||||
16
docs/api/internal/type-aliases/TemplateName/index.html
Normal file
16
docs/api/internal/type-aliases/TemplateName/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/Theme.html.md
Normal file
7
docs/api/internal/type-aliases/Theme.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: Theme
|
||||||
|
|
||||||
|
> **Theme**: `"light"` \| `"dark"`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1926](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1926)
|
||||||
16
docs/api/internal/type-aliases/Theme/index.html
Normal file
16
docs/api/internal/type-aliases/Theme/index.html
Normal file
File diff suppressed because one or more lines are too long
7
docs/api/internal/type-aliases/ToolsPaneStatus.html.md
Normal file
7
docs/api/internal/type-aliases/ToolsPaneStatus.html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Type Alias: ToolsPaneStatus
|
||||||
|
|
||||||
|
> **ToolsPaneStatus**: `"closed"` \| `"open"` \| `"full"` \| `"none"` \| `""`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:1456](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L1456)
|
||||||
16
docs/api/internal/type-aliases/ToolsPaneStatus/index.html
Normal file
16
docs/api/internal/type-aliases/ToolsPaneStatus/index.html
Normal file
File diff suppressed because one or more lines are too long
37
docs/api/internal/type-aliases/WatchCode.html.md
Normal file
37
docs/api/internal/type-aliases/WatchCode.html.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Type Alias: WatchCode()
|
||||||
|
|
||||||
|
> **WatchCode**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
Called when the playground "content" is changed (see [`getCode`](https://livecodes.io/docs/sdk/js-ts#getcode) and [`getConfig`](https://livecodes.io/docs/sdk/js-ts#getcode)).
|
||||||
|
|
||||||
|
This includes changes in:
|
||||||
|
- Code (in editors)
|
||||||
|
- Editor [languages](https://livecodes.io/docs/languages/)
|
||||||
|
- [CSS processors](https://livecodes.io/docs/features/css#css-processors)
|
||||||
|
- [External resources](https://livecodes.io/docs/features/external-resources)
|
||||||
|
- Project info (e.g. allows adding content in page head and attributes to `<html>` element)
|
||||||
|
- [Custom settings](https://livecodes.io/docs/advanced/custom-settings) (e.g. allows changing [import maps](https://livecodes.io/docs/features/module-resolution#custom-module-resolution))
|
||||||
|
- Project title
|
||||||
|
- [Test](https://livecodes.io/docs/features/tests) code
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"code"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:248](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L248)
|
||||||
39
docs/api/internal/type-aliases/WatchCode/index.html
Normal file
39
docs/api/internal/type-aliases/WatchCode/index.html
Normal file
File diff suppressed because one or more lines are too long
25
docs/api/internal/type-aliases/WatchConsole.html.md
Normal file
25
docs/api/internal/type-aliases/WatchConsole.html.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Type Alias: WatchConsole()
|
||||||
|
|
||||||
|
> **WatchConsole**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"console"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:253](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L253)
|
||||||
27
docs/api/internal/type-aliases/WatchConsole/index.html
Normal file
27
docs/api/internal/type-aliases/WatchConsole/index.html
Normal file
File diff suppressed because one or more lines are too long
25
docs/api/internal/type-aliases/WatchDestroy.html.md
Normal file
25
docs/api/internal/type-aliases/WatchDestroy.html.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Type Alias: WatchDestroy()
|
||||||
|
|
||||||
|
> **WatchDestroy**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"destroy"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:263](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L263)
|
||||||
27
docs/api/internal/type-aliases/WatchDestroy/index.html
Normal file
27
docs/api/internal/type-aliases/WatchDestroy/index.html
Normal file
File diff suppressed because one or more lines are too long
27
docs/api/internal/type-aliases/WatchLoad.html.md
Normal file
27
docs/api/internal/type-aliases/WatchLoad.html.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Type Alias: WatchLoad()
|
||||||
|
|
||||||
|
> **WatchLoad**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
Called when the playground first loads.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"load"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:225](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L225)
|
||||||
28
docs/api/internal/type-aliases/WatchLoad/index.html
Normal file
28
docs/api/internal/type-aliases/WatchLoad/index.html
Normal file
File diff suppressed because one or more lines are too long
27
docs/api/internal/type-aliases/WatchReady.html.md
Normal file
27
docs/api/internal/type-aliases/WatchReady.html.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Type Alias: WatchReady()
|
||||||
|
|
||||||
|
> **WatchReady**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
Called when a new project is loaded (including when [imported](https://livecodes.io/docs/features/import)) and the playground is ready to run.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"ready"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:230](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L230)
|
||||||
28
docs/api/internal/type-aliases/WatchReady/index.html
Normal file
28
docs/api/internal/type-aliases/WatchReady/index.html
Normal file
File diff suppressed because one or more lines are too long
25
docs/api/internal/type-aliases/WatchTests.html.md
Normal file
25
docs/api/internal/type-aliases/WatchTests.html.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Type Alias: WatchTests()
|
||||||
|
|
||||||
|
> **WatchTests**: (`event`, `fn`) => `object`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
• **event**: `"tests"`
|
||||||
|
|
||||||
|
• **fn**
|
||||||
|
|
||||||
|
## Returns
|
||||||
|
|
||||||
|
`object`
|
||||||
|
|
||||||
|
### remove()
|
||||||
|
|
||||||
|
> **remove**: () => `void`
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
`void`
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:258](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L258)
|
||||||
27
docs/api/internal/type-aliases/WatchTests/index.html
Normal file
27
docs/api/internal/type-aliases/WatchTests/index.html
Normal file
File diff suppressed because one or more lines are too long
9
docs/api/type-aliases/Language.html.md
Normal file
9
docs/api/type-aliases/Language.html.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Type Alias: Language
|
||||||
|
|
||||||
|
> **Language**: `"html"` \| `"htm"` \| `"markdown"` \| `"md"` \| `"mdown"` \| `"mkdn"` \| `"mdx"` \| `"astro"` \| `"pug"` \| `"jade"` \| `"haml"` \| `"asciidoc"` \| `"adoc"` \| `"asc"` \| `"mustache"` \| `"handlebars"` \| `"hbs"` \| `"ejs"` \| `"eta"` \| `"nunjucks"` \| `"njk"` \| `"liquid"` \| `"liquidjs"` \| `"dot"` \| `"twig"` \| `"vento"` \| `"vto"` \| `"art-template"` \| `"art"` \| `"jinja"` \| `"bbcode"` \| `"bb"` \| `"mjml"` \| `"diagrams"` \| `"diagram"` \| `"graph"` \| `"plt"` \| `"richtext"` \| `"rte"` \| `"rich"` \| `"rte.html"` \| `"css"` \| `"scss"` \| `"sass"` \| `"less"` \| `"stylus"` \| `"styl"` \| `"stylis"` \| `"postcss"` \| `"javascript"` \| `"js"` \| `"json"` \| `"babel"` \| `"es"` \| `"sucrase"` \| `"typescript"` \| `"flow"` \| `"ts"` \| `"jsx"` \| `"tsx"` \| `"react"` \| `"react-jsx"` \| `"react.jsx"` \| `"react-tsx"` \| `"react.tsx"` \| `"react-native"` \| `"react-native.jsx"` \| `"react-native-tsx"` \| `"react-native.tsx"` \| `"vue"` \| `"vue3"` \| `"vue2"` \| `"vue-app"` \| `"app.vue"` \| `"svelte"` \| `"svelte-app"` \| `"app.svelte"` \| `"stencil"` \| `"stencil.tsx"` \| `"solid"` \| `"solid.jsx"` \| `"solid.tsx"` \| `"riot"` \| `"riotjs"` \| `"malina"` \| `"malinajs"` \| `"xht"` \| `"coffeescript"` \| `"coffee"` \| `"livescript"` \| `"ls"` \| `"civet"` \| `"clio"` \| `"imba"` \| `"assemblyscript"` \| `"as"` \| `"python"` \| `"py"` \| `"pyodide"` \| `"python-wasm"` \| `"py-wasm"` \| `"pythonwasm"` \| `"pywasm"` \| `"py3"` \| `"wasm.py"` \| `"r"` \| `"rlang"` \| `"rstats"` \| `"r-wasm"` \| `"ruby"` \| `"rb"` \| `"ruby-wasm"` \| `"wasm.rb"` \| `"rubywasm"` \| `"go"` \| `"golang"` \| `"php"` \| `"php-wasm"` \| `"phpwasm"` \| `"wasm.php"` \| `"cpp"` \| `"c"` \| `"C"` \| `"cp"` \| `"cxx"` \| `"c++"` \| `"cppm"` \| `"ixx"` \| `"ii"` \| `"hpp"` \| `"h"` \| `"cpp-wasm"` \| `"cppwasm"` \| `"cwasm"` \| `"wasm.cpp"` \| `"clang"` \| `"clang.cpp"` \| `"java"` \| `"csharp"` \| `"csharp-wasm"` \| `"cs"` \| `"cs-wasm"` \| `"wasm.cs"` \| `"perl"` \| `"pl"` \| `"pm"` \| `"lua"` \| `"lua-wasm"` \| `"luawasm"` \| `"wasm.lua"` \| `"teal"` \| `"tl"` \| `"fennel"` \| `"fnl"` \| `"julia"` \| `"jl"` \| `"scheme"` \| `"scm"` \| `"commonlisp"` \| `"common-lisp"` \| `"lisp"` \| `"clojurescript"` \| `"clojure"` \| `"cljs"` \| `"clj"` \| `"cljc"` \| `"edn"` \| `"gleam"` \| `"rescript"` \| `"res"` \| `"resi"` \| `"reason"` \| `"re"` \| `"rei"` \| `"ocaml"` \| `"ml"` \| `"mli"` \| `"tcl"` \| `"wat"` \| `"wast"` \| `"webassembly"` \| `"wasm"` \| `"Binary"` \| `"sql"` \| `"sqlite"` \| `"sqlite3"` \| `"pg.sql"` \| `"pgsql.sql"` \| `"pgsql"` \| `"pg"` \| `"pglite"` \| `"pglite.sql"` \| `"postgresql"` \| `"postgres"` \| `"postgre.sql"` \| `"postgresql.sql"` \| `"prolog.pl"` \| `"prolog"` \| `"blockly"` \| `"blockly.xml"` \| `"xml"` \| `"pintora"`
|
||||||
|
|
||||||
|
Language name, alias or extension.
|
||||||
|
|
||||||
|
## Defined in
|
||||||
|
|
||||||
|
[models.ts:884](https://github.com/live-codes/livecodes/blob/7617d5c8be5a2a8be8133f973d9e69eb9f86434d/src/sdk/models.ts#L884)
|
||||||
17
docs/api/type-aliases/Language/index.html
Normal file
17
docs/api/type-aliases/Language/index.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/assets/css/styles.61e3dfbf.css
Normal file
1
docs/assets/css/styles.61e3dfbf.css
Normal file
File diff suppressed because one or more lines are too long
@ -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();
|
||||||
@ -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};
|
||||||
@ -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();
|
||||||
@ -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)}})();
|
||||||
@ -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))})();
|
||||||
@ -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
|
||||||
|
})
|
||||||
@ -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'
|
||||||
|
});
|
||||||
@ -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'
|
||||||
|
});
|
||||||
@ -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 }}'
|
||||||
|
});
|
||||||
@ -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))})})();
|
||||||
@ -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();
|
||||||
BIN
docs/assets/images/assets-1-bc942edb19a81002953065dc3fa29544.jpg
Normal file
BIN
docs/assets/images/assets-1-bc942edb19a81002953065dc3fa29544.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
BIN
docs/assets/images/assets-2-8312924d50bae171b9875269d3945b7b.jpg
Normal file
BIN
docs/assets/images/assets-2-8312924d50bae171b9875269d3945b7b.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 199 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user