@joystyk/ui 0.0.0 → 0.2.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/CHANGELOG.md +11 -0
- package/README.md +31 -2
- package/dist/ad-slot.d.ts +129 -0
- package/dist/ad-slot.js +628 -0
- package/dist/ad-slot.js.map +1 -0
- package/dist/ad-wire.d.ts +96 -0
- package/dist/ad-wire.js +101 -0
- package/dist/ad-wire.js.map +1 -0
- package/dist/button.d.ts +40 -0
- package/dist/button.js +133 -0
- package/dist/button.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/slots.d.ts +38 -0
- package/dist/slots.js +154 -0
- package/dist/slots.js.map +1 -0
- package/dist/tokens.css +98 -0
- package/package.json +66 -11
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @joystyk/ui
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 0.1.0
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- Prepare the first compiled library release: ESM and API declarations for every public entry point, runtime assets, and checks against installed npm tarballs. Games and applications remain private.
|
package/README.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @joystyk/ui
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
Shared Gyral controls and design tokens. Import a component module once to register its custom element. The button wraps a native button and supports keyboard activation and a pressed state. Ad modules implement contextual slots and their validated wire formats.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## npm package
|
|
6
|
+
|
|
7
|
+
The first `0.1.0` release is being prepared; it has not been published. Once available:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @joystyk/ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Node consumers require Node 24.15 or later. Browser entry points require a modern
|
|
14
|
+
browser and should be loaded in the browser. Tested with Gyral 0.3.1.
|
|
15
|
+
|
|
16
|
+
| Import | Format |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `@joystyk/ui` | ES module and TypeScript declarations |
|
|
19
|
+
| `@joystyk/ui/button` | ES module and TypeScript declarations |
|
|
20
|
+
| `@joystyk/ui/ad-slot` | ES module and TypeScript declarations |
|
|
21
|
+
| `@joystyk/ui/ad-wire` | ES module and TypeScript declarations |
|
|
22
|
+
| `@joystyk/ui/slots` | ES module and TypeScript declarations |
|
|
23
|
+
| `@joystyk/ui/tokens.css` | CSS asset |
|
|
24
|
+
|
|
25
|
+
Only the entries listed above are public API. Installed packages contain compiled ESM,
|
|
26
|
+
type declarations and runtime assets. Repository-relative links describe the Joystyk
|
|
27
|
+
workspace and are not needed to use the npm package.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import '@joystyk/ui/button';
|
|
31
|
+
import '@joystyk/ui/tokens.css';
|
|
32
|
+
|
|
33
|
+
// In a Gyral view: <jy-button toggle>Sound</jy-button>
|
|
34
|
+
```
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type Command, type PropsOf } from '@gyral/core';
|
|
2
|
+
import { type AdFill, type AdQuery, type CreativeFill, type HouseFill } from './ad-wire.js';
|
|
3
|
+
import { type SlotId, type SlotSurface } from './slots.js';
|
|
4
|
+
/** Whether the visitor sees ads. 'hide' arrives with ad-free entitlements in v2. */
|
|
5
|
+
export type AdEntitlement = 'show' | 'hide';
|
|
6
|
+
/** Where `<ad-slot>` learns whether to show ads. */
|
|
7
|
+
export interface AdEntitlementSource {
|
|
8
|
+
get(): AdEntitlement;
|
|
9
|
+
/** Calls `listener` on every change; returns how to stop. */
|
|
10
|
+
subscribe(listener: (entitlement: AdEntitlement) => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
/** The v1 source: every visitor sees ads, so it never changes. */
|
|
13
|
+
export declare const alwaysShowAds: AdEntitlementSource;
|
|
14
|
+
/** The default entitlement driver: `alwaysShowAds`. */
|
|
15
|
+
export declare const adEntitlement: import("@gyral/core").Driver<undefined, AdEntitlement, unknown>;
|
|
16
|
+
/** Gives every `<ad-slot>` below `element` its entitlement from `source`. */
|
|
17
|
+
export declare const provideAdEntitlement: (element: Element, source: AdEntitlementSource) => (() => void);
|
|
18
|
+
/** `navigator.onLine` now and on every `online` / `offline` event. */
|
|
19
|
+
export declare const connectivity: import("@gyral/core").Driver<undefined, boolean, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Asks the ad endpoint for a slot's fill and parses the answer at the boundary. No cookies go
|
|
22
|
+
* with it. Fails on a network error, a non-2xx status or an answer that doesn't parse.
|
|
23
|
+
*/
|
|
24
|
+
export declare const adServer: import("@gyral/core").Driver<string, {
|
|
25
|
+
kind: "creative";
|
|
26
|
+
id: number;
|
|
27
|
+
image: {
|
|
28
|
+
src: string;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
alt: string;
|
|
33
|
+
headline: string;
|
|
34
|
+
href: string;
|
|
35
|
+
beacon: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "house";
|
|
38
|
+
headline: string;
|
|
39
|
+
text: string;
|
|
40
|
+
cta: string;
|
|
41
|
+
href: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "collapse";
|
|
44
|
+
}, string>;
|
|
45
|
+
/** Sends an impression beacon: a bodiless POST that outlives the page, without cookies. */
|
|
46
|
+
export declare const adBeacon: import("@gyral/core").Driver<string, void, string>;
|
|
47
|
+
/** Where the slot's fill stands. */
|
|
48
|
+
export type AdLoad =
|
|
49
|
+
/** Not near the viewport yet: nothing asked. */
|
|
50
|
+
{
|
|
51
|
+
readonly _tag: 'Waiting';
|
|
52
|
+
} | {
|
|
53
|
+
readonly _tag: 'Loading';
|
|
54
|
+
readonly url: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly _tag: 'Filled';
|
|
57
|
+
readonly url: string;
|
|
58
|
+
readonly fill: CreativeFill | HouseFill;
|
|
59
|
+
readonly seen: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Nothing to show, or something failed: the slot collapses. */
|
|
62
|
+
| {
|
|
63
|
+
readonly _tag: 'Empty';
|
|
64
|
+
readonly url: string;
|
|
65
|
+
};
|
|
66
|
+
export interface AdSlotState {
|
|
67
|
+
readonly entitlement: AdEntitlement;
|
|
68
|
+
/** What the connectivity driver last said; null until it first reports (assumed online). */
|
|
69
|
+
readonly online: boolean | null;
|
|
70
|
+
/** The box has come near the viewport once. */
|
|
71
|
+
readonly near: boolean;
|
|
72
|
+
readonly ad: AdLoad;
|
|
73
|
+
}
|
|
74
|
+
export type AdSlotMsg = {
|
|
75
|
+
readonly _tag: 'Entitled';
|
|
76
|
+
readonly entitlement: AdEntitlement;
|
|
77
|
+
} | {
|
|
78
|
+
readonly _tag: 'Connectivity';
|
|
79
|
+
readonly online: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** The box came within a screen's reach of the viewport. */
|
|
82
|
+
| {
|
|
83
|
+
readonly _tag: 'Near';
|
|
84
|
+
} | {
|
|
85
|
+
readonly _tag: 'Loaded';
|
|
86
|
+
readonly url: string;
|
|
87
|
+
readonly fill: AdFill;
|
|
88
|
+
} | {
|
|
89
|
+
readonly _tag: 'LoadFailed';
|
|
90
|
+
readonly url: string;
|
|
91
|
+
}
|
|
92
|
+
/** The creative's image loaded and is at least half on screen, or it failed to load. */
|
|
93
|
+
| {
|
|
94
|
+
readonly _tag: 'Image';
|
|
95
|
+
readonly status: 'seen' | 'broken';
|
|
96
|
+
};
|
|
97
|
+
/** What the slot shows: its reserved box (empty or filled), or nothing at all. Pure. */
|
|
98
|
+
export declare const slotPresentation: (s: AdSlotState) => "reserved" | "collapsed";
|
|
99
|
+
declare const props: {
|
|
100
|
+
/** The registry id (attribute `slot-id`; `slot` is taken by the platform). */
|
|
101
|
+
slotId: import("@gyral/core").Prop<SlotId>;
|
|
102
|
+
/** The kind of page the slot is on (attribute `page`). Default: the slot's first surface. */
|
|
103
|
+
page: import("@gyral/core").Prop<SlotSurface | undefined>;
|
|
104
|
+
/** The game the page or screen is about (attribute `game-id`). */
|
|
105
|
+
gameId: import("@gyral/core").Prop<string | undefined>;
|
|
106
|
+
/** The category the page is about (attribute `category`). */
|
|
107
|
+
category: import("@gyral/core").Prop<string | undefined>;
|
|
108
|
+
};
|
|
109
|
+
export type AdSlotProps = PropsOf<typeof props>;
|
|
110
|
+
/** The context the slot sends: what the page is about, never who is looking. */
|
|
111
|
+
export declare const queryOf: (p: AdSlotProps) => AdQuery;
|
|
112
|
+
/** Asks the endpoint for `url`'s fill; the latest request wins. */
|
|
113
|
+
export declare const requestFill: (url: string) => Command<AdSlotMsg>;
|
|
114
|
+
export declare const AdSlot: import("@gyral/core").GyralElementClass<AdSlotState, AdSlotMsg, PropsOf<{
|
|
115
|
+
/** The registry id (attribute `slot-id`; `slot` is taken by the platform). */
|
|
116
|
+
slotId: import("@gyral/core").Prop<SlotId>;
|
|
117
|
+
/** The kind of page the slot is on (attribute `page`). Default: the slot's first surface. */
|
|
118
|
+
page: import("@gyral/core").Prop<SlotSurface | undefined>;
|
|
119
|
+
/** The game the page or screen is about (attribute `game-id`). */
|
|
120
|
+
gameId: import("@gyral/core").Prop<string | undefined>;
|
|
121
|
+
/** The category the page is about (attribute `category`). */
|
|
122
|
+
category: import("@gyral/core").Prop<string | undefined>;
|
|
123
|
+
}>, never, "Near" | "Image">;
|
|
124
|
+
declare global {
|
|
125
|
+
interface HTMLElementTagNameMap {
|
|
126
|
+
'ad-slot': InstanceType<typeof AdSlot>;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export {};
|