@tastic/hud 0.1.1 → 0.1.2
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/index.js +19 -31
- package/dist/index.mjs +1 -3
- package/package.json +1 -1
- package/src/TriggerGaugeHost.tsx +3 -4
- package/src/loadSkiaWeb.ts +8 -12
- package/src/loadSkiaWeb.web.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __esm = (fn, res) => function __init() {
|
|
9
7
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -20,14 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
18
|
}
|
|
21
19
|
return to;
|
|
22
20
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
22
|
|
|
33
23
|
// src/TriggerGauge.tsx
|
|
@@ -130,18 +120,18 @@ function TriggerGauge({ segments, litIndices, size, accentColor, mutedColor, das
|
|
|
130
120
|
height: canvasSize,
|
|
131
121
|
width: canvasSize
|
|
132
122
|
};
|
|
133
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native7.View, { style: [styles4.container, gaugeSizeStyle], pointerEvents: "none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native_skia.Canvas, { style: canvasSizeStyle, children: [
|
|
134
124
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_skia.Path, { path: unlitPath, style: "stroke", strokeWidth: UNLIT_THICKNESS, strokeCap: "round", color: mutedColor, opacity: 0.35 }),
|
|
135
125
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_skia.Path, { path: litPath, style: "stroke", strokeWidth: LIT_THICKNESS, strokeCap: "round", color: accentColor, opacity: 1 })
|
|
136
126
|
] }) });
|
|
137
127
|
}
|
|
138
|
-
var import_react_native_skia, import_react2,
|
|
128
|
+
var import_react_native_skia, import_react2, import_react_native7, import_react_native_reanimated, import_jsx_runtime5, UNLIT_THICKNESS, LIT_THICKNESS, DASH_GAP_PX, ARC_GAP, DEFAULT_START_DEG, MIN_DASH_ANGLE_DEG, MOUNT_DURATION_MS, MOUNT_STAGGER_MS, SELECTION_TRANSITION_DURATION_MS, styles4;
|
|
139
129
|
var init_TriggerGauge = __esm({
|
|
140
130
|
"src/TriggerGauge.tsx"() {
|
|
141
131
|
"use strict";
|
|
142
132
|
import_react_native_skia = require("@shopify/react-native-skia");
|
|
143
133
|
import_react2 = require("react");
|
|
144
|
-
|
|
134
|
+
import_react_native7 = require("react-native");
|
|
145
135
|
import_react_native_reanimated = require("react-native-reanimated");
|
|
146
136
|
import_jsx_runtime5 = require("react/jsx-runtime");
|
|
147
137
|
UNLIT_THICKNESS = 3;
|
|
@@ -153,7 +143,7 @@ var init_TriggerGauge = __esm({
|
|
|
153
143
|
MOUNT_DURATION_MS = 450;
|
|
154
144
|
MOUNT_STAGGER_MS = 40;
|
|
155
145
|
SELECTION_TRANSITION_DURATION_MS = 260;
|
|
156
|
-
styles4 =
|
|
146
|
+
styles4 = import_react_native7.StyleSheet.create({
|
|
157
147
|
container: {
|
|
158
148
|
alignItems: "center",
|
|
159
149
|
justifyContent: "center",
|
|
@@ -406,23 +396,21 @@ var styles2 = import_react_native4.StyleSheet.create({
|
|
|
406
396
|
});
|
|
407
397
|
|
|
408
398
|
// src/loadSkiaWeb.ts
|
|
409
|
-
var import_react_native5 = require("react-native");
|
|
410
399
|
function loadSkiaWeb() {
|
|
411
|
-
|
|
412
|
-
return import("@shopify/react-native-skia/src/web").then((m) => m.LoadSkiaWeb());
|
|
400
|
+
return Promise.resolve();
|
|
413
401
|
}
|
|
414
402
|
|
|
415
403
|
// src/PressAwayOverlay.tsx
|
|
416
|
-
var
|
|
404
|
+
var import_react_native5 = require("react-native");
|
|
417
405
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
418
406
|
function PressAwayOverlay({ active, onPress, style }) {
|
|
419
407
|
if (!active) return null;
|
|
420
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native5.Pressable, { accessibilityLabel: "Dismiss", accessibilityRole: "button", onPress, style: [import_react_native5.StyleSheet.absoluteFill, style] });
|
|
421
409
|
}
|
|
422
410
|
|
|
423
411
|
// src/ReadyButton.tsx
|
|
424
412
|
var import_feedback_press2 = require("@rific/feedback-press");
|
|
425
|
-
var
|
|
413
|
+
var import_react_native6 = require("react-native");
|
|
426
414
|
var import_react_native_paper2 = require("react-native-paper");
|
|
427
415
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
428
416
|
function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily = MONO_FONT }) {
|
|
@@ -431,7 +419,7 @@ function ReadyButton({ color, ready, onToggleReady, style, labelFontFamily = MON
|
|
|
431
419
|
const labelColorStyle = { color: ready ? "#000000" : color };
|
|
432
420
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_feedback_press2.TouchableRipple, { onPress: onToggleReady, borderless: true, style: readyButtonStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper2.Text, { variant: "labelLarge", style: [labelTextStyle, labelColorStyle], children: ready ? "READY \u2713" : "READY?" }) });
|
|
433
421
|
}
|
|
434
|
-
var styles3 =
|
|
422
|
+
var styles3 = import_react_native6.StyleSheet.create({
|
|
435
423
|
readyButton: {
|
|
436
424
|
alignItems: "center",
|
|
437
425
|
borderRadius: 12,
|
|
@@ -446,7 +434,7 @@ var styles3 = import_react_native7.StyleSheet.create({
|
|
|
446
434
|
// src/SectionedDropdown.tsx
|
|
447
435
|
var import_auto_paper2 = require("@rific/auto-paper");
|
|
448
436
|
var import_feedback_press3 = require("@rific/feedback-press");
|
|
449
|
-
var
|
|
437
|
+
var import_react_native8 = require("react-native");
|
|
450
438
|
var import_react_native_paper3 = require("react-native-paper");
|
|
451
439
|
|
|
452
440
|
// src/TriggerGaugeHost.tsx
|
|
@@ -507,13 +495,13 @@ function SectionedDropdown({ id, host, icon, accessibilityLabel, sections, accen
|
|
|
507
495
|
const anchorStyle = [styles5.anchor, open && styles5.anchorOpen];
|
|
508
496
|
const menuStyle = { backgroundColor: menuBg, borderColor: menuBorderColor, maxHeight };
|
|
509
497
|
const dividerStyle = { backgroundColor: menuBorderColor };
|
|
510
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
511
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: anchorStyle, children: [
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { ref: triggerRef, collapsable: false, style: styles5.triggerBox, children: [
|
|
512
500
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TriggerGaugeHost, { segments: gaugeSegments, litIndices: gaugeLitIndices, size: TRIGGER_SIZE, accentColor, mutedColor }),
|
|
513
501
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.IconButton, { icon: triggerIcon, iconColor: triggerIconColor, size: triggerIconSize, accessibilityLabel, onPress: () => host.toggle(id) })
|
|
514
502
|
] }),
|
|
515
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PopoverBody, { visible: open && measured, align, verticalAlign, caretColor: menuBg, caretBorderColor: menuBorderColor, caretBorderWidth: MENU_BORDER_WIDTH, triggerSize: TRIGGER_SIZE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
516
|
-
sectionIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PopoverBody, { visible: open && measured, align, verticalAlign, caretColor: menuBg, caretBorderColor: menuBorderColor, caretBorderWidth: MENU_BORDER_WIDTH, triggerSize: TRIGGER_SIZE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native8.ScrollView, { style: [styles5.menu, menuStyle], contentContainerStyle: styles5.menuContent, showsVerticalScrollIndicator: false, children: sections.map((section, sectionIndex) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { children: [
|
|
504
|
+
sectionIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native8.View, { style: [styles5.divider, dividerStyle] }),
|
|
517
505
|
section.kind === "single" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
518
506
|
SingleSection,
|
|
519
507
|
{
|
|
@@ -545,9 +533,9 @@ function SingleSection({
|
|
|
545
533
|
const itemStyle = [styles5.item, selected && { backgroundColor: accentColor }];
|
|
546
534
|
const labelStyle = { fontFamily: labelFontFamily, color: rowColor, fontWeight: selected ? "bold" : "normal" };
|
|
547
535
|
const descriptionStyle = { fontFamily: labelFontFamily, color: rowColor };
|
|
548
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.TouchableRipple, { onPress: () => onSelect(option.value), style: itemStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.TouchableRipple, { onPress: () => onSelect(option.value), style: itemStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: styles5.itemRow, children: [
|
|
549
537
|
option.icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Icon, { source: option.icon, size: MENU_ITEM_ICON_SIZE, color: rowColor }),
|
|
550
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
538
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: styles5.itemLabelColumn, children: [
|
|
551
539
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Text, { variant: "labelLarge", style: labelStyle, children: option.label }),
|
|
552
540
|
option.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Text, { variant: "labelSmall", style: descriptionStyle, children: option.description })
|
|
553
541
|
] })
|
|
@@ -571,7 +559,7 @@ function MultiSection({
|
|
|
571
559
|
const nextSelected = selected && i < section.options.length - 1 && section.value.includes(section.options[i + 1].value);
|
|
572
560
|
const itemStyle = [styles5.item, selected && { backgroundColor: accentColor }, prevSelected && { borderTopLeftRadius: 0, borderTopRightRadius: 0 }, nextSelected && { borderBottomLeftRadius: 0, borderBottomRightRadius: 0 }];
|
|
573
561
|
const labelStyle = { fontFamily: labelFontFamily, color: rowColor, fontWeight: selected ? "bold" : "normal" };
|
|
574
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.TouchableRipple, { onPress: () => section.onChange(selected ? section.value.filter((v) => v !== option.value) : [...section.value, option.value]), style: itemStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.TouchableRipple, { onPress: () => section.onChange(selected ? section.value.filter((v) => v !== option.value) : [...section.value, option.value]), style: itemStyle, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: styles5.itemRow, children: [
|
|
575
563
|
option.icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Icon, { source: option.icon, size: MENU_ITEM_ICON_SIZE, color: rowColor }),
|
|
576
564
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Text, { variant: "labelLarge", style: [styles5.itemLabelFlex, labelStyle], children: option.label })
|
|
577
565
|
] }) }, option.value);
|
|
@@ -579,7 +567,7 @@ function MultiSection({
|
|
|
579
567
|
section.allClear && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_feedback_press3.TouchableRipple, { onPress: () => section.onChange(allSelected ? [] : section.options.map((o) => o.value)), style: styles5.item, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper3.Text, { variant: "labelLarge", style: [styles5.allClearLabel, { fontFamily: labelFontFamily, color: accentColor }], children: allSelected ? allClearLabels.clear : allClearLabels.all }) })
|
|
580
568
|
] });
|
|
581
569
|
}
|
|
582
|
-
var styles5 =
|
|
570
|
+
var styles5 = import_react_native8.StyleSheet.create({
|
|
583
571
|
allClearLabel: {
|
|
584
572
|
fontWeight: "bold",
|
|
585
573
|
textAlign: "center"
|
|
@@ -596,7 +584,7 @@ var styles5 = import_react_native9.StyleSheet.create({
|
|
|
596
584
|
zIndex: 100
|
|
597
585
|
},
|
|
598
586
|
divider: {
|
|
599
|
-
height:
|
|
587
|
+
height: import_react_native8.StyleSheet.hairlineWidth,
|
|
600
588
|
marginVertical: 4
|
|
601
589
|
},
|
|
602
590
|
item: {
|
package/dist/index.mjs
CHANGED
|
@@ -225,10 +225,8 @@ var styles2 = StyleSheet2.create({
|
|
|
225
225
|
});
|
|
226
226
|
|
|
227
227
|
// src/loadSkiaWeb.ts
|
|
228
|
-
import { Platform as Platform2 } from "react-native";
|
|
229
228
|
function loadSkiaWeb() {
|
|
230
|
-
|
|
231
|
-
return import("@shopify/react-native-skia/src/web").then((m) => m.LoadSkiaWeb());
|
|
229
|
+
return Promise.resolve();
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
// src/PressAwayOverlay.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/hud",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Visual component kit for local-multiplayer React Native games: inline (non-modal) popovers, dropdowns, color pickers, gauges, ready buttons, and dialogs, built to stay scoped to one player's own zone on a shared screen",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
package/src/TriggerGaugeHost.tsx
CHANGED
|
@@ -11,10 +11,9 @@ import { TriggerGaugeProps } from './TriggerGauge'
|
|
|
11
11
|
// file therefore never imports TriggerGauge itself except as a type (erased at compile time,
|
|
12
12
|
// carrying no runtime module reference) — `lazy()` is what actually defers the real import to
|
|
13
13
|
// runtime, after loadSkiaWeb() resolves. Always lazy, on every platform, rather than a native/web
|
|
14
|
-
// branch here
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// clears on the next tick, not a perceptible delay. The Suspense fallback renders nothing, so a
|
|
14
|
+
// branch here, purely to keep this file simple — loadSkiaWeb() itself already resolves immediately
|
|
15
|
+
// on native (see its own file split), so the Suspense boundary there just clears on the next tick,
|
|
16
|
+
// not a perceptible delay. The Suspense fallback renders nothing, so a
|
|
18
17
|
// consumer's trigger icon still shows immediately and the gauge ring just pops in a beat later.
|
|
19
18
|
const LazyTriggerGauge = lazy(() => loadSkiaWeb().then(() => import('./TriggerGauge').then((m) => ({ default: m.TriggerGauge }))))
|
|
20
19
|
|
package/src/loadSkiaWeb.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// that pre-flattens the whole module graph itself (tsup/esbuild) never sees or swaps in a `.web.ts`
|
|
9
|
-
// variant the way a consuming app's own Metro bundler would, so the split has to be a runtime
|
|
10
|
-
// branch that survives being bundled, not a build-time file choice that wouldn't.
|
|
1
|
+
// Native counterpart to loadSkiaWeb.web.ts — Skia on native (via JSI, no WASM) is ready as soon as
|
|
2
|
+
// the app's native module is linked, so there's nothing to actually wait on here. This file must
|
|
3
|
+
// never import '@shopify/react-native-skia/src/web' (even conditionally behind a Platform.OS check):
|
|
4
|
+
// that module pulls in canvaskit-wasm, which does `require('fs')` — a runtime check doesn't stop
|
|
5
|
+
// Metro from statically resolving that import to build the native bundle graph, and Metro has no
|
|
6
|
+
// `fs` for iOS/Android, so the build fails outright. Metro's own platform-extension resolution (this
|
|
7
|
+
// file vs. loadSkiaWeb.web.ts) is what actually keeps the web-only module out of the native graph.
|
|
11
8
|
export function loadSkiaWeb(): Promise<void> {
|
|
12
|
-
|
|
13
|
-
return import('@shopify/react-native-skia/src/web').then((m) => m.LoadSkiaWeb())
|
|
9
|
+
return Promise.resolve()
|
|
14
10
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LoadSkiaWeb } from '@shopify/react-native-skia/src/web'
|
|
2
|
+
|
|
3
|
+
// Skia's web target renders through CanvasKit, a WASM build of Skia fetched at runtime — nothing
|
|
4
|
+
// using @shopify/react-native-skia's React components can draw a single frame until this resolves.
|
|
5
|
+
// Kept as a thin wrapper (rather than importing LoadSkiaWeb directly at call sites) purely so this
|
|
6
|
+
// file's `.ts` counterpart, loadSkiaWeb.ts, gives native an identically-shaped async no-op — Metro's
|
|
7
|
+
// platform-extension resolution picks whichever one matches the bundle target, so canvaskit-wasm's
|
|
8
|
+
// `require('fs')' never even gets resolved into a native/iOS/Android bundle.
|
|
9
|
+
export function loadSkiaWeb(): Promise<void> {
|
|
10
|
+
return LoadSkiaWeb()
|
|
11
|
+
}
|