From a880ad1c2ab6d4637e0f433cbde62122c3cae451 Mon Sep 17 00:00:00 2001
From: berekuk
Date: Fri, 12 Jan 2024 16:21:01 +0000
Subject: [PATCH 1/6] Bump versions after 0.9.2 release
---
.changeset/next-release.md | 7 ++
packages/components/package.json | 2 +-
packages/prettier-plugin/package.json | 2 +-
packages/squiggle-lang/package.json | 2 +-
packages/squiggle-lang/src/library/version.ts | 2 +-
packages/textmate-grammar/package.json | 2 +-
packages/versioned-components/package.json | 3 +-
.../src/VersionedSquiggleChart.tsx | 7 +-
.../src/VersionedSquigglePlayground.tsx | 6 +-
packages/versioned-components/src/versions.ts | 10 +-
packages/vscode-ext/package.json | 2 +-
pnpm-lock.yaml | 94 +++++++++++++++++++
12 files changed, 125 insertions(+), 14 deletions(-)
create mode 100644 .changeset/next-release.md
diff --git a/.changeset/next-release.md b/.changeset/next-release.md
new file mode 100644
index 0000000000..1be7119dcb
--- /dev/null
+++ b/.changeset/next-release.md
@@ -0,0 +1,7 @@
+---
+"@quri/squiggle-lang": patch
+"@quri/squiggle-components": patch
+"@quri/prettier-plugin-squiggle": patch
+"@quri/squiggle-textmate-grammar": patch
+"vscode-squiggle": patch
+---
diff --git a/packages/components/package.json b/packages/components/package.json
index e46e5f28fb..e32c5953ac 100644
--- a/packages/components/package.json
+++ b/packages/components/package.json
@@ -1,6 +1,6 @@
{
"name": "@quri/squiggle-components",
- "version": "0.9.2",
+ "version": "0.9.3-0",
"license": "MIT",
"repository": {
"type": "git",
diff --git a/packages/prettier-plugin/package.json b/packages/prettier-plugin/package.json
index 79acc8cbdb..214bb8761a 100644
--- a/packages/prettier-plugin/package.json
+++ b/packages/prettier-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@quri/prettier-plugin-squiggle",
- "version": "0.9.2",
+ "version": "0.9.3-0",
"license": "MIT",
"homepage": "https://squiggle-language.com",
"author": "Quantified Uncertainty Research Institute",
diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json
index d4b76fc853..52a34883ca 100644
--- a/packages/squiggle-lang/package.json
+++ b/packages/squiggle-lang/package.json
@@ -1,6 +1,6 @@
{
"name": "@quri/squiggle-lang",
- "version": "0.9.2",
+ "version": "0.9.3-0",
"license": "MIT",
"homepage": "https://squiggle-language.com",
"author": "Quantified Uncertainty Research Institute",
diff --git a/packages/squiggle-lang/src/library/version.ts b/packages/squiggle-lang/src/library/version.ts
index 268f0f3bab..0403752188 100644
--- a/packages/squiggle-lang/src/library/version.ts
+++ b/packages/squiggle-lang/src/library/version.ts
@@ -2,7 +2,7 @@ import { ImmutableMap } from "../utility/immutableMap.js";
import { Value, vString } from "../value/index.js";
// automatically updated on release by ops/ patch-js utils
-const VERSION = "0.9.2";
+const VERSION = "0.9.3-0";
export function makeVersionConstant(): ImmutableMap {
return ImmutableMap([["System.version", vString(VERSION)]]);
}
diff --git a/packages/textmate-grammar/package.json b/packages/textmate-grammar/package.json
index 55db7e9dfe..54324a8459 100644
--- a/packages/textmate-grammar/package.json
+++ b/packages/textmate-grammar/package.json
@@ -1,6 +1,6 @@
{
"name": "@quri/squiggle-textmate-grammar",
- "version": "0.9.2",
+ "version": "0.9.3-0",
"scripts": {
"build": "mkdir -p dist && js-yaml src/squiggle.tmLanguage.yaml >dist/squiggle.tmLanguage.json && js-yaml src/squiggle.js.yaml >dist/squiggle.js.json",
"lint": "prettier --check .",
diff --git a/packages/versioned-components/package.json b/packages/versioned-components/package.json
index b1d9520bca..fdd5b42a93 100644
--- a/packages/versioned-components/package.json
+++ b/packages/versioned-components/package.json
@@ -19,7 +19,8 @@
"lodash": "^4.17.21",
"squiggle-components-0.8.5": "npm:@quri/squiggle-components@0.8.5",
"squiggle-components-0.8.6": "npm:@quri/squiggle-components@0.8.6",
- "squiggle-components-0.9.0": "npm:@quri/squiggle-components@0.9.0"
+ "squiggle-components-0.9.0": "npm:@quri/squiggle-components@0.9.0",
+ "squiggle-components-0.9.2": "npm:@quri/squiggle-components@0.9.2"
},
"devDependencies": {
"@quri/configs": "workspace:*",
diff --git a/packages/versioned-components/src/VersionedSquiggleChart.tsx b/packages/versioned-components/src/VersionedSquiggleChart.tsx
index 6a6ab861e9..b6bdfc6e8d 100644
--- a/packages/versioned-components/src/VersionedSquiggleChart.tsx
+++ b/packages/versioned-components/src/VersionedSquiggleChart.tsx
@@ -6,17 +6,18 @@ import { FC, lazy, Suspense } from "react";
* It's edited with babel transformation in `publish-all.ts` script.
*/
import { type SquiggleChartProps as SquiggleChartProps_0_9_0 } from "squiggle-components-0.9.0";
-
+import { type SquiggleChartProps as SquiggleChartProps_0_9_2 } from "squiggle-components-0.9.2";
import { type SquiggleChartProps as SquiggleChartProps_dev } from "@quri/squiggle-components";
-
import { LazyVersionedComponents, VersionedComponentProps } from "./types.js";
import { SquiggleVersion } from "./versions.js";
-
type SquiggleChartVersion = Exclude;
const componentByVersion = {
"0.9.0": lazy(async () => ({
default: (await import("squiggle-components-0.9.0")).SquiggleChart,
})) as FC,
+ "0.9.2": lazy(async () => ({
+ default: (await import("squiggle-components-0.9.2")).SquiggleChart,
+ })) as FC,
dev: lazy(async () => ({
default: (await import("@quri/squiggle-components")).SquiggleChart,
})) as FC,
diff --git a/packages/versioned-components/src/VersionedSquigglePlayground.tsx b/packages/versioned-components/src/VersionedSquigglePlayground.tsx
index b0d9219c9a..c63372e399 100644
--- a/packages/versioned-components/src/VersionedSquigglePlayground.tsx
+++ b/packages/versioned-components/src/VersionedSquigglePlayground.tsx
@@ -6,7 +6,7 @@ import { FC, lazy, Suspense } from "react";
* It's edited with babel transformation in `publish-all.ts` script.
*/
import { type SquigglePlaygroundProps as SquigglePlaygroundProps_0_9_0 } from "squiggle-components-0.9.0";
-
+import { type SquigglePlaygroundProps as SquigglePlaygroundProps_0_9_2 } from "squiggle-components-0.9.2";
import { type SquigglePlaygroundProps as SquigglePlaygroundProps_dev } from "@quri/squiggle-components";
/*
@@ -21,7 +21,6 @@ import {
SquigglePlaygroundProps_0_8_6,
} from "./oldPlaygroundTypes.js";
import { LazyVersionedComponents, VersionedComponentProps } from "./types.js";
-
const componentByVersion = {
"0.8.5": lazy(async () => ({
default: (await import("squiggle-components-0.8.5")).SquigglePlayground,
@@ -32,6 +31,9 @@ const componentByVersion = {
"0.9.0": lazy(async () => ({
default: (await import("squiggle-components-0.9.0")).SquigglePlayground,
})) as FC,
+ "0.9.2": lazy(async () => ({
+ default: (await import("squiggle-components-0.9.2")).SquigglePlayground,
+ })) as FC,
dev: lazy(async () => ({
default: (await import("@quri/squiggle-components")).SquigglePlayground,
})) as FC,
diff --git a/packages/versioned-components/src/versions.ts b/packages/versioned-components/src/versions.ts
index 9ddb606650..f7ec545548 100644
--- a/packages/versioned-components/src/versions.ts
+++ b/packages/versioned-components/src/versions.ts
@@ -1,9 +1,15 @@
// auto-generated by `publish-all.ts`, don't touch
-export const squiggleVersions = ["0.9.0", "0.8.6", "0.8.5", "dev"] as const;
+export const squiggleVersions = [
+ "0.9.2",
+ "0.9.0",
+ "0.8.6",
+ "0.8.5",
+ "dev",
+] as const;
export type SquiggleVersion = (typeof squiggleVersions)[number];
// auto-generated by `publish-all.ts`, don't touch
-export const defaultSquiggleVersion: SquiggleVersion = "0.9.0";
+export const defaultSquiggleVersion: SquiggleVersion = "0.9.2";
export function checkSquiggleVersion(
version: string
): version is SquiggleVersion {
diff --git a/packages/vscode-ext/package.json b/packages/vscode-ext/package.json
index 2ce72876c5..7dbd9b9df2 100644
--- a/packages/vscode-ext/package.json
+++ b/packages/vscode-ext/package.json
@@ -3,7 +3,7 @@
"displayName": "Squiggle",
"description": "Squiggle language support",
"license": "MIT",
- "version": "0.9.2",
+ "version": "0.9.3-0",
"private": true,
"publisher": "QURI",
"repository": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5a5c7070fd..a60091ab76 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -797,6 +797,9 @@ importers:
squiggle-components-0.9.0:
specifier: npm:@quri/squiggle-components@0.9.0
version: /@quri/squiggle-components@0.9.0(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)(tailwindcss@3.4.0)
+ squiggle-components-0.9.2:
+ specifier: npm:@quri/squiggle-components@0.9.2
+ version: /@quri/squiggle-components@0.9.2(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)(tailwindcss@3.4.0)
devDependencies:
'@quri/configs':
specifier: workspace:*
@@ -4974,6 +4977,13 @@ packages:
prettier: 3.1.1
dev: false
+ /@quri/prettier-plugin-squiggle@0.9.2:
+ resolution: {integrity: sha512-lPx+Mm7Il3GwdeXN87VrSSENyfogxbKJ1kPIuCC+JH11wi34bGF8QJGstaW79EeB2j2hRRwSJ2BCzAqRS4fX5A==}
+ dependencies:
+ '@quri/squiggle-lang': 0.9.2
+ prettier: 3.1.1
+ dev: false
+
/@quri/squiggle-components@0.8.5(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)(tailwindcss@3.4.0):
resolution: {integrity: sha512-X7GYjZoLtITgUcoFx8isfHZhzK0f6b6Gks0TfGLwQ1BnJvP5OtOI0r+lj+mYjS38Z12M3KjX6VuWX6hgCsJskQ==}
peerDependencies:
@@ -5106,6 +5116,53 @@ packages:
- tailwindcss
dev: false
+ /@quri/squiggle-components@0.9.2(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)(tailwindcss@3.4.0):
+ resolution: {integrity: sha512-470n18raKe7PGm7SOlCxAlENiNRMRTRHYpvoGXtygpW62f4Y8xwYdZ63+EmF0drBL3sdmd1fLPxtvmwRiNKHwQ==}
+ peerDependencies:
+ react: ^16.8.0 || ^17 || ^18
+ react-dom: ^16.8.0 || ^17 || ^18
+ dependencies:
+ '@codemirror/autocomplete': 6.11.1(@codemirror/language@6.10.0)(@codemirror/state@6.4.0)(@codemirror/view@6.23.0)(@lezer/common@1.2.0)
+ '@codemirror/commands': 6.3.3
+ '@codemirror/language': 6.10.0
+ '@codemirror/lint': 6.4.2
+ '@codemirror/search': 6.5.5
+ '@codemirror/state': 6.4.0
+ '@codemirror/theme-one-dark': 6.1.2
+ '@codemirror/view': 6.23.0
+ '@floating-ui/react': 0.26.3(react-dom@18.2.0)(react@18.2.0)
+ '@heroicons/react': 1.0.6(react@18.2.0)
+ '@hookform/resolvers': 3.3.3(react-hook-form@7.49.2)
+ '@lezer/common': 1.2.0
+ '@quri/prettier-plugin-squiggle': 0.9.2
+ '@quri/squiggle-lang': 0.9.2
+ '@quri/squiggle-textmate-grammar': 0.9.2
+ '@quri/ui': 0.2.1(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)
+ '@react-hook/size': 2.1.2(react@18.2.0)
+ '@tailwindcss/typography': 0.5.10(tailwindcss@3.4.0)
+ clsx: 2.1.0
+ codemirror: 6.0.1(@lezer/common@1.2.0)
+ d3: 7.8.5
+ framer-motion: 10.16.16(react-dom@18.2.0)(react@18.2.0)
+ lodash: 4.17.21
+ mermaid: 10.6.1
+ prettier: 3.1.1
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
+ react-draggable: 4.4.6(react-dom@18.2.0)(react@18.2.0)
+ react-hook-form: 7.49.2(react@18.2.0)
+ react-markdown: 9.0.1(@types/react@18.2.46)(react@18.2.0)
+ remark-gfm: 4.0.0
+ shikiji: 0.9.15
+ unist-util-visit: 5.0.0
+ unist-util-visit-parents: 6.0.1
+ zod: 3.22.4
+ transitivePeerDependencies:
+ - '@types/react'
+ - supports-color
+ - tailwindcss
+ dev: false
+
/@quri/squiggle-lang@0.8.5:
resolution: {integrity: sha512-ymA/Y/3C8pppvYFy9RhpJyCjjttJPm+pWu1gWpaOFOs53qP61+GpGw0qtkduO0t2wYdj/3GDlQC/JyyxZMAOGw==}
hasBin: true
@@ -5142,6 +5199,22 @@ packages:
open: 9.1.0
dev: false
+ /@quri/squiggle-lang@0.9.2:
+ resolution: {integrity: sha512-R+aiPKr+070S7C6J6Xf/KdGj4uA855CpQgJnsL+Vij5lC0Y5BjzsQZR+mwm8qb7f9rp88CM1642Ei+qQ0qiEPw==}
+ hasBin: true
+ dependencies:
+ '@commander-js/extra-typings': 11.1.0(commander@11.1.0)
+ commander: 11.1.0
+ immutable: 4.3.4
+ jstat: 1.9.6
+ lodash: 4.17.21
+ open: 10.0.2
+ dev: false
+
+ /@quri/squiggle-textmate-grammar@0.9.2:
+ resolution: {integrity: sha512-wY9f4AOM1QP2FN81LDirgohVPjtcjyDGVivB3SbVCwYTL3bjDqBMPAGyZlmLM6z53jMBAMPf3GixKJ+ldEUHlQ==}
+ dev: false
+
/@quri/ui@0.1.4(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-aUAhpRN7gc4T8Tyk3Eg9ubC57QItlUEQSYi/XSgBu2Ghcc5Hoje5eKc/AKIvhvotCuwO/TbafSVq5HjNoojufQ==}
peerDependencies:
@@ -5205,6 +5278,27 @@ packages:
- '@types/react'
dev: false
+ /@quri/ui@0.2.1(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-8qvCiRM7LWmTmq6InnOKXHGbziutbEI33dX4QKD9gtLOmGhViEmFXXqqrrkKxT+xcv8V1Ff9rDICwJ4mP28ong==}
+ peerDependencies:
+ react: ^17 || ^18
+ react-dom: ^17 || ^18
+ dependencies:
+ '@floating-ui/react': 0.26.3(react-dom@18.2.0)(react@18.2.0)
+ '@headlessui/react': 1.7.17(react-dom@18.2.0)(react@18.2.0)
+ clsx: 2.1.0
+ framer-motion: 10.16.16(react-dom@18.2.0)(react@18.2.0)
+ react: 18.2.0
+ react-colorful: 5.6.1(react-dom@18.2.0)(react@18.2.0)
+ react-dom: 18.2.0(react@18.2.0)
+ react-hook-form: 7.49.2(react@18.2.0)
+ react-select: 5.8.0(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)
+ react-textarea-autosize: 8.5.3(@types/react@18.2.46)(react@18.2.0)
+ react-use: 17.4.2(react-dom@18.2.0)(react@18.2.0)
+ transitivePeerDependencies:
+ - '@types/react'
+ dev: false
+
/@radix-ui/number@1.0.1:
resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==}
dependencies:
From 622d75143de1e5e2ed2851d8f7a66835266ebe44 Mon Sep 17 00:00:00 2001
From: Vyacheslav Matyukhin
Date: Fri, 12 Jan 2024 12:07:15 -0600
Subject: [PATCH 2/6] hub supports 0.9.2; CompositeGuard checks in
versioned-components
---
packages/hub/package.json | 1 +
.../[slug]/EditSquiggleSnippetModel.tsx | 4 +-
.../SquiggleModelExportPage.tsx | 40 ++++++++++++--
packages/versioned-components/src/versions.ts | 54 ++++++++++++++-----
pnpm-lock.yaml | 3 ++
5 files changed, 83 insertions(+), 19 deletions(-)
diff --git a/packages/hub/package.json b/packages/hub/package.json
index b7df00258a..d909032eba 100644
--- a/packages/hub/package.json
+++ b/packages/hub/package.json
@@ -56,6 +56,7 @@
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.0",
"squiggle-lang-0.9.0": "npm:@quri/squiggle-lang@0.9.0",
+ "squiggle-lang-0.9.2": "npm:@quri/squiggle-lang@0.9.2",
"zod": "^3.22.4"
},
"devDependencies": {
diff --git a/packages/hub/src/app/models/[owner]/[slug]/EditSquiggleSnippetModel.tsx b/packages/hub/src/app/models/[owner]/[slug]/EditSquiggleSnippetModel.tsx
index 4c093d4fc4..90c49d769c 100644
--- a/packages/hub/src/app/models/[owner]/[slug]/EditSquiggleSnippetModel.tsx
+++ b/packages/hub/src/app/models/[owner]/[slug]/EditSquiggleSnippetModel.tsx
@@ -355,7 +355,7 @@ export const EditSquiggleSnippetModel: FC = ({
* (In this simple case, we could always set `renderExtraDropdownItems` prop since it'd be ignored by older playground versions.)
* It relies on `versionSupportsDropdownMenu` type predicate which narrows down `playgroundProps` type.
*/
- if (versionSupportsDropdownMenu(playgroundProps)) {
+ if (versionSupportsDropdownMenu.props(playgroundProps)) {
playgroundProps.renderExtraDropdownItems = ({ openModal }) =>
model.isEditable ? (
<>
@@ -369,7 +369,7 @@ export const EditSquiggleSnippetModel: FC = ({
) : null;
}
- if (versionSupportsExports(playgroundProps)) {
+ if (versionSupportsExports.props(playgroundProps)) {
playgroundProps.onExportsChange = (exports) => {
form.setValue("exports", exports);
};
diff --git a/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx b/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
index 7bbf4c8420..4876cd2dd7 100644
--- a/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
+++ b/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
@@ -2,11 +2,13 @@
import { FC, useState } from "react";
import { graphql, useFragment } from "react-relay";
import * as squiggleLang_0_9_0 from "squiggle-lang-0.9.0";
+import * as squiggleLang_0_9_2 from "squiggle-lang-0.9.2";
import * as squiggleLang_dev from "@quri/squiggle-lang";
import {
useAdjustSquiggleVersion,
VersionedSquiggleChart,
+ versionSupportsExports,
} from "@quri/versioned-squiggle-components";
import { squiggleHubLinker } from "@/squiggle/components/linker";
@@ -18,7 +20,7 @@ type SquiggleProps = {
code: string;
};
-const SquiggleModelExportPage_9_0_0: FC = ({
+const SquiggleModelExportPage_0_9_0: FC = ({
variableName,
code,
}) => {
@@ -43,6 +45,31 @@ const SquiggleModelExportPage_9_0_0: FC = ({
);
};
+const SquiggleModelExportPage_0_9_2: FC = ({
+ variableName,
+ code,
+}) => {
+ const [{ project, rootPath }] = useState(() => {
+ const project = new squiggleLang_0_9_2.SqProject({
+ linker: squiggleHubLinker,
+ });
+ const rootPath = new squiggleLang_0_9_2.SqValuePath({
+ root: "bindings",
+ items: [{ type: "string", value: variableName }],
+ });
+ return { project, rootPath };
+ });
+
+ return (
+
+ );
+};
+
const SquiggleModelExportPage_dev: FC = ({
variableName,
code,
@@ -85,7 +112,7 @@ export const SquiggleModelExportPage: FC<{
const checkedVersion = useAdjustSquiggleVersion(content.version);
- if (checkedVersion === "0.8.5" || checkedVersion === "0.8.6") {
+ if (!versionSupportsExports.plain(checkedVersion)) {
return (
Export view pages don't support Squiggle {checkedVersion}.
@@ -96,7 +123,14 @@ export const SquiggleModelExportPage: FC<{
switch (checkedVersion) {
case "0.9.0":
return (
-
+ );
+ case "0.9.2":
+ return (
+
diff --git a/packages/versioned-components/src/versions.ts b/packages/versioned-components/src/versions.ts
index f7ec545548..fe35ec4fe2 100644
--- a/packages/versioned-components/src/versions.ts
+++ b/packages/versioned-components/src/versions.ts
@@ -15,20 +15,46 @@ export function checkSquiggleVersion(
): version is SquiggleVersion {
return (squiggleVersions as readonly string[]).includes(version);
}
-function excludeVersions
(skipVersions: T) {
- const guard = <
- Arg extends {
- version: SquiggleVersion;
- },
- >(
- arg: Arg
- ): arg is Extract<
- Arg,
- {
- version: Exclude;
- }
- > => !skipVersions.includes(arg.version);
- return guard;
+
+// We need two kinds of guards:
+// 1) `guard.plain(version)`, to check the version string
+// 2) `guard.props({ version: ... })`, to check and narrow the props that we're going to use and incrementally update the props
+// The following code is a bit complicated, because it optimizes for easily adding new guards.
+
+type VersionGuard = (
+ version: SquiggleVersion
+) => version is AllowedSquiggleVersion;
+
+type VersionedPropsGuard = <
+ Arg extends { version: SquiggleVersion },
+>(
+ arg: Arg
+) => arg is Extract;
+
+type CompositeGuard = {
+ plain: VersionGuard;
+ props: VersionedPropsGuard;
+};
+
+function excludeVersions<
+ T extends SquiggleVersion[],
+ AllowedSquiggleVersion extends SquiggleVersion = Exclude<
+ SquiggleVersion,
+ T[number]
+ >,
+>(skipVersions: T): CompositeGuard {
+ const plainGuard = ((version) =>
+ !skipVersions.includes(version)) as VersionGuard;
+
+ const propsGuard = ((arg) =>
+ !skipVersions.includes(
+ arg.version
+ )) as VersionedPropsGuard;
+
+ return {
+ plain: plainGuard,
+ props: propsGuard,
+ };
}
/*
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a60091ab76..66850c086e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -408,6 +408,9 @@ importers:
squiggle-lang-0.9.0:
specifier: npm:@quri/squiggle-lang@0.9.0
version: /@quri/squiggle-lang@0.9.0
+ squiggle-lang-0.9.2:
+ specifier: npm:@quri/squiggle-lang@0.9.2
+ version: /@quri/squiggle-lang@0.9.2
zod:
specifier: ^3.22.4
version: 3.22.4
From 2cd0f0d0a933f4dccbd95e841701301d20508ee9 Mon Sep 17 00:00:00 2001
From: Vyacheslav Matyukhin
Date: Fri, 12 Jan 2024 12:31:56 -0600
Subject: [PATCH 3/6] split /admin/ pages
---
packages/hub/src/app/admin/AdminPage.tsx | 44 -------------------
packages/hub/src/app/admin/layout.tsx | 35 +++++++++++++++
packages/hub/src/app/admin/page.tsx | 37 +++-------------
.../UpgradeVersionsPage.tsx} | 35 ++++++++-------
.../src/app/admin/upgrade-versions/page.tsx | 20 +++++++++
5 files changed, 81 insertions(+), 90 deletions(-)
delete mode 100644 packages/hub/src/app/admin/AdminPage.tsx
create mode 100644 packages/hub/src/app/admin/layout.tsx
rename packages/hub/src/app/admin/{UpgradeModels.tsx => upgrade-versions/UpgradeVersionsPage.tsx} (77%)
create mode 100644 packages/hub/src/app/admin/upgrade-versions/page.tsx
diff --git a/packages/hub/src/app/admin/AdminPage.tsx b/packages/hub/src/app/admin/AdminPage.tsx
deleted file mode 100644
index de8f90ac1a..0000000000
--- a/packages/hub/src/app/admin/AdminPage.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-import { useSession } from "next-auth/react";
-import { FC } from "react";
-import { graphql } from "relay-runtime";
-
-import { LockIcon } from "@quri/ui";
-
-import { H1 } from "@/components/ui/Headers";
-import { SerializablePreloadedQuery } from "@/relay/loadPageQuery";
-import { usePageQuery } from "@/relay/usePageQuery";
-
-import { RebuildSearchIndex } from "./RebuildSearchIndex";
-import { UpgradeModels } from "./UpgradeModels";
-
-import { AdminPageQuery } from "@/__generated__/AdminPageQuery.graphql";
-
-const Query = graphql`
- query AdminPageQuery {
- ...UpgradeModels
- }
-`;
-
-export const AdminPage: FC<{
- query: SerializablePreloadedQuery;
-}> = ({ query }) => {
- useSession({ required: true });
-
- const [queryRef] = usePageQuery(Query, query);
-
- return (
-
-
-
-
- Admin console
-
-
-
-
-
-
-
- );
-};
diff --git a/packages/hub/src/app/admin/layout.tsx b/packages/hub/src/app/admin/layout.tsx
new file mode 100644
index 0000000000..75fc0582c2
--- /dev/null
+++ b/packages/hub/src/app/admin/layout.tsx
@@ -0,0 +1,35 @@
+import { getServerSession } from "next-auth";
+import { PropsWithChildren } from "react";
+
+import { LockIcon } from "@quri/ui";
+
+import { FullLayoutWithPadding } from "@/components/layout/FullLayoutWithPadding";
+import { NarrowPageLayout } from "@/components/layout/NarrowPageLayout";
+import { H1 } from "@/components/ui/Headers";
+
+import { authOptions } from "../api/auth/[...nextauth]/authOptions";
+
+export default async function AdminLayout({ children }: PropsWithChildren) {
+ const session = await getServerSession(authOptions);
+
+ const email = session?.user.email;
+
+ const { ROOT_EMAILS } = process.env;
+ if (!email || !ROOT_EMAILS?.includes(email)) {
+ return Access denied.;
+ }
+
+ return (
+
+
+
+
+
+ Admin console
+
+
+
+
{children}
+
+ );
+}
diff --git a/packages/hub/src/app/admin/page.tsx b/packages/hub/src/app/admin/page.tsx
index 0810207f90..5298d01b01 100644
--- a/packages/hub/src/app/admin/page.tsx
+++ b/packages/hub/src/app/admin/page.tsx
@@ -1,39 +1,16 @@
import { Metadata } from "next";
-import { getServerSession } from "next-auth";
-import { FC } from "react";
-import { FullLayoutWithPadding } from "@/components/layout/FullLayoutWithPadding";
-import { NarrowPageLayout } from "@/components/layout/NarrowPageLayout";
-import { loadPageQuery } from "@/relay/loadPageQuery";
+import { StyledLink } from "@/components/ui/StyledLink";
-import { authOptions } from "../api/auth/[...nextauth]/authOptions";
-import { AdminPage } from "./AdminPage";
-
-import QueryNode, {
- AdminPageQuery,
-} from "@/__generated__/AdminPageQuery.graphql";
-
-const OuterAdminPageAuthenticated: FC = async () => {
- const query = await loadPageQuery(QueryNode, {});
+export default async function OuterAdminPage() {
+ // permissions are checked in ./layout.tsx
return (
-
-
-
+
+ Search
+ Upgrade versions
+
);
-};
-
-export default async function OuterAdminPage() {
- const session = await getServerSession(authOptions);
-
- const email = session?.user.email;
-
- const { ROOT_EMAILS } = process.env;
- if (!email || !ROOT_EMAILS?.includes(email)) {
- return Access denied.;
- }
-
- return ;
}
export const metadata: Metadata = {
diff --git a/packages/hub/src/app/admin/UpgradeModels.tsx b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
similarity index 77%
rename from packages/hub/src/app/admin/UpgradeModels.tsx
rename to packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
index f3f0ee782b..7126071bf4 100644
--- a/packages/hub/src/app/admin/UpgradeModels.tsx
+++ b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
@@ -1,3 +1,4 @@
+"use client";
import { FC, useState } from "react";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
@@ -8,20 +9,22 @@ import { defaultSquiggleVersion } from "@quri/versioned-squiggle-components";
import { H2 } from "@/components/ui/Headers";
import { MutationButton } from "@/components/ui/MutationButton";
import { StyledLink } from "@/components/ui/StyledLink";
+import { SerializablePreloadedQuery } from "@/relay/loadPageQuery";
+import { usePageQuery } from "@/relay/usePageQuery";
import { modelRoute } from "@/routes";
-import { EditSquiggleSnippetModel } from "../models/[owner]/[slug]/EditSquiggleSnippetModel";
+import { EditSquiggleSnippetModel } from "../../models/[owner]/[slug]/EditSquiggleSnippetModel";
-import { UpgradeModels$key } from "@/__generated__/UpgradeModels.graphql";
-import { UpgradeModels_List$key } from "@/__generated__/UpgradeModels_List.graphql";
-import { UpgradeModels_updateMutation } from "@/__generated__/UpgradeModels_updateMutation.graphql";
+import { UpgradeVersionsPage_List$key } from "@/__generated__/UpgradeVersionsPage_List.graphql";
+import { UpgradeVersionsPage_updateMutation } from "@/__generated__/UpgradeVersionsPage_updateMutation.graphql";
+import { UpgradeVersionsPageQuery } from "@/__generated__/UpgradeVersionsPageQuery.graphql";
-const ModelList: FC<{ modelsRef: UpgradeModels_List$key }> = ({
+const ModelList: FC<{ modelsRef: UpgradeVersionsPage_List$key }> = ({
modelsRef,
}) => {
const models = useFragment(
graphql`
- fragment UpgradeModels_List on Model @relay(plural: true) {
+ fragment UpgradeVersionsPage_List on Model @relay(plural: true) {
id
slug
owner {
@@ -55,12 +58,12 @@ const ModelList: FC<{ modelsRef: UpgradeModels_List$key }> = ({
expectedTypename="AdminUpdateModelVersionResult"
mutation={graphql`
- mutation UpgradeModels_updateMutation(
+ mutation UpgradeVersionsPage_updateMutation(
$input: MutationAdminUpdateModelVersionInput!
) {
result: adminUpdateModelVersion(input: $input) {
@@ -108,23 +111,23 @@ const ModelList: FC<{ modelsRef: UpgradeModels_List$key }> = ({
);
};
-export const UpgradeModels: FC<{
- queryRef: UpgradeModels$key;
-}> = ({ queryRef }) => {
- const { modelsByVersion } = useFragment(
+export const UpgradeVersionsPage: FC<{
+ query: SerializablePreloadedQuery;
+}> = ({ query }) => {
+ const [{ modelsByVersion }] = usePageQuery(
graphql`
- fragment UpgradeModels on Query {
+ query UpgradeVersionsPageQuery {
modelsByVersion {
version
count
privateCount
models {
- ...UpgradeModels_List
+ ...UpgradeVersionsPage_List
}
}
}
`,
- queryRef
+ query
);
return (
@@ -139,7 +142,7 @@ export const UpgradeModels: FC<{
{`Code edits won't be saved, "Upgrade" button bumps only the model's version.`}
-
+
{modelsByVersion.map((entry) => {
if (
entry.version === "dev" ||
diff --git a/packages/hub/src/app/admin/upgrade-versions/page.tsx b/packages/hub/src/app/admin/upgrade-versions/page.tsx
new file mode 100644
index 0000000000..64291265e5
--- /dev/null
+++ b/packages/hub/src/app/admin/upgrade-versions/page.tsx
@@ -0,0 +1,20 @@
+import { Metadata } from "next";
+
+import { loadPageQuery } from "@/relay/loadPageQuery";
+
+import { UpgradeVersionsPage } from "./UpgradeVersionsPage";
+
+import QueryNode, {
+ UpgradeVersionsPageQuery,
+} from "@/__generated__/UpgradeVersionsPageQuery.graphql";
+
+export default async function OuterUpgradeVersionsPage() {
+ // permissions are checked in ./layout.tsx
+ const query = await loadPageQuery
(QueryNode, {});
+
+ return ;
+}
+
+export const metadata: Metadata = {
+ title: "Admin",
+};
From 2ee99098b6f6c3d5665966218133ca44ae41bea0 Mon Sep 17 00:00:00 2001
From: Vyacheslav Matyukhin
Date: Fri, 12 Jan 2024 13:45:26 -0600
Subject: [PATCH 4/6] upgrade page ui
---
.../upgrade-versions/UpgradeVersionsPage.tsx | 101 +++++++++++++-----
1 file changed, 73 insertions(+), 28 deletions(-)
diff --git a/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
index 7126071bf4..666a004e2a 100644
--- a/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
+++ b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
@@ -3,7 +3,12 @@ import { FC, useState } from "react";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
-import { Button } from "@quri/ui";
+import {
+ Button,
+ Dropdown,
+ DropdownMenu,
+ DropdownMenuActionItem,
+} from "@quri/ui";
import { defaultSquiggleVersion } from "@quri/versioned-squiggle-components";
import { H2 } from "@/components/ui/Headers";
@@ -114,6 +119,7 @@ const ModelList: FC<{ modelsRef: UpgradeVersionsPage_List$key }> = ({
export const UpgradeVersionsPage: FC<{
query: SerializablePreloadedQuery;
}> = ({ query }) => {
+ // TODO - this fetches all models even if we show just one, can we optimize it?
const [{ modelsByVersion }] = usePageQuery(
graphql`
query UpgradeVersionsPageQuery {
@@ -130,37 +136,76 @@ export const UpgradeVersionsPage: FC<{
query
);
+ type Entry = (typeof upgradeableModelsByVersion)[number];
+
+ const upgradeableModelsByVersion = modelsByVersion.filter(
+ (entry) =>
+ entry.version !== "dev" && entry.version !== defaultSquiggleVersion
+ );
+
+ const [selectedVersion, setSelectedVersion] = useState(
+ upgradeableModelsByVersion.at(0)?.version
+ );
+
+ const getEntryTitle = (entry: Entry) =>
+ `${entry.version} (${entry.count} models, ${entry.privateCount} private)`;
+
+ const getEntryByVersion = (version: string): Entry | undefined =>
+ modelsByVersion.find((entry) => entry.version === version);
+
+ const selectedEntry = selectedVersion
+ ? getEntryByVersion(selectedVersion)
+ : undefined;
+
+ const devCount = getEntryByVersion("dev")?.models.length ?? 0;
+ const latestCount =
+ getEntryByVersion(defaultSquiggleVersion)?.models.length ?? 0;
+
return (
Upgrade model versions
-
- Check models with their current version and the new version, then press
- the upgrade button if everything is ok.
-
-
-
- {`Code edits won't be saved, "Upgrade" button bumps only the model's version.`}
-
-
-
- {modelsByVersion.map((entry) => {
- if (
- entry.version === "dev" ||
- entry.version === defaultSquiggleVersion
- ) {
- return null;
- }
- return (
-
-
- {entry.version} ({entry.count} models, {entry.privateCount}{" "}
- private models)
-
-
-
- );
- })}
+
+
+ Check models with their current version and the new version, then
+ press the upgrade button if everything is ok.
+
+
+
+ {`Code edits won't be saved, "Upgrade" button bumps only the model's version.`}
+
+
+
+
+
Dev models: {devCount}
+
+ {defaultSquiggleVersion} models: {latestCount}
+
+
+
+ (
+
+ {upgradeableModelsByVersion.map((entry) => {
+ return (
+ {
+ setSelectedVersion(entry.version);
+ close();
+ }}
+ />
+ );
+ })}
+
+ )}
+ >
+
+
+ {selectedEntry ?
: null}
);
};
From a84e9a7134f9bb39dce6e1068366193d04596317 Mon Sep 17 00:00:00 2001
From: Vyacheslav Matyukhin
Date: Fri, 12 Jan 2024 15:26:00 -0600
Subject: [PATCH 5/6] squiggleLangByVersion, new compare view in
/admin/upgrade-models
---
packages/hub/package.json | 2 -
.../upgrade-versions/UpgradeVersionsPage.tsx | 96 ++++++++++++++--
.../SquiggleModelExportPage.tsx | 108 ++++--------------
packages/versioned-components/package.json | 5 +
.../src/VersionedSquiggleChart.tsx | 4 +
.../src/VersionedSquigglePlayground.tsx | 5 +-
packages/versioned-components/src/index.ts | 3 +
.../src/squiggleLangByVersion.ts | 29 +++++
packages/versioned-components/src/versions.ts | 1 +
pnpm-lock.yaml | 15 +++
10 files changed, 171 insertions(+), 97 deletions(-)
create mode 100644 packages/versioned-components/src/squiggleLangByVersion.ts
diff --git a/packages/hub/package.json b/packages/hub/package.json
index d909032eba..70aa515f82 100644
--- a/packages/hub/package.json
+++ b/packages/hub/package.json
@@ -55,8 +55,6 @@
"relay-runtime": "^16.1.0",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.0",
- "squiggle-lang-0.9.0": "npm:@quri/squiggle-lang@0.9.0",
- "squiggle-lang-0.9.2": "npm:@quri/squiggle-lang@0.9.2",
"zod": "^3.22.4"
},
"devDependencies": {
diff --git a/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
index 666a004e2a..04f2e33f36 100644
--- a/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
+++ b/packages/hub/src/app/admin/upgrade-versions/UpgradeVersionsPage.tsx
@@ -1,5 +1,5 @@
"use client";
-import { FC, useState } from "react";
+import { FC, use, useState } from "react";
import { useFragment } from "react-relay";
import { graphql } from "relay-runtime";
@@ -9,21 +9,101 @@ import {
DropdownMenu,
DropdownMenuActionItem,
} from "@quri/ui";
-import { defaultSquiggleVersion } from "@quri/versioned-squiggle-components";
+import {
+ defaultSquiggleVersion,
+ squiggleLangByVersion,
+ useAdjustSquiggleVersion,
+ VersionedSquiggleChart,
+ versionSupportsSquiggleChart,
+} from "@quri/versioned-squiggle-components";
+import { EditSquiggleSnippetModel } from "@/app/models/[owner]/[slug]/EditSquiggleSnippetModel";
import { H2 } from "@/components/ui/Headers";
import { MutationButton } from "@/components/ui/MutationButton";
import { StyledLink } from "@/components/ui/StyledLink";
import { SerializablePreloadedQuery } from "@/relay/loadPageQuery";
import { usePageQuery } from "@/relay/usePageQuery";
import { modelRoute } from "@/routes";
-
-import { EditSquiggleSnippetModel } from "../../models/[owner]/[slug]/EditSquiggleSnippetModel";
+import { squiggleHubLinker } from "@/squiggle/components/linker";
import { UpgradeVersionsPage_List$key } from "@/__generated__/UpgradeVersionsPage_List.graphql";
+import { UpgradeVersionsPage_Model$key } from "@/__generated__/UpgradeVersionsPage_Model.graphql";
import { UpgradeVersionsPage_updateMutation } from "@/__generated__/UpgradeVersionsPage_updateMutation.graphql";
import { UpgradeVersionsPageQuery } from "@/__generated__/UpgradeVersionsPageQuery.graphql";
+const UpgradeableModel: FC<{ modelRef: UpgradeVersionsPage_Model$key }> = ({
+ modelRef,
+}) => {
+ const model = useFragment(
+ graphql`
+ fragment UpgradeVersionsPage_Model on Model {
+ id
+ currentRevision {
+ content {
+ __typename
+ ... on SquiggleSnippet {
+ id
+ code
+ version
+ }
+ }
+ }
+ ...EditSquiggleSnippetModel
+ }
+ `,
+ modelRef
+ );
+
+ const currentRevision = model.currentRevision;
+
+ if (currentRevision.content.__typename !== "SquiggleSnippet") {
+ throw new Error("Wrong content type");
+ }
+
+ const version = useAdjustSquiggleVersion(currentRevision.content.version);
+ const updatedVersion = defaultSquiggleVersion;
+
+ const squiggleLang = use(squiggleLangByVersion(version));
+ const updatedSquiggleLang = use(squiggleLangByVersion(updatedVersion));
+
+ const project = new squiggleLang.SqProject({
+ linker: squiggleHubLinker,
+ });
+ const updatedProject = new updatedSquiggleLang.SqProject({
+ linker: squiggleHubLinker,
+ });
+
+ if (versionSupportsSquiggleChart.plain(version)) {
+ const headerClasses = "py-1 px-2 m-1 bg-slate-200 font-medium";
+ return (
+
+
{version}
+
{updatedVersion}
+
+
+
+ );
+ } else {
+ return (
+
+ );
+ }
+};
+
const ModelList: FC<{ modelsRef: UpgradeVersionsPage_List$key }> = ({
modelsRef,
}) => {
@@ -36,7 +116,7 @@ const ModelList: FC<{ modelsRef: UpgradeVersionsPage_List$key }> = ({
id
slug
}
- ...EditSquiggleSnippetModel
+ ...UpgradeVersionsPage_Model
}
`,
modelsRef
@@ -107,11 +187,7 @@ const ModelList: FC<{ modelsRef: UpgradeVersionsPage_List$key }> = ({
Next →
-
+
);
};
diff --git a/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx b/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
index 4876cd2dd7..65ecc4587d 100644
--- a/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
+++ b/packages/hub/src/app/models/[owner]/[slug]/exports/[variableName]/SquiggleModelExportPage.tsx
@@ -1,11 +1,9 @@
"use client";
-import { FC, useState } from "react";
+import { FC, use, useState } from "react";
import { graphql, useFragment } from "react-relay";
-import * as squiggleLang_0_9_0 from "squiggle-lang-0.9.0";
-import * as squiggleLang_0_9_2 from "squiggle-lang-0.9.2";
-import * as squiggleLang_dev from "@quri/squiggle-lang";
import {
+ squiggleLangByVersion,
useAdjustSquiggleVersion,
VersionedSquiggleChart,
versionSupportsExports,
@@ -20,65 +18,24 @@ type SquiggleProps = {
code: string;
};
-const SquiggleModelExportPage_0_9_0: FC
= ({
- variableName,
- code,
-}) => {
- const [{ project, rootPath }] = useState(() => {
- const project = new squiggleLang_0_9_0.SqProject({
- linker: squiggleHubLinker,
- });
- const rootPath = new squiggleLang_0_9_0.SqValuePath({
- root: "bindings",
- items: [{ type: "string", value: variableName }],
- });
- return { project, rootPath };
- });
-
- return (
-
- );
-};
+// via https://github.com/microsoft/TypeScript/issues/30542#issuecomment-475646727
+type GuardedType = T extends (x: any) => x is infer T ? T : never;
-const SquiggleModelExportPage_0_9_2: FC = ({
- variableName,
- code,
-}) => {
- const [{ project, rootPath }] = useState(() => {
- const project = new squiggleLang_0_9_2.SqProject({
- linker: squiggleHubLinker,
- });
- const rootPath = new squiggleLang_0_9_2.SqValuePath({
- root: "bindings",
- items: [{ type: "string", value: variableName }],
- });
- return { project, rootPath };
- });
+type SupportedVersion = GuardedType<(typeof versionSupportsExports)["plain"]>;
- return (
-
- );
-};
+const VersionedSquiggleModelExportPage: FC<
+ SquiggleProps & {
+ version: SupportedVersion;
+ }
+> = ({ variableName, code, version }) => {
+ // `use` is still experimental in React, but this is Squiggle Hub which uses Next.js which uses canary React releases, so it's fine
+ const squiggleLang = use(squiggleLangByVersion(version));
-const SquiggleModelExportPage_dev: FC = ({
- variableName,
- code,
-}) => {
const [{ project, rootPath }] = useState(() => {
- const project = new squiggleLang_dev.SqProject({
+ const project = new squiggleLang.SqProject({
linker: squiggleHubLinker,
});
- const rootPath = new squiggleLang_dev.SqValuePath({
+ const rootPath = new squiggleLang.SqValuePath({
root: "bindings",
items: [{ type: "string", value: variableName }],
});
@@ -87,10 +44,11 @@ const SquiggleModelExportPage_dev: FC = ({
return (
);
};
@@ -120,29 +78,11 @@ export const SquiggleModelExportPage: FC<{
);
}
- switch (checkedVersion) {
- case "0.9.0":
- return (
-
- );
- case "0.9.2":
- return (
-
- );
- case "dev":
- return (
-
- );
- default:
- throw new Error(`Wrong version ${checkedVersion satisfies never}`);
- }
+ return (
+
+ );
};
diff --git a/packages/versioned-components/package.json b/packages/versioned-components/package.json
index fdd5b42a93..f94a1684a2 100644
--- a/packages/versioned-components/package.json
+++ b/packages/versioned-components/package.json
@@ -17,6 +17,11 @@
"@tailwindcss/typography": "^0.5.10",
"glob": "^10.3.10",
"lodash": "^4.17.21",
+ "@quri/squiggle-lang": "workspace:*",
+ "squiggle-lang-0.8.5": "npm:@quri/squiggle-lang@0.8.5",
+ "squiggle-lang-0.8.6": "npm:@quri/squiggle-lang@0.8.6",
+ "squiggle-lang-0.9.0": "npm:@quri/squiggle-lang@0.9.0",
+ "squiggle-lang-0.9.2": "npm:@quri/squiggle-lang@0.9.2",
"squiggle-components-0.8.5": "npm:@quri/squiggle-components@0.8.5",
"squiggle-components-0.8.6": "npm:@quri/squiggle-components@0.8.6",
"squiggle-components-0.9.0": "npm:@quri/squiggle-components@0.9.0",
diff --git a/packages/versioned-components/src/VersionedSquiggleChart.tsx b/packages/versioned-components/src/VersionedSquiggleChart.tsx
index b6bdfc6e8d..6e9307c234 100644
--- a/packages/versioned-components/src/VersionedSquiggleChart.tsx
+++ b/packages/versioned-components/src/VersionedSquiggleChart.tsx
@@ -7,9 +7,12 @@ import { FC, lazy, Suspense } from "react";
*/
import { type SquiggleChartProps as SquiggleChartProps_0_9_0 } from "squiggle-components-0.9.0";
import { type SquiggleChartProps as SquiggleChartProps_0_9_2 } from "squiggle-components-0.9.2";
+
import { type SquiggleChartProps as SquiggleChartProps_dev } from "@quri/squiggle-components";
+
import { LazyVersionedComponents, VersionedComponentProps } from "./types.js";
import { SquiggleVersion } from "./versions.js";
+
type SquiggleChartVersion = Exclude;
const componentByVersion = {
"0.9.0": lazy(async () => ({
@@ -26,6 +29,7 @@ type VersionedSquiggleChartProps = VersionedComponentProps<
typeof componentByVersion,
SquiggleChartVersion
>;
+
export const VersionedSquiggleChart: FC = ({
version,
...props
diff --git a/packages/versioned-components/src/VersionedSquigglePlayground.tsx b/packages/versioned-components/src/VersionedSquigglePlayground.tsx
index c63372e399..13d2d413e4 100644
--- a/packages/versioned-components/src/VersionedSquigglePlayground.tsx
+++ b/packages/versioned-components/src/VersionedSquigglePlayground.tsx
@@ -7,6 +7,7 @@ import { FC, lazy, Suspense } from "react";
*/
import { type SquigglePlaygroundProps as SquigglePlaygroundProps_0_9_0 } from "squiggle-components-0.9.0";
import { type SquigglePlaygroundProps as SquigglePlaygroundProps_0_9_2 } from "squiggle-components-0.9.2";
+
import { type SquigglePlaygroundProps as SquigglePlaygroundProps_dev } from "@quri/squiggle-components";
/*
@@ -21,7 +22,8 @@ import {
SquigglePlaygroundProps_0_8_6,
} from "./oldPlaygroundTypes.js";
import { LazyVersionedComponents, VersionedComponentProps } from "./types.js";
-const componentByVersion = {
+
+export const componentByVersion = {
"0.8.5": lazy(async () => ({
default: (await import("squiggle-components-0.8.5")).SquigglePlayground,
})) as FC,
@@ -38,6 +40,7 @@ const componentByVersion = {
default: (await import("@quri/squiggle-components")).SquigglePlayground,
})) as FC,
} as const satisfies LazyVersionedComponents;
+
type Props = VersionedComponentProps;
export const VersionedSquigglePlayground: FC = ({
version,
diff --git a/packages/versioned-components/src/index.ts b/packages/versioned-components/src/index.ts
index 08c21b2ccc..e9c58c3ace 100644
--- a/packages/versioned-components/src/index.ts
+++ b/packages/versioned-components/src/index.ts
@@ -10,6 +10,9 @@ export {
squiggleVersions,
versionSupportsDropdownMenu,
versionSupportsExports,
+ versionSupportsSquiggleChart,
} from "./versions.js";
export { useAdjustSquiggleVersion } from "./hooks.js";
+
+export { squiggleLangByVersion } from "./squiggleLangByVersion.js";
diff --git a/packages/versioned-components/src/squiggleLangByVersion.ts b/packages/versioned-components/src/squiggleLangByVersion.ts
new file mode 100644
index 0000000000..86217dd904
--- /dev/null
+++ b/packages/versioned-components/src/squiggleLangByVersion.ts
@@ -0,0 +1,29 @@
+import { SquiggleVersion } from "./versions.js";
+
+type PackageTypes = {
+ "0.8.5": Awaited;
+ "0.8.6": Awaited;
+ "0.9.0": Awaited;
+ "0.9.2": Awaited;
+ dev: Awaited;
+};
+
+export async function squiggleLangByVersion(
+ version: T
+): Promise {
+ // We do explicit casting of imports, but it shouldn't matter.
+ switch (version) {
+ case "0.8.5":
+ return (await import("squiggle-lang-0.8.5")) as PackageTypes[T];
+ case "0.8.6":
+ return (await import("squiggle-lang-0.8.6")) as PackageTypes[T];
+ case "0.9.0":
+ return (await import("squiggle-lang-0.9.0")) as PackageTypes[T];
+ case "0.9.2":
+ return (await import("squiggle-lang-0.9.2")) as PackageTypes[T];
+ case "dev":
+ return (await import("@quri/squiggle-lang")) as PackageTypes[T];
+ default:
+ throw new Error(`Unkonwn version ${version satisfies never}`);
+ }
+}
diff --git a/packages/versioned-components/src/versions.ts b/packages/versioned-components/src/versions.ts
index fe35ec4fe2..747b61498c 100644
--- a/packages/versioned-components/src/versions.ts
+++ b/packages/versioned-components/src/versions.ts
@@ -64,3 +64,4 @@ function excludeVersions<
*/
export const versionSupportsDropdownMenu = excludeVersions(["0.8.5"]);
export const versionSupportsExports = excludeVersions(["0.8.5", "0.8.6"]);
+export const versionSupportsSquiggleChart = excludeVersions(["0.8.5", "0.8.6"]);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 66850c086e..b7f5fd750f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -776,6 +776,9 @@ importers:
'@quri/squiggle-components':
specifier: workspace:*
version: link:../components
+ '@quri/squiggle-lang':
+ specifier: workspace:*
+ version: link:../squiggle-lang
'@quri/ui':
specifier: workspace:*
version: link:../ui
@@ -803,6 +806,18 @@ importers:
squiggle-components-0.9.2:
specifier: npm:@quri/squiggle-components@0.9.2
version: /@quri/squiggle-components@0.9.2(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0)(tailwindcss@3.4.0)
+ squiggle-lang-0.8.5:
+ specifier: npm:@quri/squiggle-lang@0.8.5
+ version: /@quri/squiggle-lang@0.8.5
+ squiggle-lang-0.8.6:
+ specifier: npm:@quri/squiggle-lang@0.8.6
+ version: /@quri/squiggle-lang@0.8.6
+ squiggle-lang-0.9.0:
+ specifier: npm:@quri/squiggle-lang@0.9.0
+ version: /@quri/squiggle-lang@0.9.0
+ squiggle-lang-0.9.2:
+ specifier: npm:@quri/squiggle-lang@0.9.2
+ version: /@quri/squiggle-lang@0.9.2
devDependencies:
'@quri/configs':
specifier: workspace:*
From 5be13ee12fb5f928cd49d15989cf7a26de115c91 Mon Sep 17 00:00:00 2001
From: Vyacheslav Matyukhin
Date: Fri, 12 Jan 2024 15:30:02 -0600
Subject: [PATCH 6/6] fix lock file
---
pnpm-lock.yaml | 6 ------
1 file changed, 6 deletions(-)
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b7f5fd750f..de4f635183 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -405,12 +405,6 @@ importers:
remark-gfm:
specifier: ^4.0.0
version: 4.0.0
- squiggle-lang-0.9.0:
- specifier: npm:@quri/squiggle-lang@0.9.0
- version: /@quri/squiggle-lang@0.9.0
- squiggle-lang-0.9.2:
- specifier: npm:@quri/squiggle-lang@0.9.2
- version: /@quri/squiggle-lang@0.9.2
zod:
specifier: ^3.22.4
version: 3.22.4