@popcorn245/cornfield-components 0.48.0 → 0.49.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/corn-map.js CHANGED
@@ -1 +1 @@
1
- export { t as CornMap } from "./chunks/corn-map-D6uJOnYp.js";
1
+ export { t as CornMap } from "./chunks/corn-map-C9msiSKP.js";
@@ -0,0 +1,83 @@
1
+ import { n as e, r as t, t as n } from "./chunks/runtime-DFu6W5g-.js";
2
+ import { t as r } from "./chunks/scope-vxRGj-2V.js";
3
+ import { t as i } from "./chunks/_corn-default-tokens-CoghUocx.js";
4
+ // src/components/corn-scope/corn-scope.tsx
5
+ var a = class extends n {
6
+ constructor(t) {
7
+ super(), t !== !1 && this.__registerHost(), this.cornReady = e(this, "cornReady", 7), this.cornAuth = e(this, "cornAuth", 7), this.cornError = e(this, "cornError", 7);
8
+ }
9
+ get el() {
10
+ return this;
11
+ }
12
+ src;
13
+ theme;
14
+ useTheme = !1;
15
+ topology;
16
+ config;
17
+ strings;
18
+ cornReady;
19
+ cornAuth;
20
+ cornError;
21
+ scope = null;
22
+ loaded = !1;
23
+ connectedCallback() {
24
+ this.loaded && this.mountScope();
25
+ }
26
+ componentWillLoad() {
27
+ this.loaded = !0, this.mountScope();
28
+ }
29
+ disconnectedCallback() {
30
+ this.scope && this.scope.destroy(), this.scope = null;
31
+ }
32
+ mountScope() {
33
+ this.scope ||= r(this.el, {
34
+ src: this.src,
35
+ theme: this.theme,
36
+ useTheme: this.useTheme,
37
+ topology: this.topology,
38
+ config: this.config,
39
+ strings: this.strings,
40
+ tokens: i,
41
+ version: "0.49.0",
42
+ pageUrl: () => typeof location > "u" ? "" : location.href,
43
+ onReady: () => this.cornReady.emit(),
44
+ onAuth: (e) => this.cornAuth.emit(e),
45
+ onError: (e) => this.cornError.emit(e)
46
+ });
47
+ }
48
+ changed(e, t, n) {
49
+ this.scope && this.scope.update({ [n]: e });
50
+ }
51
+ static get watchers() {
52
+ return {
53
+ src: [{ changed: 0 }],
54
+ theme: [{ changed: 0 }],
55
+ useTheme: [{ changed: 0 }],
56
+ topology: [{ changed: 0 }],
57
+ config: [{ changed: 0 }],
58
+ strings: [{ changed: 0 }]
59
+ };
60
+ }
61
+ };
62
+ t(a, [
63
+ 512,
64
+ "corn-scope",
65
+ {
66
+ src: [1],
67
+ theme: [513],
68
+ useTheme: [4, "use-theme"],
69
+ topology: [16],
70
+ config: [16],
71
+ strings: [16]
72
+ },
73
+ void 0,
74
+ {
75
+ src: [{ changed: 0 }],
76
+ theme: [{ changed: 0 }],
77
+ useTheme: [{ changed: 0 }],
78
+ topology: [{ changed: 0 }],
79
+ config: [{ changed: 0 }],
80
+ strings: [{ changed: 0 }]
81
+ }
82
+ ]);
83
+ export { a as CornScope };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { t as e } from "./chunks/corn-map-D6uJOnYp.js";
1
+ import { t as e } from "./chunks/corn-map-C9msiSKP.js";
2
+ import { CornScope as t } from "./corn-scope.js";
2
3
  // src/index.ts
