Skip to content

Commit

Permalink
Merge pull request #480 from live-codes/develop
Browse files Browse the repository at this point in the history
release v19
  • Loading branch information
hatemhosny authored Nov 27, 2023
2 parents df3828b + db16f41 commit 2ea3810
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 56 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

---

## [v19](https://github.com/live-codes/livecodes/compare/v18...v19) (2023-11-27)


### Bug Fixes

* **Templates:** fix solid template ([32732a0](https://github.com/live-codes/livecodes/commit/32732a0bc32a0660561d4d104379785877e755aa))


### Features

* **compilers:** upgrade Brython to v3.12.1 running Python v3.12 ([933f606](https://github.com/live-codes/livecodes/commit/933f606d960d9cea9b41534e944e6c2417902b77))
* **Types:** load types for imports from CDN URLs ([8d25463](https://github.com/live-codes/livecodes/commit/8d2546393591c49e1b698e707e731b2977ad8085))




---

## [v18](https://github.com/live-codes/livecodes/compare/v17...v18) (2023-11-26)
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ LiveCodes uses services that are generously provided by:
</img></a><br /><br />
</p>
<p>
<a href="https://www.skypack.dev/" target="_blank" title="Skypack">
<img alt="Skypack" width="200" src="https://dev.livecodes.io/docs/img/credits/skypack.svg">
<a href="https://esm.sh/" target="_blank" title="esm.sh">
<img alt="esm.sh" width="200" src="https://dev.livecodes.io/docs/img/credits/esm.sh.png">
</img></a><br /><br />
</p>
<p>
Expand All @@ -172,11 +172,6 @@ LiveCodes uses services that are generously provided by:
</img></a><br /><br />
</p>
<p>
<a href="https://kapa.ai/" target="_blank" title="Kapa.ai">
<img alt="Kapa.ai" width="200" src="https://dev.livecodes.io/docs/img/credits/kapa-ai.jpg">
</img></a><br /><br />
</p>
<p>
<a href="https://www.sonarsource.com/products/sonarcloud/" target="_blank" title="SonarCloud">
<img alt="SonarCloud" width="200" src="https://dev.livecodes.io/docs/img/credits/sonarcloud.svg">
</img></a><br /><br />
Expand Down
9 changes: 2 additions & 7 deletions docs/docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ LiveCodes uses services that are generously provided by:
</img></a>
</p>
<p>
<a href="https://www.skypack.dev/" target="_blank" title="Skypack">
<img alt="Skypack" width="200" style={{margin: "0.5em"}} src="/docs/img/credits/skypack.svg">
<a href="https://esm.sh/" target="_blank" title="esm.sh">
<img alt="esm.sh" width="200" style={{margin: "0.5em"}} src="/docs/img/credits/esm.sh.png">
</img></a>
</p>
<p>
Expand All @@ -40,11 +40,6 @@ LiveCodes uses services that are generously provided by:
</img></a>
</p>
<p>
<a href="https://kapa.ai/" target="_blank" title="Kapa.ai">
<img alt="Kapa.ai" width="200" style={{margin: "0.5em"}} src="/docs/img/credits/kapa-ai.jpg">
</img></a>
</p>
<p>
<a href="https://www.sonarsource.com/products/sonarcloud/" target="_blank" title="SonarCloud">
<img alt="SonarCloud" width="200" style={{margin: "0.5em"}} src="/docs/img/credits/sonarcloud.svg">
</img></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/features/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ import '@testing-library/jest-dom';

### Chai

Jest assertions can be used in the tests. However, if you prefer to Chai, it can be easily used.
Jest assertions can be used in the tests. However, if you prefer Chai, it can be easily used.
Autocomplete is also available in Monaco editor for Chai API.

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/languages/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Check the [starter template](#starter-template) for an example.

### Version

Brython v3.11.3, running Python v3.11
Brython v3.12.1, running Python v3.12

## Code Formatting

Expand Down
8 changes: 0 additions & 8 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,6 @@ const config = {
async: true,
defer: true,
},
{
src: 'https://widget.kapa.ai/kapa-widget.bundle.js',
'data-website-id': 'c5e9cf39-ef75-4290-becc-151b380252a3',
'data-project-name': 'LiveCodes',
'data-project-color': '#44494F',
'data-project-logo': 'https://avatars.githubusercontent.com/u/90906587?s=280&v=4',
async: true,
},
],
headTags: [
{
Expand Down
3 changes: 1 addition & 2 deletions docs/src/components/HomepageFeatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ const FeatureList3: FeatureItem[] = [
<Link to="./features">features</Link>, <Link to="./configuration">configuration</Link> and{' '}
<Link to="./sdk">SDK</Link> (including <Link to="./api/modules">TypeScript types</Link>).
Documentations are rich with code samples, live demos and screenshots. A gallery of usage
examples is provided as a <Link to="pathname:///../stories">storybook</Link>. You can even
just ask our <strong>AI chatbot</strong>.
examples is provided as a <Link to="pathname:///../stories">storybook</Link>.
</>
),
},
Expand Down
Binary file added docs/static/img/credits/esm.sh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "livecodes",
"version": "0.0.0",
"appVersion": "18",
"appVersion": "19",
"description": "Code Playground That Just Works!",
"author": "Hatem Hosny",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/services/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CDN } from '../models';

declare const globalThis: { appCDN: CDN };

const moduleCDNs: CDN[] = ['jspm', 'skypack'];
const moduleCDNs: CDN[] = ['jspm', 'esm.sh', 'skypack'];
const npmCDNs: CDN[] = ['unpkg', 'jsdelivr', 'fastly.jsdelivr'];
const ghCDNs: CDN[] = ['fastly.jsdelivr.gh', 'jsdelivr.gh', 'statically'];

Expand Down
30 changes: 28 additions & 2 deletions src/livecodes/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const typesService = {
const fetchedTypes: Types = {};
await Promise.all(
types.map(async (type) => {
if (!isBare(type)) return;
const mod = removeSpecifier(removeCDNPrefix(type));
if (!isBare(mod)) return;
try {
const mod = type.includes(':') ? type.split(':')[1] : type;
const res = await fetch('https://esm.sh/' + mod);
if (!res.ok) return;
const typesUrl = res.headers.get('X-Typescript-Types');
Expand All @@ -23,3 +23,29 @@ export const typesService = {
return fetchedTypes;
},
};

const removeCDNPrefix = (url: string) => {
if (!url.startsWith('https://')) return url;

const prefixes = [
'https://jspm.dev/',
'https://cdn.skypack.dev/',
'https://cdn.jsdelivr.net/npm/',
'https://fastly.jsdelivr.net/npm/',
'https://esm.run/',
'https://esm.sh/',
'https://esbuild.vercel.app/',
'https://bundle.run/',
'https://unpkg.com/',
'https://deno.bundlejs.com/?file&q=',
];

for (const prefix of prefixes) {
if (url.startsWith(prefix)) {
return url.replace(prefix, '');
}
}
return url;
};

const removeSpecifier = (type: string) => (type.includes(':') ? type.split(':')[1] : type);
9 changes: 1 addition & 8 deletions src/livecodes/templates/starter/angular-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Component, Input, NgModule, enableProdMode } from '@angular/[email protected]
import { CommonModule } from '@angular/[email protected]';
import { BrowserModule } from '@angular/[email protected]';
import { platformBrowserDynamic } from '@angular/[email protected]';
import 'zone.js/dist/zone';
import 'zone.js@0.12.0/dist/zone';
// app.component.ts
@Component({
Expand Down Expand Up @@ -87,13 +87,6 @@ platformBrowserDynamic()
.catch((err: Error) => console.error(err));
`.trimStart(),
},
stylesheets: [],
scripts: [],
cssPreset: '',
imports: {},
types: {
'zone.js/dist/zone': '',
},
customSettings: {
typescript: {
experimentalDecorators: true,
Expand Down
22 changes: 11 additions & 11 deletions src/livecodes/templates/starter/lit-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export class SignalExample extends SignalWatcher(LitElement) {
}
static styles = css\`
:host {
display: flex;
flex-direction: column;
align-items: center;
}
:host, button {
font: 1em sans-serif;
}
.logo {
width: 150px;
}
:host {
display: flex;
flex-direction: column;
align-items: center;
}
:host, button {
font: 1em sans-serif;
}
.logo {
width: 150px;
}
\`;
}
`.trimStart(),
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/templates/starter/solid-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function App(props: Props) {
<div className="container">
<h1>Hello, {props.title}!</h1>
<img className="logo" alt="logo" src="{{ __livecodes_baseUrl__ }}assets/templates/solid.svg" />
<p>You clicked {count} times.</p>
<p>You clicked {count()} times.</p>
<button onClick={increment}>Click me</button>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/toolspane/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const createToolsPane = (
const updateConfig = () => {
setTools({
enabled: tools.length === allTools.length ? 'all' : tools.map((tool) => tool.name),
active: tools[activeToolId].name,
active: tools[activeToolId]?.name,
status,
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/livecodes/types/type-loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getImports } from '../compiler';
import type { EditorLibrary, Types } from '../models';
import { typesService } from '../services';
import { objectFilter } from '../utils';
import { objectFilter, safeName } from '../utils';

export const createTypeLoader = () => {
let loadedTypes: Types = {};
Expand All @@ -28,7 +28,7 @@ export const createTypeLoader = () => {
}
loadedTypes = { ...loadedTypes, ...type };
return {
filename: `file:///node_modules/${name}/index.d.ts`,
filename: `file:///node_modules/${safeName(name)}/index.d.ts`,
content,
};
};
Expand Down
6 changes: 3 additions & 3 deletions src/livecodes/vendors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export const browserJestUrl = /* @__PURE__ */ getUrl(
'@live-codes/[email protected]/dist/browser-jest.umd.js',
);

export const brythonBaseUrl = /* @__PURE__ */ getUrl('brython@3.11.3/');
export const brythonBaseUrl = /* @__PURE__ */ getUrl('brython@3.12.1/');

export const chaiUrl = /* @__PURE__ */ getModuleUrl('chai@4.3.6');
export const chaiUrl = /* @__PURE__ */ getModuleUrl('chai@5.0.0-alpha.2');

export const chaiTypesUrl = /* @__PURE__ */ getUrl('@types/chai@4.2.22/index.d.ts');
export const chaiTypesUrl = /* @__PURE__ */ getUrl('@types/chai@4.3.11/index.d.ts');

export const cherryCljsBaseUrl = /* @__PURE__ */ getUrl('[email protected]/');

Expand Down

0 comments on commit 2ea3810

Please sign in to comment.