@open-slide/core 2.0.1 → 2.1.0
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/dist/{build-DOgOEZZA.js → build-COxfoC_P.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-hT1o6Jct.js → config-CNhYSo4C.js} +56 -3
- package/dist/{config-GMR1QUlM.d.ts → config-DHPbCCnt.d.ts} +1 -1
- package/dist/{dev-_YkLNJRt.js → dev-CujpTS3T.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/locale/index.d.ts +5 -2
- package/dist/locale/index.js +2 -2
- package/dist/{preview-pABcGTQh.js → preview-kU5R6QXJ.js} +1 -1
- package/dist/{types-BcbaKTNY.d.ts → types-BGUi9COY.d.ts} +1 -1
- package/dist/{update-moCkSyvg.js → update-CPBitJQq.js} +24 -14
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DlZoAc2-.js → zh-tw-BbFb4PZW.js} +519 -1
- package/package.json +3 -3
- package/skills/apply-comments/SKILL.md +1 -0
- package/skills/create-slide/SKILL.md +2 -0
- package/skills/current-slide/SKILL.md +1 -0
- package/skills/slide-authoring/SKILL.md +31 -1
- package/src/app/app.tsx +2 -0
- package/src/app/assets/open-slide.svg +39 -0
- package/src/app/components/command/command-menu.tsx +1 -3
- package/src/app/components/history-provider.tsx +25 -3
- package/src/app/components/inspector/inspector-provider.tsx +179 -21
- package/src/app/components/panel/editor-sidebar.tsx +1 -1
- package/src/app/components/panel/save-card.tsx +6 -2
- package/src/app/components/preview-step-host.tsx +16 -0
- package/src/app/components/sidebar/sidebar.tsx +2 -2
- package/src/app/components/slide-transition-layer.tsx +1 -1
- package/src/app/components/style-panel/style-panel.tsx +3 -2
- package/src/app/components/thumbnail-rail.tsx +37 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/favicon.svg +39 -0
- package/src/app/index.html +2 -1
- package/src/app/lib/keys.ts +3 -0
- package/src/app/lib/locale-store.ts +6 -1
- package/src/app/lib/print-ready.ts +9 -6
- package/src/app/routes/presenter.tsx +1 -16
- package/src/app/routes/preview.tsx +169 -0
- package/src/app/routes/slide.tsx +113 -65
- package/src/locale/es.ts +548 -0
- package/src/locale/index.ts +1 -0
- package/src/locale/types.ts +1 -1
- package/src/app/assets/open-slide.png +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as printHeader, t as createCliLogger } from "./cli/bin.js";
|
|
2
|
-
import { t as createViteConfig } from "./config-
|
|
2
|
+
import { t as createViteConfig } from "./config-CNhYSo4C.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { build as build$1, mergeConfig } from "vite";
|
|
5
5
|
//#region src/cli/build.ts
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as detectPackageManager } from "../update-
|
|
2
|
+
import { t as detectPackageManager } from "../update-CPBitJQq.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as readline from "node:readline/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -453,17 +453,17 @@ async function run(argv) {
|
|
|
453
453
|
program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").action(async (flags) => {
|
|
454
454
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
455
455
|
await assertViteResolvesToCore();
|
|
456
|
-
const { dev } = await import("../dev-
|
|
456
|
+
const { dev } = await import("../dev-CujpTS3T.js");
|
|
457
457
|
await dev(flags);
|
|
458
458
|
});
|
|
459
459
|
program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
460
460
|
await assertViteResolvesToCore();
|
|
461
|
-
const { build } = await import("../build-
|
|
461
|
+
const { build } = await import("../build-COxfoC_P.js");
|
|
462
462
|
await build(flags);
|
|
463
463
|
});
|
|
464
464
|
program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
|
|
465
465
|
await assertViteResolvesToCore();
|
|
466
|
-
const { preview } = await import("../preview-
|
|
466
|
+
const { preview } = await import("../preview-kU5R6QXJ.js");
|
|
467
467
|
await preview(flags);
|
|
468
468
|
});
|
|
469
469
|
program.command("sync:skills").description("Sync built-in skills from @open-slide/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as defaultDesign } from "./design-Cpqx7SJs.js";
|
|
2
|
-
import { C as reorderDefaultExportPagesInSource, D as updateMetaTitleInSource, E as rmSlideDir, O as validateSlideName, S as removePageFromDefaultExportInSource, T as resolveSlideEntry, _ as SLIDE_ID_RE, a as readBody, b as duplicateSlideDir, c as FOLDER_ID_RE, d as readManifest, f as validateIcon, g as shortId, h as writeManifest, i as makeContext, k as validateMutationRequest, l as foldersManifestPath, m as validateReorder, n as registerUpdateRoutes, o as readSlideSource, p as validateName, r as json, s as resolveSlideEntryPath, u as newFolderId, v as duplicateNotesElementInSource, w as reorderNotesArrayInSource, x as removeNotesElementInSource, y as duplicatePageInDefaultExportInSource } from "./update-
|
|
2
|
+
import { C as reorderDefaultExportPagesInSource, D as updateMetaTitleInSource, E as rmSlideDir, O as validateSlideName, S as removePageFromDefaultExportInSource, T as resolveSlideEntry, _ as SLIDE_ID_RE, a as readBody, b as duplicateSlideDir, c as FOLDER_ID_RE, d as readManifest, f as validateIcon, g as shortId, h as writeManifest, i as makeContext, k as validateMutationRequest, l as foldersManifestPath, m as validateReorder, n as registerUpdateRoutes, o as readSlideSource, p as validateName, r as json, s as resolveSlideEntryPath, u as newFolderId, v as duplicateNotesElementInSource, w as reorderNotesArrayInSource, x as removeNotesElementInSource, y as duplicatePageInDefaultExportInSource } from "./update-CPBitJQq.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import { parse } from "@babel/parser";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
@@ -3178,6 +3178,58 @@ async function loadUserConfig(userCwd) {
|
|
|
3178
3178
|
}, file, userCwd, "silent"))?.config ?? {};
|
|
3179
3179
|
}
|
|
3180
3180
|
//#endregion
|
|
3181
|
+
//#region src/vite/server-info-plugin.ts
|
|
3182
|
+
function serverInfoUrl(address, https, base) {
|
|
3183
|
+
let host = address.address === "::" || address.address === "0.0.0.0" ? "localhost" : address.address;
|
|
3184
|
+
if (host.includes(":")) host = `[${host}]`;
|
|
3185
|
+
const pathname = base.startsWith("/") ? base : "/";
|
|
3186
|
+
return `${https ? "https" : "http"}://${host}:${address.port}${pathname}`;
|
|
3187
|
+
}
|
|
3188
|
+
function serverInfoPlugin(opts) {
|
|
3189
|
+
const outDir = path.join(opts.userCwd, "node_modules", ".open-slide");
|
|
3190
|
+
const outFile = path.join(outDir, "server.json");
|
|
3191
|
+
return {
|
|
3192
|
+
name: "open-slide:server-info",
|
|
3193
|
+
apply: "serve",
|
|
3194
|
+
configureServer(server) {
|
|
3195
|
+
const httpServer = server.httpServer;
|
|
3196
|
+
if (!httpServer) return;
|
|
3197
|
+
let publication = Promise.resolve(null);
|
|
3198
|
+
httpServer.on("listening", () => {
|
|
3199
|
+
const address = httpServer.address();
|
|
3200
|
+
if (!address || typeof address === "string") return;
|
|
3201
|
+
const token = randomUUID();
|
|
3202
|
+
const body = {
|
|
3203
|
+
url: serverInfoUrl(address, Boolean(server.config.server.https), server.config.base),
|
|
3204
|
+
port: address.port,
|
|
3205
|
+
pid: process.pid,
|
|
3206
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3207
|
+
token
|
|
3208
|
+
};
|
|
3209
|
+
const tmpFile = `${outFile}.${token}.tmp`;
|
|
3210
|
+
publication = (async () => {
|
|
3211
|
+
try {
|
|
3212
|
+
await fs.mkdir(outDir, { recursive: true });
|
|
3213
|
+
await fs.writeFile(tmpFile, `${JSON.stringify(body, null, 2)}\n`, "utf8");
|
|
3214
|
+
await fs.rename(tmpFile, outFile);
|
|
3215
|
+
return token;
|
|
3216
|
+
} catch {
|
|
3217
|
+
await fs.rm(tmpFile, { force: true }).catch(() => {});
|
|
3218
|
+
return null;
|
|
3219
|
+
}
|
|
3220
|
+
})();
|
|
3221
|
+
});
|
|
3222
|
+
httpServer.on("close", async () => {
|
|
3223
|
+
const token = await publication;
|
|
3224
|
+
if (!token) return;
|
|
3225
|
+
try {
|
|
3226
|
+
if (JSON.parse(readFileSync(outFile, "utf8")).token === token) rmSync(outFile, { force: true });
|
|
3227
|
+
} catch {}
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
};
|
|
3231
|
+
}
|
|
3232
|
+
//#endregion
|
|
3181
3233
|
//#region src/vite/themes-plugin.ts
|
|
3182
3234
|
const THEMES_VMOD = "virtual:open-slide/themes";
|
|
3183
3235
|
function resolved(id) {
|
|
@@ -3386,7 +3438,8 @@ async function createViteConfig(opts) {
|
|
|
3386
3438
|
currentPlugin({
|
|
3387
3439
|
userCwd,
|
|
3388
3440
|
slidesDir
|
|
3389
|
-
})
|
|
3441
|
+
}),
|
|
3442
|
+
serverInfoPlugin({ userCwd })
|
|
3390
3443
|
],
|
|
3391
3444
|
resolve: {
|
|
3392
3445
|
alias: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as printUrls, i as printShortcutsHint, n as formatError, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
|
|
2
|
-
import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-
|
|
2
|
+
import { n as DEV_SUPERVISED_ENV, t as createViteConfig } from "./config-CNhYSo4C.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { fork } from "node:child_process";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as Plural, t as Locale } from "./types-
|
|
2
|
-
import { t as OpenSlideConfig } from "./config-
|
|
1
|
+
import { n as Plural, t as Locale } from "./types-BGUi9COY.js";
|
|
2
|
+
import { t as OpenSlideConfig } from "./config-DHPbCCnt.js";
|
|
3
3
|
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
4
4
|
//#region src/app/components/image-placeholder.d.ts
|
|
5
5
|
type ImagePlaceholderProps = {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "./zh-tw-BbFb4PZW.js";
|
|
2
2
|
import { n as defaultDesign, r as designToCssVars, t as cssVarsToString } from "./design-Cpqx7SJs.js";
|
|
3
3
|
import { Children, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { toast } from "sonner";
|
|
@@ -85,12 +85,13 @@ const LOCALES = {
|
|
|
85
85
|
en,
|
|
86
86
|
"zh-TW": zhTW,
|
|
87
87
|
"zh-CN": zhCN,
|
|
88
|
-
ja
|
|
88
|
+
ja,
|
|
89
|
+
es
|
|
89
90
|
};
|
|
90
91
|
const STORAGE_KEY = "open-slide:locale";
|
|
91
92
|
const configLocale = config.locale;
|
|
92
93
|
function isLocaleId(value) {
|
|
93
|
-
return value === "en" || value === "zh-TW" || value === "zh-CN" || value === "ja";
|
|
94
|
+
return value === "en" || value === "zh-TW" || value === "zh-CN" || value === "ja" || value === "es";
|
|
94
95
|
}
|
|
95
96
|
function readStored() {
|
|
96
97
|
try {
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { n as Plural, t as Locale } from "../types-
|
|
1
|
+
import { n as Plural, t as Locale } from "../types-BGUi9COY.js";
|
|
2
2
|
//#region src/locale/en.d.ts
|
|
3
3
|
declare const en: Locale;
|
|
4
4
|
//#endregion
|
|
5
|
+
//#region src/locale/es.d.ts
|
|
6
|
+
declare const es: Locale;
|
|
7
|
+
//#endregion
|
|
5
8
|
//#region src/locale/format.d.ts
|
|
6
9
|
declare function format(template: string, vars: Record<string, string | number>): string;
|
|
7
10
|
declare function plural(count: number, forms: Plural): string;
|
|
@@ -15,4 +18,4 @@ declare const zhCN: Locale;
|
|
|
15
18
|
//#region src/locale/zh-tw.d.ts
|
|
16
19
|
declare const zhTW: Locale;
|
|
17
20
|
//#endregion
|
|
18
|
-
export { type Locale, type Plural, en, format, ja, plural, zhCN, zhTW };
|
|
21
|
+
export { type Locale, type Plural, en, es, format, ja, plural, zhCN, zhTW };
|
package/dist/locale/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as en, i as es, n as zhCN, r as ja, t as zhTW } from "../zh-tw-BbFb4PZW.js";
|
|
2
2
|
//#region src/locale/format.ts
|
|
3
3
|
function format(template, vars) {
|
|
4
4
|
return template.replace(/\{(\w+)\}/g, (m, key) => {
|
|
@@ -10,4 +10,4 @@ function plural(count, forms) {
|
|
|
10
10
|
return count === 1 ? forms.one : forms.other;
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
|
-
export { en, format, ja, plural, zhCN, zhTW };
|
|
13
|
+
export { en, es, format, ja, plural, zhCN, zhTW };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as printUrls, i as printShortcutsHint, o as shortcutsEnabled, r as printHeader, s as startupDuration, t as createCliLogger } from "./cli/bin.js";
|
|
2
|
-
import { t as createViteConfig } from "./config-
|
|
2
|
+
import { t as createViteConfig } from "./config-CNhYSo4C.js";
|
|
3
3
|
import { mergeConfig, preview as preview$1 } from "vite";
|
|
4
4
|
//#region src/cli/preview.ts
|
|
5
5
|
async function preview(opts = {}) {
|
|
@@ -68,6 +68,21 @@ function validateMutationRequest(req, opts = {}) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/editing/slide-ops.ts
|
|
70
70
|
const SLIDE_ID_RE = /^[a-z0-9_-]+$/i;
|
|
71
|
+
/**
|
|
72
|
+
* True when a directory under root already uses this id, including a
|
|
73
|
+
* different case. ext4 keeps `Cover` and `cover` as two folders; macOS
|
|
74
|
+
* and Windows usually collapse them. Listing names catches both.
|
|
75
|
+
*/
|
|
76
|
+
async function slideIdTaken(root, slideId) {
|
|
77
|
+
let names;
|
|
78
|
+
try {
|
|
79
|
+
names = await fs.readdir(root);
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const want = slideId.toLowerCase();
|
|
84
|
+
return names.some((name) => name.toLowerCase() === want);
|
|
85
|
+
}
|
|
71
86
|
function validateSlideName(v) {
|
|
72
87
|
if (typeof v !== "string") return null;
|
|
73
88
|
const trimmed = v.trim();
|
|
@@ -172,30 +187,25 @@ async function duplicateSlideDir(slidesRoot, slideId, desiredId) {
|
|
|
172
187
|
error: "invalid newId"
|
|
173
188
|
};
|
|
174
189
|
newId = desiredId;
|
|
175
|
-
|
|
176
|
-
if (!dstDir.startsWith(root + path.sep)) return {
|
|
190
|
+
if (!path.resolve(root, newId).startsWith(root + path.sep)) return {
|
|
177
191
|
ok: false,
|
|
178
192
|
status: 400,
|
|
179
193
|
error: "invalid newId"
|
|
180
194
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
error: "slide already exists"
|
|
187
|
-
};
|
|
188
|
-
} catch {}
|
|
195
|
+
if (await slideIdTaken(root, newId)) return {
|
|
196
|
+
ok: false,
|
|
197
|
+
status: 409,
|
|
198
|
+
error: "slide already exists"
|
|
199
|
+
};
|
|
189
200
|
} else {
|
|
190
201
|
let suffix = 1;
|
|
191
202
|
while (true) {
|
|
192
203
|
newId = suffix === 1 ? `${slideId}-copy` : `${slideId}-copy-${suffix}`;
|
|
193
|
-
|
|
194
|
-
await fs.access(path.resolve(root, newId));
|
|
204
|
+
if (await slideIdTaken(root, newId)) {
|
|
195
205
|
suffix++;
|
|
196
|
-
|
|
197
|
-
break;
|
|
206
|
+
continue;
|
|
198
207
|
}
|
|
208
|
+
break;
|
|
199
209
|
}
|
|
200
210
|
}
|
|
201
211
|
const dstDir = path.resolve(root, newId);
|
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createViteConfig } from "../config-
|
|
1
|
+
import { t as createViteConfig } from "../config-CNhYSo4C.js";
|
|
2
2
|
export { createViteConfig };
|