3
- var t = "0.48.0";
4
- export { e as CornMap, t as version };
4
+ var n = "0.49.0";
5
+ export { e as CornMap, t as CornScope, n as version };
@@ -1,51 +1,76 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield-components",
3
- "cornfield": "0.48.0",
3
+ "cornfield": "0.49.0",
4
4
  "files": [
5
5
  {
6
- "path": "chunks/corn-map-D6uJOnYp.js",
7
- "bytes": 215695,
8
- "sha256": "68cdb9f2106510aee93f2ad57c12a10a99953b240fc38194cc2e2f684c0d3b4f"
6
+ "path": "chunks/_corn-default-tokens-CoghUocx.js",
7
+ "bytes": 139118,
8
+ "sha256": "c2e7e94d31d03d24c074bc9dcc3137bc38f9bfdc00fb4cbcef28dff29b5b68bd"
9
9
  },
10
10
  {
11
- "path": "chunks/runtime-D89gVy_w.js",
12
- "bytes": 93285,
13
- "sha256": "211e8111b4a7db118eb21b991d266cb7a175a590c21a9a43f62e3ba5b2923076"
11
+ "path": "chunks/corn-map-C9msiSKP.js",
12
+ "bytes": 93538,
13
+ "sha256": "f5a28cd66b66ceea5b383533c2cbf5aa68d4775a4a215a082e348a5c1ff74403"
14
+ },
15
+ {
16
+ "path": "chunks/rolldown-runtime-CGnMp29N.js",
17
+ "bytes": 228,
18
+ "sha256": "403903b4a10bc334e69926f74213e2e9d6cd01effd69acefe9d17088bfc4902b"
19
+ },
20
+ {
21
+ "path": "chunks/runtime-DFu6W5g-.js",
22
+ "bytes": 93182,
23
+ "sha256": "47327281b56616b00075dd5e4b52c0142fc3414509eb8258d9b98c8b56fc372d"
24
+ },
25
+ {
26
+ "path": "chunks/scope-vxRGj-2V.js",
27
+ "bytes": 26321,
28
+ "sha256": "b44774683ba8ddcbc7ac802401dc9a8dced3d7d92aad7f550d5d40b413f107f8"
14
29
  },
15
30
  {
16
31
  "path": "corn-map.js",
17
32
  "bytes": 62,
18
- "sha256": "63ba316219a24f5f225712454410dd13566f9a4215a3a0853f6a98aabbdcb666"
33
+ "sha256": "fe3c56c50934e69b4a3dd45dd3afb3381021cabcc842471643233b1075d5a573"
34
+ },
35
+ {
36
+ "path": "corn-scope.js",
37
+ "bytes": 1891,
38
+ "sha256": "ba66720a293e534be2a119ef7c7c52c2a3d337eec658edeeb57edea05ba2f508"
19
39
  },
20
40
  {
21
41
  "path": "index.js",
22
- "bytes": 129,
23
- "sha256": "fbf76a789c915b7b26d42ed553024d2efe675f3c4ef9dc6279869183161fb75a"
42
+ "bytes": 195,
43
+ "sha256": "08696131b0f0898a9de49fb5d89405dad106c469fcc9fb163addfd9794992f8f"
24
44
  },
25
45
  {
26
46
  "path": "tokens.css",
27
- "bytes": 22335,
28
- "sha256": "fbf0f208cb37bd11ea85fcc304843422ad2c2631a1bab5d91fd20e91ba9a8cc5"
47
+ "bytes": 22404,
48
+ "sha256": "b7b3770c02d54dc4b143363051a9a4ee553231d595fcf8102927d2e42876ffd7"
29
49
  },
30
50
  {
31
51
  "path": "types/components.d.ts",
32
- "bytes": 4976,
33
- "sha256": "62e2bfeb10b80c34a92c0b3364bd8bf3b94ca4f1179fa0a69f94773cafd41e2b"
52
+ "bytes": 11230,
53
+ "sha256": "200e1fc27f2e3c6fccbdf4e639e3290545ac37c80f264b3f33fd282c670d4a87"
34
54
  },
35
55
  {
36
56
  "path": "types/corn-map.d.ts",
37
57
  "bytes": 126,
38
58
  "sha256": "55a73109062f33a77cfb61cd01a3c26241112518b4c09b3e27655be1c6e9f08d"
39
59
  },
60
+ {
61
+ "path": "types/corn-scope.d.ts",
62
+ "bytes": 132,
63
+ "sha256": "bccea440b30e794e8d5d57bb24c006d96ad86752d0602d9c1c244f3dcc5bcb05"
64
+ },
40
65
  {
41
66
  "path": "types/index.d.ts",
42
- "bytes": 266,
43
- "sha256": "c5c9adab53ce11a6439fbae2ab622f47a5b88649957272ae0dcbc3d9f13c0c34"
67
+ "bytes": 365,
68
+ "sha256": "3a88ac322244901600af3ab8b7f2772b672e6e535a048840ef61825c11fc58af"
44
69
  },
45
70
  {
46
71
  "path": "version.json",
47
72
  "bytes": 65,
48
- "sha256": "9744436eda8eca2e5ed0329e1f047c2b6780ff920ce744d9b4496cc00bd43d2d"
73
+ "sha256": "8e0fa090508c775cf3740e1e41e978044fd5463307d60dc87c15a559fbfedd72"
49
74
  }
50
75
  ]
