-
-
Notifications
You must be signed in to change notification settings - Fork 248
Add support for Ripple (WIP) #865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
cc813f0
bb8c04f
f0c18a7
16eeddb
085b3a3
cd0045b
b7a457c
1dd4f75
3324ef9
a6c6cce
4a8b37d
2c88177
6d65af0
813cbdd
db6a670
24df424
f3702a7
28387b9
20f8def
20a473d
ffffb1a
dfe0702
abd3e58
dbfe2e1
e62a259
28592cd
ffbdbfc
f9c3b47
ce7fea3
e2d6cea
0c0b60e
05d6552
b2cf421
b324074
224bdac
bea5b56
ec6838b
fc56a41
00683e9
a8ee0a9
6d5f6d3
765861f
0c1e45f
bba104d
7881b06
0887ab8
defbe25
d420059
56805b0
6848574
eb71c13
a57b44a
264033e
b10c3c3
544dea0
971330a
35d6186
6885b11
0d1a869
b0ecd9b
3126c4f
ddb54e9
0bed5bb
16d57df
fafc9a2
2b71b23
75b7334
b91d192
a0df890
39b67f4
3b4c76d
efdea7e
2234dc2
a7f817f
4894b33
0413d21
6b00d82
5a0d428
d530d30
fee8369
d8ba8a5
35de26b
8bf2be9
2404bed
7eb2056
dca57b7
4513aa7
7a6fe48
1ff714e
550c7cc
902a78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './lang-ripple'; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { LanguageSpecs } from '../../models'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { rippleUrl } from '../../vendors'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { parserPlugins } from '../prettier'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ripple: LanguageSpecs = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'ripple', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: 'Ripple', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| info: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parser: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'babel-ts', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pluginUrls: [parserPlugins.babel, parserPlugins.html], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compiler: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| factory: async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: convert to UMD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { compile } = await import(rippleUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return async (code) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!code.trim()) return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { js, css } = await compile(code, './src/App.ripple'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const cssCode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| css === '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : `\n\nconst styles = document.createElement('style');\nstyles.innerHTML = ${JSON.stringify(css)};\ndocument.head.appendChild(styles);\n`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `${js.code}${cssCode}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add compiler.imports, guard imports, and surface compile errors.
compiler: {
- factory: async () => {
+ factory: async () => {
// TODO: convert to UMD
- const { compile } = await import(rippleUrl);
+ const { compile } = await import(rippleUrl);
return async (code) => {
- if (!code.trim()) return '';
- const { js, css } = await compile(code, './src/App.ripple');
+ if (!code.trim()) return "export default () => null;";
+ try {
+ const { js, css } = await compile(code, './src/App.ripple');
const cssCode =
- css === ''
- ? ''
- : `\n\nconst styles = document.createElement('style');\nstyles.innerHTML = ${JSON.stringify(css)};\ndocument.head.appendChild(styles);\n`;
- return `${js.code}${cssCode}`;
+ css === ''
+ ? ''
+ : `\n\n(function(){const id='lc-ripple-style';let s=document.getElementById(id);if(!s){s=document.createElement('style');s.id=id;document.head.appendChild(s);}s.textContent=${JSON.stringify(
+ css,
+ )};})();`;
+ return `${js.code}${cssCode}`;
+ } catch (err) {
+ console.error('[ripple] compile error:', err);
+ throw err;
+ }
};
},
+ imports: { ripple: rippleModuleUrl },
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| extensions: ['ripple'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| editor: 'script', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| editorLanguage: 'typescript', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| export const rippleRuntime = ` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { mount } from 'ripple'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import App from "./script"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| (() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| mount(App, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| target: document.querySelector("#livecodes-app") || document.body.appendChild(document.createElement('div')), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| })(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainMake runtime resilient to non-default exports from compiled script. If the Ripple compiler doesn’t emit a default export, -export const rippleRuntime = `
-import { mount } from 'ripple';
-import App from "./script";
-(() => {
- mount(App, {
- target: document.querySelector("#livecodes-app") || document.body.appendChild(document.createElement('div')),
- });
-})();
-`;
+export const rippleRuntime = `
+import { mount } from 'ripple';
+import * as AppModule from "./script";
+(() => {
+ const App = AppModule.default || AppModule.App || AppModule;
+ const target =
+ document.querySelector("#livecodes-app") ||
+ (() => { const el = document.createElement('div'); el.id = 'livecodes-app'; return document.body.appendChild(el); })();
+ mount(App, { target });
+})();
+`;🏁 Script executed: #!/bin/bash
# List all files under the Ripple language integration directory
fd src/livecodes/languages/ripple -t f
# Locate any compiler or codegen files in that directory
fd compile src/livecodes/languages/ripple -t f
# Search for default export patterns in the ripple language code
rg -n "export default" src/livecodes/languages/ripple
# Search for named export patterns (const/function/class) in the same directory
rg -n "export (const|function|class) " src/livecodes/languages/rippleLength of output: 812 🏁 Script executed: #!/bin/bash
sed -n '1,200p' src/livecodes/languages/ripple/ripple-runtime.tsLength of output: 308 🏁 Script executed: #!/bin/bash
# Preview the first 200 lines of the Ripple language spec to see how compiled script is generated
sed -n '1,200p' src/livecodes/languages/ripple/lang-ripple.tsLength of output: 1003 Use namespace import with export fallbacks and assign File: src/livecodes/languages/ripple/ripple-runtime.ts -export const rippleRuntime = `
-import { mount } from 'ripple';
-import App from "./script";
-(() => {
- mount(App, {
- target: document.querySelector("#livecodes-app") || document.body.appendChild(document.createElement('div')),
- });
-})();
-`;
+export const rippleRuntime = `
+import { mount } from 'ripple';
+import * as AppModule from "./script";
+(() => {
+ const App = AppModule.default || AppModule.App || AppModule;
+ const target =
+ document.querySelector("#livecodes-app") ||
+ (() => {
+ const el = document.createElement('div');
+ el.id = 'livecodes-app';
+ return document.body.appendChild(el);
+ })();
+ mount(App, { target });
+})();
+`;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { | |
| import { cssPresets, getLanguageCompiler, getLanguageExtension } from '../languages'; | ||
| import { reactRuntime } from '../languages/jsx/react-runtime'; | ||
| import { reactNativeRuntime } from '../languages/react-native/react-native-runtime'; | ||
| import { rippleRuntime } from '../languages/ripple/ripple-runtime'; | ||
| import { solidRuntime } from '../languages/solid/solid-runtime'; | ||
| import { hasCustomJsxRuntime } from '../languages/typescript'; | ||
| import type { Cache, CompileInfo, Config, EditorId, Language } from '../models'; | ||
|
|
@@ -210,6 +211,7 @@ export const createResultPage = async ({ | |
| 'react-native-tsx': reactNativeRuntime, | ||
| solid: solidRuntime, | ||
| 'solid.tsx': solidRuntime, | ||
| ripple: rippleRuntime, | ||
| }; | ||
|
Comment on lines
+221
to
222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainEnsure Ripple runtime dependency is version-pinned in import map
🏁 Script executed: #!/bin/bash
# Locate the result-page.ts file
FILE=$(fd result-page.ts)
echo "Found file: $FILE"
# Show lines around the snippet (200–240)
sed -n '200,240p' "$FILE"
# Search for any compiler.imports usage across TypeScript files
rg -n "compiler\.imports" -g '*.ts'
# Search for import map or importMap references
rg -n "importMap" -g '*.ts'
rg -n "import map" -g '*.ts'Length of output: 5400 🏁 Script executed: #!/bin/bash
# Find ripple compiler file under languages directory
fd -g "*ripple*" -t f src/livecodes/languagesLength of output: 142 🏁 Script executed: #!/bin/bash
# Show Ripple language compiler implementation
sed -n '1,200p' src/livecodes/languages/ripple/lang-ripple.tsLength of output: 1003 Add pinned Ripple runtime import in ripple language spec imports: { ripple: rippleUrl },so that 🤖 Prompt for AI Agents |
||
| const jsxRuntime = jsxRuntimes[code.script.language] || ''; | ||
| const reactImport = | ||
|
|
@@ -439,7 +441,7 @@ export const createResultPage = async ({ | |
| } | ||
| } | ||
|
|
||
| // React JSX runtime | ||
| // JSX runtime | ||
| if (shouldInsertJsxRuntime) { | ||
| const jsxRuntimeScript = dom.createElement('script'); | ||
| jsxRuntimeScript.type = 'module'; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -389,6 +389,8 @@ export const resetCssUrl = /* @__PURE__ */ getUrl('reset-css@5.0.1/reset.css'); | |
|
|
||
| export const riotBaseUrl = /* @__PURE__ */ getUrl('riot@9.2.2/'); | ||
|
|
||
| export const rippleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5/compiler'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainPin Ripple runtime to the same version as the compiler to avoid skew Compiler is pinned to ripple@0.2.5, but runtime imports resolve "ripple" via generic import maps, which may pull a different version. Add a pinned module URL to use in the Ripple language spec Apply this diff here and reference it from the Ripple language spec: export const riotBaseUrl = /* @__PURE__ */ getUrl('riot@9.2.2/');
-export const rippleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5/compiler');
+export const rippleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5/compiler');
+export const rippleModuleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5');Then, in import { rippleUrl, rippleModuleUrl } from '../../vendors';
compiler: {
factory: async () => { /* unchanged */ },
imports: { ripple: rippleModuleUrl },
},🌐 Web query: 💡 Result: Short answer: No — I couldn't find any evidence that a package named "ripple" at version 0.2.5 exposes an ESM entry "ripple@0.2.5/compiler" that exports a compile function, nor that the documented runtime API is import { mount } from 'ripple'. Evidence:
If you want me to check a specific npm package tarball or the exact contents of ripple@0.2.5 (e.g. via unpkg or npm pack) I can fetch and list the package files to confirm. Citations:
🏁 Script executed: #!/bin/bash
set -e
# List files in ripple@0.2.5 npm package
echo "Listing files in ripple@0.2.5 package..."
curl -sL https://registry.npmjs.org/ripple/-/ripple-0.2.5.tgz | tar -tz > ripple-files.txt
echo -e "\nFiles containing 'compiler':"
grep -R 'compiler' ripple-files.txt || echo "(none found)"
echo -e "\nShowing package.json (first 200 lines):"
curl -sL https://registry.npmjs.org/ripple/-/ripple-0.2.5.tgz | tar -xzO package/package.json | sed -n '1,200p'Length of output: 2560 🏁 Script executed: #!/bin/bash
set -e
# Verify if the compiler entry exports a `compile` function
echo "Checking compiler exports for 'compile':"
curl -sL https://registry.npmjs.org/ripple/-/ripple-0.2.5.tgz \
| tar -xzO package/src/compiler/index.js \
| grep -E "export (async )?function compile|export { compile"
# List all top-level exports in the runtime entry
echo -e "\nListing exports in runtime index:"
curl -sL https://registry.npmjs.org/ripple/-/ripple-0.2.5.tgz \
| tar -xzO package/src/runtime/index.js \
| grep -E "export "
# Search for any `mount` export or usage in the runtime entry
echo -e "\nSearching for 'mount' in runtime index:"
curl -sL https://registry.npmjs.org/ripple/-/ripple-0.2.5.tgz \
| tar -xzO package/src/runtime/index.js \
| grep -R "mount"Length of output: 4193 Pin Ripple runtime URL to v0.2.5 and update Ripple language spec export const rippleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5/compiler');
+export const rippleModuleUrl = /* @__PURE__ */ getModuleUrl('ripple@0.2.5');Then in import { rippleUrl, rippleModuleUrl } from '../../vendors';
compiler: {
factory: async () => { /* unchanged */ },
imports: { ripple: rippleModuleUrl },
},🤖 Prompt for AI Agents |
||
|
|
||
| export const rubyWasmBaseUrl = /* @__PURE__ */ getUrl('@ruby/3.3-wasm-wasi@2.6.2/dist/'); | ||
|
|
||
| export const rubyWasmScriptUrl = /* @__PURE__ */ getUrl( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid empty module when editor content is blank.
Returning
''yields a module with no exports; the runtime import then fails. Emit a tiny no-op component instead.📝 Committable suggestion
🤖 Prompt for AI Agents