Skip to content
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

Slintpad standalone #2877

Merged
merged 2 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions tools/slintpad/package.json
@@ -1,5 +1,5 @@
{
"//": "cSpell: ignore lumino dragdrop frsource ",
"//": "cSpell: ignore codingame dragdrop frsource lumino ",
"name": "slintpad",
"version": "1.0.3",
"description": "",
Expand All @@ -19,7 +19,8 @@
"test:cypress_run-chromium": "cypress run --browser=chromium --e2e",
"test:cypress_open-chromium": "cypress open --browser=chromium --e2e",
"test:cypress_run-ff": "cypress run --browser=firefox --e2e",
"test:cypress_open-ff": "cypress open --browser=firefox --e2e"
"test:cypress_open-ff": "cypress open --browser=firefox --e2e",
"slintpad:prepublish": "npm run build:wasm_lsp-release && npm run build:wasm_preview-release"
},
"keywords": [],
"author": "",
Expand Down
5 changes: 3 additions & 2 deletions tools/slintpad/src/editor_widget.ts
@@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

// cSpell: ignore lumino inmemory mimetypes printerdemo
// cSpell: ignore edcore lumino inmemory mimetypes printerdemo
//
import "monaco-editor/esm/vs/editor/edcore.main.js";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
Expand Down Expand Up @@ -849,7 +849,8 @@ export class EditorWidget extends Widget {

async set_demo(location: string) {
if (location) {
let tag = "master";
const default_tag = "XXXX_DEFAULT_TAG_XXXX";
let tag = default_tag.startsWith("XXXX_DEFAULT_TAG_") ? "master" : default_tag;
{
let found;
if (
Expand Down
52 changes: 10 additions & 42 deletions tools/slintpad/vite.config.ts
@@ -1,15 +1,12 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

// TODO: Do build and package wasm-lsp separately. Right now vite does not
// support `exclude` in web workers!

// cSpell: ignore iife lumino
// cSpell: ignore lumino

import { defineConfig, UserConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";

export default defineConfig(({ command }) => {
export default defineConfig(() => {
const base_config: UserConfig = {
server: {
fs: {
Expand All @@ -28,7 +25,14 @@ export default defineConfig(({ command }) => {
},
},
},
resolve: {},
resolve: {
alias: {
"@lsp/": "../../../lsp/pkg/",
"@preview/": "../../../api/wasm-interpreter/pkg/",
"~@lumino": "node_modules/@lumino/", // work around strange defaults in @lumino
path: "path-browserify", // To make path.sep available to monaco
},
},
plugins: [
VitePWA({
registerType: "autoUpdate",
Expand All @@ -50,41 +54,5 @@ export default defineConfig(({ command }) => {
],
};

const global_aliases = {
"@lsp/": "../../../lsp/pkg/",
"~@lumino": "node_modules/@lumino/", // work around strange defaults in @lumino
path: "path-browserify", // To make path.sep available to monaco
};

if (command === "serve") {
// For development builds, serve the wasm interpreter straight out of the local file system.
base_config.resolve = {
alias: {
"@preview/": "../../../api/wasm-interpreter/pkg/",
...global_aliases,
},
};
} else {
// For distribution builds,
// assume deployment on the main website where the loading file (index.js) is in the assets/
// sub-directory and the relative path to the interpreter is as below.
if (base_config.build == null) {
base_config.build = {};
}
base_config.build.rollupOptions = {
makeAbsoluteExternalsRelative: true,
external: [
"../../../../wasm-interpreter/slint_wasm_interpreter.js",
],
...base_config.build.rollupOptions,
};
base_config.resolve = {
alias: {
"@preview/": "../../../../wasm-interpreter/",
...global_aliases,
},
};
}

return base_config as UserConfig;
});