51
76
  }
package/dist/tokens.css CHANGED
@@ -314,7 +314,8 @@
314
314
  }
315
315
 
316
316
  /* theme="light" on an element: this mode's tokens, on the element itself */
317
- :where(corn-map[theme="light"]) {
317
+ :where(corn-map[theme="light"]),
318
+ :where(corn-scope[theme="light"]) {
318
319
  --corn-ground: #f4f6fa;
319
320
  --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.06) 0%, transparent 45%),
320
321
  radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.04) 0%, transparent 45%);
@@ -431,7 +432,8 @@
431
432
  }
432
433
 
433
434
  /* theme="dark" on an element: this mode's tokens, on the element itself */
434
- :where(corn-map[theme="dark"]) {
435
+ :where(corn-map[theme="dark"]),
436
+ :where(corn-scope[theme="dark"]) {
435
437
  --corn-ground: #090d16;
436
438
  --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.2) 0%, transparent 45%),
437
439
  radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.16) 0%, transparent 45%),
@@ -1,5 +1,19 @@
1
1
  // Generated by components/scripts/types.mjs from the components' own declarations (StencilRS emits no types for a library build: StencilRS#54). Do not edit.
2
2
 
3
+ export interface CornAuthDetail {
4
+ /** 401 or 403 */
5
+ status: number;
6
+ /** `<src>/auth/start?returnTo=<this page's address>`: a link the host or the piece puts in front of the person; the component never navigates the window */
7
+ signIn: string;
8
+ }
9
+
10
+ export interface CornErrorDetail {
11
+ /** `not-listed` (the server gave this page no CORS answer: its origin is not in `embed.origins`), `offline`, `server` (it answered with something that is not a config or a map), `address` (`src` is not an http(s) address), `version` (the package and the server differ by a minor or more; it keeps working), `theme` (the server's theme could not be had), `second-map` (a scope holds one map) */
12
+ kind: 'not-listed' | 'offline' | 'server' | 'address' | 'version' | 'theme' | 'second-map';
13
+ /** A few words more, plain text: the origin to list, the problem with the address, the two versions */
14
+ message?: string;
15
+ }
16
+
3
17
  export interface CornSelectDetail {
4
18
  /** The node's id, `from->to` for an edge, or null when the selection was cleared */
5
19
  id: string | null;
@@ -24,6 +38,10 @@ export namespace Components {
24
38
  'theme'?: 'light' | 'dark' | 'auto' | undefined;
25
39
  /** `auto` (WebGL2 when there is one) or `canvas2d` */
26
40
  'renderer': 'auto' | 'canvas2d';
41
+ /** The base address of a cornfield server, for a map with no `corn-scope` around it: it reads the config and the topology from there, with the signed-in maintainer's session. Inside a scope the scope's is used and this is ignored. */
42
+ 'src'?: string | undefined;
43
+ /** With `src` and no scope: wear the server's theme (its stylesheet and its `--corn-*` tokens). Inside a scope, the scope's `use-theme` decides. */
44
+ 'useTheme': boolean;
27
45
  /** Puts the whole map in view */
28
46
  'fit': () => Promise<void>;
29
47
  /** Selects the node with this id and brings it into view; nothing happens when the map has no such node */
@@ -31,6 +49,20 @@ export namespace Components {
31
49
  /** Reads the tokens again and draws: for a token changed at run time by something the map cannot see (a rule added to the page's head, a class on `<html>`) */
32
50
  'refresh': () => Promise<void>;
33
51
  }
52
+ interface CornScope {
53
+ /** The base address of a cornfield server, `https://map.example.com` (an http(s) origin with an optional path). Another value is refused, and said in the pieces and in `cornError`. */
54
+ 'src'?: string | undefined;
55
+ /** The ground the pieces are drawn for: `light` or `dark` forces it, `auto` (or none) follows the page's own `data-theme` or the system's setting */
56
+ 'theme'?: 'light' | 'dark' | 'auto' | undefined;
57
+ /** Wear the server's theme: its stylesheet goes into every piece, and its `--corn-*` tokens onto this element. Off by default: a host app has its own look. */
58
+ 'useTheme': boolean;
59
+ /** The map to draw, for a host that fetches for itself: the object `topology.json` holds. With it (and `config`) no request is made. */
60
+ 'topology'?: { nodes: Array<{ id: string; [key: string]: unknown }>; edges?: Array<{ from: string; to: string; [key: string]: unknown }> } | null | undefined;
61
+ /** The object `/cornfield/config.json` holds, for a host that fetches for itself */
62
+ 'config'?: { [key: string]: unknown } | null | undefined;
63
+ /** The words the host overrides (a flat map of `strings` keys to text); they win over the server's */
64
+ 'strings'?: { [key: string]: string } | null | undefined;
65
+ }
34
66
  }
35
67
 
36
68
  export interface CornMapCustomEvent<T> extends CustomEvent<T> {
@@ -38,6 +70,11 @@ export interface CornMapCustomEvent<T> extends CustomEvent<T> {
38
70
  target: HTMLCornMapElement;
39
71
  }
40
72
 
73
+ export interface CornScopeCustomEvent<T> extends CustomEvent<T> {
74
+ detail: T;
75
+ target: HTMLCornScopeElement;
76
+ }
77
+
41
78
  export namespace LocalJSX {
42
79
  interface CornMap {
43
80
  'topology'?: { nodes: Array<{ id: string; [key: string]: unknown }>; edges?: Array<{ from: string; to: string; [key: string]: unknown }> } | null | undefined;
@@ -45,11 +82,27 @@ export namespace LocalJSX {
45
82
  'view'?: 'map' | 'dataflow';
46
83
  'theme'?: 'light' | 'dark' | 'auto' | undefined;
47
84
  'renderer'?: 'auto' | 'canvas2d';
85
+ 'src'?: string | undefined;
86
+ 'useTheme'?: boolean;
48
87
  'onCornSelect'?: (event: CornMapCustomEvent<CornSelectDetail>) => void;
49
88
  'onCornReady'?: (event: CornMapCustomEvent<void>) => void;
89
+ 'onCornAuth'?: (event: CornMapCustomEvent<CornAuthDetail>) => void;
90
+ 'onCornError'?: (event: CornMapCustomEvent<CornErrorDetail>) => void;
91
+ }
92
+ interface CornScope {
93
+ 'src'?: string | undefined;
94
+ 'theme'?: 'light' | 'dark' | 'auto' | undefined;
95
+ 'useTheme'?: boolean;
96
+ 'topology'?: { nodes: Array<{ id: string; [key: string]: unknown }>; edges?: Array<{ from: string; to: string; [key: string]: unknown }> } | null | undefined;
97
+ 'config'?: { [key: string]: unknown } | null | undefined;
98
+ 'strings'?: { [key: string]: string } | null | undefined;
99
+ 'onCornReady'?: (event: CornScopeCustomEvent<void>) => void;
100
+ 'onCornAuth'?: (event: CornScopeCustomEvent<CornAuthDetail>) => void;
101
+ 'onCornError'?: (event: CornScopeCustomEvent<CornErrorDetail>) => void;
50
102
  }
51
103
  interface IntrinsicElements {
52
104
  'corn-map': LocalJSX.CornMap & { [attribute: string]: unknown };
105
+ 'corn-scope': LocalJSX.CornScope & { [attribute: string]: unknown };
53
106
  }
54
107
  }
55
108
 
@@ -60,6 +113,10 @@ declare global {
60
113
  'cornSelect': CornSelectDetail;
61
114
  /** The first frame with a map in it is drawn (once per time the element is connected) */
62
115
  'cornReady': void;
116
+ /** With `src` and no scope: the server answered a gated read with 401 or 403 and the maintainer has to sign in. The map shows a link to `signIn`. */
117
+ 'cornAuth': CornAuthDetail;
118
+ /** With `src` and no scope: something the map could not do (see `kind`). In a scope, the scope says it. */
119
+ 'cornError': CornErrorDetail;
63
120
  }
64
121
  /** cornfield's map, in a shadow root. A thin shell (spec 0011 D1): it declares properties and events, mounts the engine's map piece in its shadow root, passes each property change in, turns the piece's callbacks into events, and ends the piece when it leaves the page. It holds no behaviour (test/shell.test.ts fails if this file imports anything but the Stencil runtime, the engine's pieces and CSS, or grows past a shell). */
65
122
  interface HTMLCornMapElement extends Components.CornMap, HTMLElement {
@@ -72,8 +129,29 @@ declare global {
72
129
  }
73
130
  var HTMLCornMapElement: { prototype: HTMLCornMapElement; new (): HTMLCornMapElement };
74
131
 
132
+ /** What `<corn-scope>` sends: the event's name and the type of its `detail` */
133
+ interface HTMLCornScopeElementEventMap {
134
+ /** The scope has its data: read from the server, or handed in. Once per server. */
135
+ 'cornReady': void;
136
+ /** The server answered a gated read with 401 or 403: the maintainer has to sign in. The piece shows a link to `signIn`. */
137
+ 'cornAuth': CornAuthDetail;
138
+ /** Something the pieces could not do */
139
+ 'cornError': CornErrorDetail;
140
+ }
141
+ /** Where the data comes from, and what the pieces inside it share (spec 0011 D5). It shows nothing of its own and has no shadow root: the `corn-*` pieces inside it (today `corn-map`) share one instance (one selection, one camera, one topology), and `src` is the address of a cornfield server it reads their config and topology from, with the signed-in maintainer's session. A thin shell (spec 0011 D1): the work is explorer/pieces/scope.js. */
142
+ interface HTMLCornScopeElement extends Components.CornScope, HTMLElement {
143
+ addEventListener<K extends keyof HTMLCornScopeElementEventMap>(type: K, listener: (this: HTMLCornScopeElement, ev: CornScopeCustomEvent<HTMLCornScopeElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
144
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLCornScopeElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
145
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
146
+ removeEventListener<K extends keyof HTMLCornScopeElementEventMap>(type: K, listener: (this: HTMLCornScopeElement, ev: CornScopeCustomEvent<HTMLCornScopeElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
147
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLCornScopeElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
148
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
149
+ }
150
+ var HTMLCornScopeElement: { prototype: HTMLCornScopeElement; new (): HTMLCornScopeElement };
151
+
75
152
  interface HTMLElementTagNameMap {
76
153
  'corn-map': HTMLCornMapElement;
154
+ 'corn-scope': HTMLCornScopeElement;
77
155
  }
78
156
  }
79
157
 
@@ -0,0 +1,2 @@
1
+ export * from './components.js';
2
+ export declare const CornScope: { prototype: HTMLCornScopeElement; new (): HTMLCornScopeElement };
@@ -2,3 +2,4 @@ export * from './components.js';
2
2
  /** The version of cornfield these components were built from (the server reports the same number) */
3
3
  export declare const version: string;
4
4
  export declare const CornMap: { prototype: HTMLCornMapElement; new (): HTMLCornMapElement };
5
+ export declare const CornScope: { prototype: HTMLCornScopeElement; new (): HTMLCornScopeElement };
package/dist/version.json CHANGED
@@ -1 +1 @@
1
- {"name":"@popcorn245/cornfield-components","cornfield":"0.48.0"}
1
+ {"name":"@popcorn245/cornfield-components","cornfield":"0.49.0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield-components",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "cornfield's interface as web components (spec 0011): <corn-map> and what follows, thin StencilRS shells over the engine in cornfield. The same files are served by every cornfield server at /cornfield/components/.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",
@@ -34,6 +34,10 @@
34
34
  "types": "./dist/types/corn-map.d.ts",
35
35
  "default": "./dist/corn-map.js"
36
36
  },
37
+ "./corn-scope": {
38
+ "types": "./dist/types/corn-scope.d.ts",
39
+ "default": "./dist/corn-scope.js"
40
+ },
37
41
  "./tokens.css": "./dist/tokens.css",
38
42
  "./version.json": "./dist/version.json"
39
43
  },