@swiftbrowser/web 0.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.
Files changed (84) hide show
  1. package/README.md +600 -0
  2. package/app/index.html +125 -0
  3. package/index.html +56 -0
  4. package/node/dist/node/apps.d.ts +58 -0
  5. package/node/dist/node/apps.d.ts.map +1 -0
  6. package/node/dist/node/apps.js +60 -0
  7. package/node/dist/node/apps.js.map +1 -0
  8. package/node/dist/node/config.d.ts +42 -0
  9. package/node/dist/node/config.d.ts.map +1 -0
  10. package/node/dist/node/config.js +99 -0
  11. package/node/dist/node/config.js.map +1 -0
  12. package/node/dist/node/examples.d.ts +39 -0
  13. package/node/dist/node/examples.d.ts.map +1 -0
  14. package/node/dist/node/examples.js +116 -0
  15. package/node/dist/node/examples.js.map +1 -0
  16. package/node/dist/node/index.d.ts +47 -0
  17. package/node/dist/node/index.d.ts.map +1 -0
  18. package/node/dist/node/index.js +52 -0
  19. package/node/dist/node/index.js.map +1 -0
  20. package/node/dist/plugins/app-manifests.d.ts +61 -0
  21. package/node/dist/plugins/app-manifests.d.ts.map +1 -0
  22. package/node/dist/plugins/app-manifests.js +168 -0
  23. package/node/dist/plugins/app-manifests.js.map +1 -0
  24. package/node/dist/plugins/asset-catalogs.d.ts +119 -0
  25. package/node/dist/plugins/asset-catalogs.d.ts.map +1 -0
  26. package/node/dist/plugins/asset-catalogs.js +488 -0
  27. package/node/dist/plugins/asset-catalogs.js.map +1 -0
  28. package/node/dist/plugins/bundle-resources.d.ts +49 -0
  29. package/node/dist/plugins/bundle-resources.d.ts.map +1 -0
  30. package/node/dist/plugins/bundle-resources.js +172 -0
  31. package/node/dist/plugins/bundle-resources.js.map +1 -0
  32. package/node/dist/plugins/swift-wasm.d.ts +33 -0
  33. package/node/dist/plugins/swift-wasm.d.ts.map +1 -0
  34. package/node/dist/plugins/swift-wasm.js +241 -0
  35. package/node/dist/plugins/swift-wasm.js.map +1 -0
  36. package/node/dist/src/assets.d.ts +60 -0
  37. package/node/dist/src/assets.d.ts.map +1 -0
  38. package/node/dist/src/assets.js +54 -0
  39. package/node/dist/src/assets.js.map +1 -0
  40. package/node/dist/src/devEvents.d.ts +31 -0
  41. package/node/dist/src/devEvents.d.ts.map +1 -0
  42. package/node/dist/src/devEvents.js +9 -0
  43. package/node/dist/src/devEvents.js.map +1 -0
  44. package/package.json +56 -0
  45. package/plugins/app-manifests.ts +192 -0
  46. package/plugins/asset-catalogs.ts +558 -0
  47. package/plugins/bundle-resources.ts +195 -0
  48. package/plugins/swift-wasm.ts +259 -0
  49. package/public/_headers +23 -0
  50. package/public/apple-touch-icon.png +0 -0
  51. package/public/icon.svg +14 -0
  52. package/public/manifest.webmanifest +14 -0
  53. package/src/animation.ts +521 -0
  54. package/src/assets.ts +86 -0
  55. package/src/chartDom.ts +481 -0
  56. package/src/devEvents.ts +35 -0
  57. package/src/deviceMode.ts +80 -0
  58. package/src/ghost.ts +25 -0
  59. package/src/interaction.ts +1113 -0
  60. package/src/landing.css +261 -0
  61. package/src/landing.ts +141 -0
  62. package/src/layout/chart.ts +477 -0
  63. package/src/layout/controls.ts +116 -0
  64. package/src/layout/engine.ts +3581 -0
  65. package/src/layout/index.ts +91 -0
  66. package/src/layout/measure.ts +86 -0
  67. package/src/layout/text.ts +124 -0
  68. package/src/layout/types.ts +153 -0
  69. package/src/layout/typography.ts +188 -0
  70. package/src/layoutDom.ts +549 -0
  71. package/src/layoutEvents.ts +110 -0
  72. package/src/locale.ts +64 -0
  73. package/src/main.ts +554 -0
  74. package/src/mock.ts +752 -0
  75. package/src/nodeQueries.ts +60 -0
  76. package/src/protocol.ts +1421 -0
  77. package/src/renderer.ts +2882 -0
  78. package/src/styles.css +2834 -0
  79. package/src/styles.ts +373 -0
  80. package/src/swipe.ts +110 -0
  81. package/src/symbols.ts +595 -0
  82. package/src/typography.ts +76 -0
  83. package/src/vite-env.d.ts +26 -0
  84. package/src/wasm.ts +400 -0
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Read-only queries over the renderer's `LayoutNode` tree, shared by the
3
+ * popover menus (src/renderer.ts) and the Phase 8 swipe actions
4
+ * (src/interaction.ts): the text and symbol a `button` row shows, and the
5
+ * `tint` set on it.
6
+ */
7
+
8
+ import type { LayoutNode } from './layout';
9
+ import type { Color } from './protocol';
10
+
11
+ /** All `text` in a subtree, joined with spaces (a `Label`'s title, a button's text). */
12
+ export function textOf(node: LayoutNode): string {
13
+ const parts: string[] = [];
14
+ const visit = (n: LayoutNode): void => {
15
+ if (n.kind === 'text' && typeof n.props['text'] === 'string') parts.push(n.props['text']);
16
+ n.children.forEach(visit);
17
+ };
18
+ visit(node);
19
+ return parts.join(' ').trim();
20
+ }
21
+
22
+ /** The first SF Symbol (`image` with `systemName`) in a subtree, or null. */
23
+ export function symbolOf(node: LayoutNode): string | null {
24
+ if (node.kind === 'image' && typeof node.props['systemName'] === 'string') return node.props['systemName'];
25
+ for (const child of node.children) {
26
+ const found = symbolOf(child);
27
+ if (found) return found;
28
+ }
29
+ return null;
30
+ }
31
+
32
+ /** The `style` record of a `styled` node (empty for anything else). */
33
+ export function styleRecordOf(node: LayoutNode): Record<string, unknown> {
34
+ const style = node.props['style'];
35
+ return typeof style === 'object' && style !== null ? (style as Record<string, unknown>) : {};
36
+ }
37
+
38
+ /**
39
+ * Phase 8: the `tint` a swipe action button carries, looked for on the
40
+ * `styled` wrappers above the button (`.tint()` on the `Button`) and on the
41
+ * single-child chain below it (a tinted label). `null` when none.
42
+ */
43
+ export function tintOf(node: LayoutNode): Color | null {
44
+ let current: LayoutNode | undefined = node;
45
+ while (current) {
46
+ if (current.kind === 'styled') {
47
+ const tint = styleRecordOf(current)['tint'];
48
+ if (typeof tint === 'object' && tint !== null) return tint as Color;
49
+ }
50
+ current = current.children.length === 1 ? current.children[0] : undefined;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ /** The element under a chain of `styled` wrappers. */
56
+ export function unwrapStyledNode(node: LayoutNode): LayoutNode {
57
+ let current = node;
58
+ while (current.kind === 'styled' && current.children.length === 1) current = current.children[0] as LayoutNode;
59
+ return current;
60
+ }