create-grist-widget 0.3.25 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-grist-widget.mjs +1 -1
- package/bin/grist-widget-deploy.mjs +92 -0
- package/examples/reads-demo/WidgetApp.tsx +2 -1
- package/examples/safe-parse/WidgetApp.tsx +2 -1
- package/examples/spreadsheet-grid/GristDataSheetGrid.tsx +1 -1
- package/examples/spreadsheet-grid/GristSchemaToolbar.tsx +4 -4
- package/manifest.json +2 -2
- package/package.json +3 -2
- package/{template/scripts → src}/deploy.mjs +14 -85
- package/template/.github/dependabot.yml +5 -4
- package/template/.github/workflows/deploy.yml +32 -11
- package/template/AGENTS.md +9 -8
- package/template/README.md +15 -12
- package/template/package.json +2 -1
- package/template/src/App.smoke.test.tsx +17 -0
- package/template/src/App.test.tsx +6 -13
- package/template/src/components/theme-provider.tsx +5 -229
- package/template/src/main.tsx +7 -53
- package/vendor/compose-example.mjs +7 -2
- package/template/src/components/grist-sdk-alerts.tsx +0 -80
- package/template/src/components/local-dev-notice.tsx +0 -55
- package/template/src/components/release-info.tsx +0 -111
- package/template/src/lib/showcase-routing.ts +0 -59
- package/template/src/lib/showcase-versions.ts +0 -63
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react"
|
|
2
|
-
|
|
3
|
-
import { parseShowcasePath } from "@/lib/showcase-routing"
|
|
4
|
-
|
|
5
|
-
// Used by ReleaseInfo, which needs the released-version list on every
|
|
6
|
-
// non-embedded, deployed URL. URLs are root-relative to wherever THIS
|
|
7
|
-
// deploy actually lives (derived from
|
|
8
|
-
// window.location.pathname via parseShowcasePath's hubPath), not hardcoded
|
|
9
|
-
// to the grist-widget-sdk monorepo's own showcase: a real scaffolded
|
|
10
|
-
// widget has its own versions.json and its own v<version>/ + dev/ dirs,
|
|
11
|
-
// and previously showed the monorepo's version history and links instead
|
|
12
|
-
// of its own (found live on a real scaffold's landing page).
|
|
13
|
-
function hubPath(): string {
|
|
14
|
-
const path = parseShowcasePath(window.location.pathname).hubPath
|
|
15
|
-
return path.endsWith("/") ? path : `${path}/`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type ReleasedVersion = {
|
|
19
|
-
version: string
|
|
20
|
-
publishedAt: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function versionsUrl(): string {
|
|
24
|
-
return `${hubPath()}versions.json`
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function devUrl(): string {
|
|
28
|
-
return `${hubPath()}dev/`
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function versionUrl(version: string): string {
|
|
32
|
-
return `${hubPath()}v${version}/`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function useVersions() {
|
|
36
|
-
const [versions, setVersions] = useState<ReleasedVersion[] | null>(null)
|
|
37
|
-
const [error, setError] = useState(false)
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
let cancelled = false
|
|
41
|
-
fetch(versionsUrl(), { cache: "no-store" })
|
|
42
|
-
.then((res) => (res.ok ? res.json() : Promise.reject(res)))
|
|
43
|
-
.then((data: ReleasedVersion[]) => {
|
|
44
|
-
if (!cancelled) setVersions(data)
|
|
45
|
-
})
|
|
46
|
-
.catch(() => {
|
|
47
|
-
if (!cancelled) setError(true)
|
|
48
|
-
})
|
|
49
|
-
return () => {
|
|
50
|
-
cancelled = true
|
|
51
|
-
}
|
|
52
|
-
}, [])
|
|
53
|
-
|
|
54
|
-
return { versions, error }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function formatDate(iso: string) {
|
|
58
|
-
return new Date(iso).toLocaleDateString(undefined, {
|
|
59
|
-
year: "numeric",
|
|
60
|
-
month: "short",
|
|
61
|
-
day: "numeric",
|
|
62
|
-
})
|
|
63
|
-
}
|