gbpptx 0.2.0 → 0.4.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.
Files changed (46) hide show
  1. package/README.md +237 -214
  2. package/package.json +5 -3
  3. package/src/kernel/model.js +1 -2
  4. package/src/kernel/parts.js +11 -15
  5. package/src/kernel/print.js +14 -16
  6. package/web/app/main.js +8 -8
  7. package/web/app/slides/arrange.js +101 -0
  8. package/web/app/slides/clipboard.js +93 -0
  9. package/web/app/slides/file.js +213 -0
  10. package/web/app/slides/find.js +201 -0
  11. package/web/app/slides/history.js +100 -0
  12. package/web/app/slides/keys.js +179 -0
  13. package/web/app/slides/menus.js +105 -0
  14. package/web/app/slides/objects.js +254 -0
  15. package/web/app/slides/render.js +183 -0
  16. package/web/app/slides/shared.js +85 -0
  17. package/web/app/slides/slides.js +103 -0
  18. package/web/app/slides/table.js +102 -0
  19. package/web/app/slides/text.js +418 -0
  20. package/web/app/slides/view.js +156 -0
  21. package/web/app/slides-app.js +323 -2446
  22. package/web/app/ui/canvas.js +769 -755
  23. package/web/app/ui/color-panel.js +58 -76
  24. package/web/app/ui/dialogs.js +120 -159
  25. package/web/app/ui/file-io.js +116 -132
  26. package/web/app/ui/format-pane.js +427 -427
  27. package/web/app/ui/icons.js +129 -129
  28. package/web/app/ui/menu.js +75 -89
  29. package/web/app/ui/notify.js +45 -45
  30. package/web/app/ui/page-view.js +221 -221
  31. package/web/app/ui/popup.js +80 -80
  32. package/web/app/ui/present.js +292 -292
  33. package/web/app/ui/ribbon.js +868 -878
  34. package/web/app/ui/slide-pane.js +197 -189
  35. package/web/app/ui/statusbar.js +93 -93
  36. package/web/app/ui/text-styles.js +84 -84
  37. package/web/app/ui/titlebar.js +184 -67
  38. package/web/app/ui/transition.js +30 -30
  39. package/web/index.html +23 -21
  40. package/web/serve.mjs +22 -67
  41. package/web/styles/office.css +466 -644
  42. package/web/styles/slides.css +97 -219
  43. package/web/styles/tokens.css +154 -155
  44. package/src/kernel/util/escape.js +0 -21
  45. package/src/kernel/util/id.js +0 -13
  46. package/web/app/ui/backstage.js +0 -255
package/web/serve.mjs CHANGED
@@ -1,67 +1,22 @@
1
- // [文件] gbpptx·serve —— 零依赖静态服务器(包根为 URL 空间根:/web/ 为应用,/vendor/gbooxml/ 映射到本地 gbOoxml 包)
2
- // 用法:node web/serve.mjs [端口] → http://localhost:5274/web/
3
- import { createServer } from 'node:http';
4
- import { readFile, stat } from 'node:fs/promises';
5
- import { extname, join, normalize, sep } from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
-
8
- const WEB_DIR = fileURLToPath(new URL('.', import.meta.url));
9
- const ROOT = normalize(join(WEB_DIR, '..'));
10
- // gbOoxml 真实位置:同仓本地包(本包唯一依赖)
11
- const OOXML_ROOT = normalize(join(ROOT, '..', 'gbooxml', 'src'));
12
- const PORT = Number(process.argv[2] || process.env.GBPPTX_PORT || 5274);
13
-
14
- const MIME = {
15
- '.html': 'text/html; charset=utf-8',
16
- '.js': 'text/javascript; charset=utf-8',
17
- '.mjs': 'text/javascript; charset=utf-8',
18
- '.css': 'text/css; charset=utf-8',
19
- '.json': 'application/json; charset=utf-8',
20
- '.svg': 'image/svg+xml',
21
- '.png': 'image/png',
22
- '.webp': 'image/webp',
23
- '.ico': 'image/x-icon',
24
- };
25
-
26
- function resolvePath(urlPath) {
27
- const decoded = decodeURIComponent(urlPath.split('?')[0]);
28
- if (decoded.startsWith('/vendor/gbooxml/')) {
29
- const rest = decoded.slice('/vendor/gbooxml/'.length);
30
- const target = normalize(join(OOXML_ROOT, rest));
31
- return target.startsWith(OOXML_ROOT + sep) || target === OOXML_ROOT ? target : null;
32
- }
33
- const rest = decoded === '/' ? 'web/index.html' : decoded.replace(/^\/+/, '');
34
- const target = normalize(join(ROOT, rest));
35
- return target.startsWith(ROOT) ? target : null;
36
- }
37
-
38
- const server = createServer(async (req, res) => {
39
- let target = resolvePath(req.url || '/');
40
- try {
41
- if (!target) throw new Error('forbidden');
42
- let info = await stat(target).catch(() => null);
43
- if (info?.isDirectory()) {
44
- target = join(target, 'index.html');
45
- info = await stat(target).catch(() => null);
46
- }
47
- if (!info?.isFile()) {
48
- res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
49
- res.end('404 Not Found');
50
- return;
51
- }
52
- const body = await readFile(target);
53
- res.writeHead(200, {
54
- 'Content-Type': MIME[extname(target).toLowerCase()] || 'application/octet-stream',
55
- 'Cache-Control': 'no-store',
56
- });
57
- res.end(body);
58
- } catch (err) {
59
- res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
60
- res.end(`500 ${err.message}`);
61
- }
62
- });
63
-
64
- server.listen(PORT, () => {
65
- console.log(`gbpptx 运行中:http://localhost:${PORT}/web/`);
66
- console.log(`gbOoxml 映射自:${OOXML_ROOT}`);
67
- });
1
+ // [文件] gbpptx·serve —— 静态服务器(包根为 URL 空间根:/web/ 为应用,/vendor/* 映射到同仓源码包)
2
+ // 用法:node web/serve.mjs [端口] → http://localhost:5274/web/
3
+ import { fileURLToPath } from 'node:url';
4
+ import { startStaticServer } from 'guabiutils/dev-server';
5
+
6
+ const ooxmlSrc = fileURLToPath(new URL('../../gbooxml/src/', import.meta.url));
7
+ const utilsSrc = fileURLToPath(new URL('../../../guabiutils/src/', import.meta.url));
8
+ const officeChrome = fileURLToPath(new URL('../../gbofficeui/styles/', import.meta.url));
9
+
10
+ const { origin } = await startStaticServer({
11
+ root: fileURLToPath(new URL('..', import.meta.url)),
12
+ index: 'web/index.html',
13
+ port: Number(process.argv[2] || process.env.GBPPTX_PORT || 5274),
14
+ mounts: [
15
+ { prefix: '/vendor/gbooxml/', dir: ooxmlSrc },
16
+ { prefix: '/vendor/guabiutils/', dir: utilsSrc },
17
+ { prefix: '/vendor/gbofficeui/', dir: officeChrome },
18
+ ],
19
+ });
20
+
21
+ console.log(`gbpptx 运行中:${origin}/web/`);
22
+ console.log(`gbooxml 映射自:${ooxmlSrc}`);