From 78921cf0db74ddaa7b9d9098e29acf323c95037c Mon Sep 17 00:00:00 2001 From: Hatem Hosny Date: Wed, 17 Jan 2024 22:34:26 +0200 Subject: [PATCH 1/3] use esm.sh as default CDN --- src/livecodes/services/modules.ts | 8 +++----- src/livecodes/templates/starter/preact-starter.ts | 4 +++- src/livecodes/toolspane/test-imports.ts | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/livecodes/services/modules.ts b/src/livecodes/services/modules.ts index d70b153a1..19ce0e157 100644 --- a/src/livecodes/services/modules.ts +++ b/src/livecodes/services/modules.ts @@ -2,14 +2,14 @@ import type { CDN } from '../models'; declare const globalThis: { appCDN: CDN }; -const moduleCDNs: CDN[] = ['jspm', 'esm.sh', 'skypack']; +const moduleCDNs: CDN[] = ['esm.sh', 'skypack', 'jspm']; const npmCDNs: CDN[] = ['unpkg', 'jsdelivr', 'fastly.jsdelivr']; const ghCDNs: CDN[] = ['fastly.jsdelivr.gh', 'jsdelivr.gh', 'statically']; export const modulesService = { getModuleUrl: ( moduleName: string, - { isModule = true, defaultCDN = 'jspm' }: { isModule?: boolean; defaultCDN?: CDN } = {}, + { isModule = true, defaultCDN = 'esm.sh' }: { isModule?: boolean; defaultCDN?: CDN } = {}, ) => { moduleName = moduleName.replace(/#nobundle/g, ''); @@ -18,9 +18,7 @@ export const modulesService = { return moduleUrl; } - return isModule - ? 'https://jspm.dev/' + moduleName - : 'https://cdn.jsdelivr.net/npm/' + moduleName; + return isModule ? 'https://esm.sh/' + moduleName : 'https://cdn.jsdelivr.net/npm/' + moduleName; }, getUrl: (path: string, cdn?: CDN) => diff --git a/src/livecodes/templates/starter/preact-starter.ts b/src/livecodes/templates/starter/preact-starter.ts index 918df4792..491dd13a1 100644 --- a/src/livecodes/templates/starter/preact-starter.ts +++ b/src/livecodes/templates/starter/preact-starter.ts @@ -47,6 +47,8 @@ render(, document.body); stylesheets: [], scripts: [], cssPreset: '', - imports: {}, types: {}, + customSettings: { + defaultCDN: 'jspm', + }, }; diff --git a/src/livecodes/toolspane/test-imports.ts b/src/livecodes/toolspane/test-imports.ts index a25ebfe70..ac4be3328 100644 --- a/src/livecodes/toolspane/test-imports.ts +++ b/src/livecodes/toolspane/test-imports.ts @@ -1,6 +1,7 @@ import { chaiUrl, vendorsBaseUrl } from '../vendors'; export const testImports = { + react: 'https://esm.sh/react?dev', '@testing-library/dom': vendorsBaseUrl + '@testing-library/dom.js', '@testing-library/jest-dom': vendorsBaseUrl + '@testing-library/jest-dom.js', '@testing-library/react': vendorsBaseUrl + '@testing-library/react.js', From f797f0f20fa3aa370f870bb57983987811133702 Mon Sep 17 00:00:00 2001 From: Hatem Hosny Date: Wed, 17 Jan 2024 22:45:26 +0200 Subject: [PATCH 2/3] fix tests --- src/livecodes/compiler/__tests__/import-map.spec.ts | 6 +++--- src/livecodes/services/__tests__/modulesService.spec.ts | 8 ++++---- src/livecodes/services/modules.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/livecodes/compiler/__tests__/import-map.spec.ts b/src/livecodes/compiler/__tests__/import-map.spec.ts index 2f638efd1..b2d961679 100644 --- a/src/livecodes/compiler/__tests__/import-map.spec.ts +++ b/src/livecodes/compiler/__tests__/import-map.spec.ts @@ -29,10 +29,10 @@ describe('Import map', () => { `; const importMap = { - '@codemirror/basic-setup': 'https://jspm.dev/@codemirror/basic-setup', + '@codemirror/basic-setup': 'https://esm.sh/@codemirror/basic-setup', lodash: 'https://unpkg.com/lodash', mylib: 'https://someurl/path/module', - similar2: 'https://jspm.dev/similar2', + similar2: 'https://esm.sh/similar2', }; const map = createImportMap(code, config); @@ -60,7 +60,7 @@ describe('Import map', () => { `; const expectedCode = ` - import { EditorState, EditorView, basicSetup } from 'https://jspm.dev/@codemirror/basic-setup'; + import { EditorState, EditorView, basicSetup } from 'https://esm.sh/@codemirror/basic-setup'; import fp from "https://unpkg.com/lodash/fp.js"; import { html } from 'http://localhost/@codemirror/lang-html'; import { flatten } from 'https://cdn.jsdelivr.net/gh/remeda/remeda@master/src/flatten.js'; diff --git a/src/livecodes/services/__tests__/modulesService.spec.ts b/src/livecodes/services/__tests__/modulesService.spec.ts index 14cea0cdc..42b96379a 100644 --- a/src/livecodes/services/__tests__/modulesService.spec.ts +++ b/src/livecodes/services/__tests__/modulesService.spec.ts @@ -4,17 +4,17 @@ describe('modulesService', () => { test('CDN urls', () => { const url = modulesService.getModuleUrl; - expect(url('uuid')).toEqual('https://jspm.dev/uuid'); + expect(url('uuid')).toEqual('https://esm.sh/uuid'); - expect(url('uuid@1.0.0')).toEqual('https://jspm.dev/uuid@1.0.0'); + expect(url('uuid@1.0.0')).toEqual('https://esm.sh/uuid@1.0.0'); expect(url('uuid@1.0.0/sub/directory/file.js')).toEqual( - 'https://jspm.dev/uuid@1.0.0/sub/directory/file.js', + 'https://esm.sh/uuid@1.0.0/sub/directory/file.js', ); expect(url('jspm:uuid')).toEqual('https://jspm.dev/uuid'); - expect(url('npm:uuid')).toEqual('https://jspm.dev/uuid'); + expect(url('npm:uuid')).toEqual('https://esm.sh/uuid'); expect(url('skypack:uuid')).toEqual('https://cdn.skypack.dev/uuid'); diff --git a/src/livecodes/services/modules.ts b/src/livecodes/services/modules.ts index 19ce0e157..8e26d9091 100644 --- a/src/livecodes/services/modules.ts +++ b/src/livecodes/services/modules.ts @@ -74,9 +74,9 @@ const getCdnUrl = (modName: string, isModule: boolean, defaultCDN?: CDN) => { const TEMPLATES: Array<[RegExp, string]> = [ [/^(jspm:)(.+)/i, 'https://jspm.dev/$2'], - [/^(npm:)(.+)/i, 'https://jspm.dev/$2'], + [/^(npm:)(.+)/i, 'https://esm.sh/$2'], - [/^(node:)(.+)/i, 'https://jspm.dev/$2'], + [/^(node:)(.+)/i, 'https://esm.sh/$2'], [/^(skypack:)(.+)/i, 'https://cdn.skypack.dev/$2'], From ef037aa2c5228b08c7e3ac612a2968786a3acab0 Mon Sep 17 00:00:00 2001 From: Hatem Hosny Date: Thu, 18 Jan 2024 00:16:40 +0200 Subject: [PATCH 3/3] release: v20 --- CHANGELOG.md | 30 ++++++++++++++---------------- package.json | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e01e20a6f..ad916bf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,38 +4,36 @@ All notable changes to this project will be documented in this file. See [standa --- -## [sdk-v0.4.0](https://github.com/live-codes/livecodes/compare/v19...sdk-v0.4.0) (2024-01-17) - +## [v20](https://github.com/live-codes/livecodes/compare/v19...v20) (2024-01-17) ### Features -* **Editor:** support editor themes ([7eaafeb](https://github.com/live-codes/livecodes/commit/7eaafeb325164186e9c05af57ad255a554c6b909)) -* **SDK:** add `getPlaygroundUrl` function to SDK ([ef2105b](https://github.com/live-codes/livecodes/commit/ef2105bb773c09cf8e361a630e9b3e829256f44f)) -* **SDK:** update options on changing props in react sdk ([0544540](https://github.com/live-codes/livecodes/commit/054454025d6ac9a605afc502f23120f4ba3f72da)) -* **SDK:** update options on changing props in vue sdk ([04c8ae8](https://github.com/live-codes/livecodes/commit/04c8ae89e65c606c8715c53cc81cce7b4ebbcd17)) -* **UI:** add buttons for project info and custom settings in editor toolbar ([e92a4f6](https://github.com/live-codes/livecodes/commit/e92a4f6924152730cc1294dcaf3fad3ffd628385)) -* **UI:** add editor settings button to editor toolbar ([213cfc9](https://github.com/live-codes/livecodes/commit/213cfc955704a040b7bc4335e79380878804b328)) +- **Editor:** support editor themes ([7eaafeb](https://github.com/live-codes/livecodes/commit/7eaafeb325164186e9c05af57ad255a554c6b909)) +- **UI:** add buttons for project info and custom settings in editor toolbar ([e92a4f6](https://github.com/live-codes/livecodes/commit/e92a4f6924152730cc1294dcaf3fad3ffd628385)) +- **UI:** add editor settings button to editor toolbar ([213cfc9](https://github.com/live-codes/livecodes/commit/213cfc955704a040b7bc4335e79380878804b328)) +--- +## [sdk-v0.4.0](https://github.com/live-codes/livecodes/compare/sdk-v0.3.0...sdk-v0.4.0) (2024-01-17) +### Features + +- **SDK:** add `getPlaygroundUrl` function to SDK ([ef2105b](https://github.com/live-codes/livecodes/commit/ef2105bb773c09cf8e361a630e9b3e829256f44f)) +- **SDK:** update options on changing props in react sdk ([0544540](https://github.com/live-codes/livecodes/commit/054454025d6ac9a605afc502f23120f4ba3f72da)) +- **SDK:** update options on changing props in vue sdk ([04c8ae8](https://github.com/live-codes/livecodes/commit/04c8ae89e65c606c8715c53cc81cce7b4ebbcd17)) --- ## [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)) - +- **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)) - - - +- **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)) --- diff --git a/package.json b/package.json index 6be709889..778b047cf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "livecodes", "version": "0.0.0", - "appVersion": "19", + "appVersion": "20", "description": "Code Playground That Just Works!", "author": "Hatem Hosny", "license": "MIT",