lanre-ds 0.0.0-stage → 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/LICENSE +21 -0
- package/components/buttons/Button.d.ts +28 -0
- package/components/buttons/Button.jsx +50 -0
- package/components/buttons/Button.prompt.md +16 -0
- package/components/buttons/IconButton.d.ts +23 -0
- package/components/buttons/IconButton.jsx +53 -0
- package/components/buttons/IconButton.prompt.md +12 -0
- package/components/buttons/SegmentedTabs.d.ts +21 -0
- package/components/buttons/SegmentedTabs.jsx +15 -0
- package/components/buttons/SegmentedTabs.prompt.md +10 -0
- package/components/contributor/AudioRecorder.d.ts +27 -0
- package/components/contributor/AudioRecorder.jsx +79 -0
- package/components/contributor/AudioRecorder.prompt.md +13 -0
- package/components/contributor/RadioCard.d.ts +17 -0
- package/components/contributor/RadioCard.jsx +30 -0
- package/components/contributor/RadioCard.prompt.md +12 -0
- package/components/contributor/RecorderPanel.d.ts +30 -0
- package/components/contributor/RecorderPanel.jsx +49 -0
- package/components/contributor/RecorderPanel.prompt.md +11 -0
- package/components/contributor/StepBar.d.ts +17 -0
- package/components/contributor/StepBar.jsx +55 -0
- package/components/contributor/StepBar.prompt.md +12 -0
- package/components/contributor/TextField.d.ts +25 -0
- package/components/contributor/TextField.jsx +29 -0
- package/components/contributor/TextField.prompt.md +7 -0
- package/components/contributor/UploadTile.d.ts +39 -0
- package/components/contributor/UploadTile.jsx +116 -0
- package/components/contributor/UploadTile.prompt.md +21 -0
- package/components/contributor/WorldChip.d.ts +18 -0
- package/components/contributor/WorldChip.jsx +16 -0
- package/components/contributor/WorldChip.prompt.md +9 -0
- package/components/contributor/WorldOption.d.ts +19 -0
- package/components/contributor/WorldOption.jsx +19 -0
- package/components/contributor/WorldOption.prompt.md +11 -0
- package/components/contributor/WorldSign.d.ts +25 -0
- package/components/contributor/WorldSign.jsx +32 -0
- package/components/contributor/WorldSign.prompt.md +14 -0
- package/components/contributor/WorldSigns.d.ts +13 -0
- package/components/contributor/WorldSigns.jsx +12 -0
- package/components/contributor/WorldSigns.prompt.md +8 -0
- package/components/effects/Confetti.d.ts +14 -0
- package/components/effects/Confetti.jsx +38 -0
- package/components/effects/Confetti.prompt.md +12 -0
- package/components/effects/Sparkles.d.ts +9 -0
- package/components/effects/Sparkles.jsx +13 -0
- package/components/effects/Sparkles.prompt.md +11 -0
- package/components/effects/Sunburst.d.ts +23 -0
- package/components/effects/Sunburst.jsx +26 -0
- package/components/effects/Sunburst.prompt.md +12 -0
- package/components/feedback/Badge.d.ts +17 -0
- package/components/feedback/Badge.jsx +16 -0
- package/components/feedback/Badge.prompt.md +10 -0
- package/components/feedback/ErrorText.d.ts +11 -0
- package/components/feedback/ErrorText.jsx +8 -0
- package/components/feedback/ErrorText.prompt.md +9 -0
- package/components/feedback/LoadingScreen.d.ts +14 -0
- package/components/feedback/LoadingScreen.jsx +24 -0
- package/components/feedback/LoadingScreen.prompt.md +9 -0
- package/components/feedback/Notice.d.ts +15 -0
- package/components/feedback/Notice.jsx +16 -0
- package/components/feedback/Notice.prompt.md +10 -0
- package/components/feedback/SaveAlert.d.ts +15 -0
- package/components/feedback/SaveAlert.jsx +24 -0
- package/components/feedback/SaveAlert.prompt.md +9 -0
- package/components/feedback/SavePill.d.ts +13 -0
- package/components/feedback/SavePill.jsx +29 -0
- package/components/feedback/SavePill.prompt.md +8 -0
- package/components/feedback/SoundToggle.d.ts +16 -0
- package/components/feedback/SoundToggle.jsx +15 -0
- package/components/feedback/SoundToggle.prompt.md +6 -0
- package/components/feedback/Sticker.d.ts +15 -0
- package/components/feedback/Sticker.jsx +12 -0
- package/components/feedback/Sticker.prompt.md +9 -0
- package/components/feedback/Tag.d.ts +15 -0
- package/components/feedback/Tag.jsx +15 -0
- package/components/feedback/Tag.prompt.md +10 -0
- package/components/feedback/Toast.d.ts +21 -0
- package/components/feedback/Toast.jsx +19 -0
- package/components/feedback/Toast.prompt.md +7 -0
- package/components/forms/Slider.d.ts +24 -0
- package/components/forms/Slider.jsx +28 -0
- package/components/forms/Slider.prompt.md +6 -0
- package/components/forms/Switch.d.ts +19 -0
- package/components/forms/Switch.jsx +20 -0
- package/components/forms/Switch.prompt.md +6 -0
- package/components/games/MatchCard.d.ts +18 -0
- package/components/games/MatchCard.jsx +27 -0
- package/components/games/MatchCard.prompt.md +11 -0
- package/components/hud/Countdown.d.ts +33 -0
- package/components/hud/Countdown.jsx +74 -0
- package/components/hud/Countdown.prompt.md +15 -0
- package/components/hud/CurrencyPill.d.ts +24 -0
- package/components/hud/CurrencyPill.jsx +34 -0
- package/components/hud/CurrencyPill.prompt.md +12 -0
- package/components/hud/HudBar.d.ts +18 -0
- package/components/hud/HudBar.jsx +14 -0
- package/components/hud/HudBar.prompt.md +15 -0
- package/components/hud/HudChip.d.ts +25 -0
- package/components/hud/HudChip.jsx +30 -0
- package/components/hud/HudChip.prompt.md +13 -0
- package/components/hud/ProgressBar.d.ts +27 -0
- package/components/hud/ProgressBar.jsx +39 -0
- package/components/hud/ProgressBar.prompt.md +11 -0
- package/components/hud/TimerChip.d.ts +19 -0
- package/components/hud/TimerChip.jsx +17 -0
- package/components/hud/TimerChip.prompt.md +7 -0
- package/components/icons/GameIcon.d.ts +25 -0
- package/components/icons/GameIcon.jsx +43 -0
- package/components/icons/GameIcon.prompt.md +13 -0
- package/components/identity/Avatar.d.ts +26 -0
- package/components/identity/Avatar.jsx +31 -0
- package/components/identity/Avatar.prompt.md +11 -0
- package/components/identity/AvatarButton.d.ts +19 -0
- package/components/identity/AvatarButton.jsx +13 -0
- package/components/identity/AvatarButton.prompt.md +8 -0
- package/components/identity/Gemstone.d.ts +28 -0
- package/components/identity/Gemstone.jsx +46 -0
- package/components/identity/Gemstone.prompt.md +15 -0
- package/components/identity/PersonTile.d.ts +22 -0
- package/components/identity/PersonTile.jsx +27 -0
- package/components/identity/PersonTile.prompt.md +10 -0
- package/components/levels/ChoiceButton.d.ts +20 -0
- package/components/levels/ChoiceButton.jsx +31 -0
- package/components/levels/ChoiceButton.prompt.md +10 -0
- package/components/map/DiscoveryMarker.d.ts +19 -0
- package/components/map/DiscoveryMarker.jsx +31 -0
- package/components/map/DiscoveryMarker.prompt.md +11 -0
- package/components/map/LevelNode.d.ts +19 -0
- package/components/map/LevelNode.jsx +37 -0
- package/components/map/LevelNode.prompt.md +11 -0
- package/components/map/PortraitMedallion.d.ts +27 -0
- package/components/map/PortraitMedallion.jsx +29 -0
- package/components/map/PortraitMedallion.prompt.md +14 -0
- package/components/map/StarRating.d.ts +22 -0
- package/components/map/StarRating.jsx +21 -0
- package/components/map/StarRating.prompt.md +6 -0
- package/components/map/Tile.d.ts +22 -0
- package/components/map/Tile.jsx +32 -0
- package/components/map/Tile.prompt.md +8 -0
- package/components/map/WorldGate.d.ts +21 -0
- package/components/map/WorldGate.jsx +27 -0
- package/components/map/WorldGate.prompt.md +13 -0
- package/components/map/worlds.d.ts +18 -0
- package/components/map/worlds.js +9 -0
- package/components/media/Album.d.ts +33 -0
- package/components/media/Album.jsx +157 -0
- package/components/media/Album.prompt.md +16 -0
- package/components/media/Cassette.d.ts +23 -0
- package/components/media/Cassette.jsx +64 -0
- package/components/media/Cassette.prompt.md +13 -0
- package/components/media/Film.d.ts +20 -0
- package/components/media/Film.jsx +39 -0
- package/components/media/Film.prompt.md +14 -0
- package/components/media/MemoryText.d.ts +20 -0
- package/components/media/MemoryText.jsx +14 -0
- package/components/media/MemoryText.prompt.md +9 -0
- package/components/media/Unavailable.d.ts +13 -0
- package/components/media/Unavailable.jsx +13 -0
- package/components/media/Unavailable.prompt.md +10 -0
- package/components/media/Words.d.ts +21 -0
- package/components/media/Words.jsx +57 -0
- package/components/media/Words.prompt.md +12 -0
- package/components/media/shared.js +19 -0
- package/components/panels/Modal.d.ts +25 -0
- package/components/panels/Modal.jsx +68 -0
- package/components/panels/Modal.prompt.md +20 -0
- package/components/panels/Panel.d.ts +29 -0
- package/components/panels/Panel.jsx +109 -0
- package/components/panels/Panel.prompt.md +13 -0
- package/components/quiz/LeaderboardRow.d.ts +26 -0
- package/components/quiz/LeaderboardRow.jsx +24 -0
- package/components/quiz/LeaderboardRow.prompt.md +10 -0
- package/components/rewards/ItemCell.d.ts +24 -0
- package/components/rewards/ItemCell.jsx +24 -0
- package/components/rewards/ItemCell.prompt.md +9 -0
- package/components/rewards/RewardCard.d.ts +24 -0
- package/components/rewards/RewardCard.jsx +34 -0
- package/components/rewards/RewardCard.prompt.md +8 -0
- package/components/rewards/ShopRow.d.ts +23 -0
- package/components/rewards/ShopRow.jsx +26 -0
- package/components/rewards/ShopRow.prompt.md +7 -0
- package/components/text/Heading.d.ts +19 -0
- package/components/text/Heading.jsx +15 -0
- package/components/text/Heading.prompt.md +10 -0
- package/components/text/OutlineText.d.ts +24 -0
- package/components/text/OutlineText.jsx +20 -0
- package/components/text/OutlineText.prompt.md +11 -0
- package/components/toolbar/FastTravelDock.d.ts +50 -0
- package/components/toolbar/FastTravelDock.jsx +36 -0
- package/components/toolbar/FastTravelDock.prompt.md +12 -0
- package/components/toolbar/Toolbar.d.ts +16 -0
- package/components/toolbar/Toolbar.jsx +8 -0
- package/components/toolbar/Toolbar.prompt.md +14 -0
- package/components/toolbar/ToolbarNext.d.ts +21 -0
- package/components/toolbar/ToolbarNext.jsx +21 -0
- package/components/toolbar/ToolbarNext.prompt.md +13 -0
- package/components/toolbar/ToolbarTab.d.ts +15 -0
- package/components/toolbar/ToolbarTab.jsx +12 -0
- package/components/toolbar/ToolbarTab.prompt.md +9 -0
- package/components/viewer/ClueCard.d.ts +18 -0
- package/components/viewer/ClueCard.jsx +14 -0
- package/components/viewer/ClueCard.prompt.md +9 -0
- package/components/viewer/ClueTab.d.ts +16 -0
- package/components/viewer/ClueTab.jsx +12 -0
- package/components/viewer/ClueTab.prompt.md +8 -0
- package/components/viewer/RevealTray.d.ts +54 -0
- package/components/viewer/RevealTray.jsx +58 -0
- package/components/viewer/RevealTray.prompt.md +21 -0
- package/components/viewer/RoadsideViewer.d.ts +60 -0
- package/components/viewer/RoadsideViewer.jsx +96 -0
- package/components/viewer/RoadsideViewer.prompt.md +20 -0
- package/components/viewer/ViewerKeys.d.ts +26 -0
- package/components/viewer/ViewerKeys.jsx +22 -0
- package/components/viewer/ViewerKeys.prompt.md +14 -0
- package/components/viewer/ViewerKnob.d.ts +20 -0
- package/components/viewer/ViewerKnob.jsx +12 -0
- package/components/viewer/ViewerKnob.prompt.md +11 -0
- package/components/viewer/WhoButton.d.ts +21 -0
- package/components/viewer/WhoButton.jsx +15 -0
- package/components/viewer/WhoButton.prompt.md +10 -0
- package/package.json +62 -4
- package/readme.md +145 -0
- package/styles.css +15 -0
- package/tokens/colors.css +140 -0
- package/tokens/effects.css +40 -0
- package/tokens/fonts.css +3 -0
- package/tokens/fx.css +186 -0
- package/tokens/gems.css +8 -0
- package/tokens/hud.css +510 -0
- package/tokens/icons.css +7 -0
- package/tokens/media.css +774 -0
- package/tokens/signs.css +459 -0
- package/tokens/spacing.css +38 -0
- package/tokens/typography.css +34 -0
- package/tokens/ui.css +432 -0
- package/tokens/utilities.css +34 -0
- package/tokens/viewer.css +1176 -0
- package/tokens/worlds.css +73 -0
- package/tools/ds-loader.js +60 -0
- package/README.md +0 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* World themes for the Birthday Adventure. Put data-world="<id>" on a screen, section or component root;
|
|
2
|
+
everything inside reads --world-*. Defaults (:root) are the generic meadow. Summit is the author’s letter, not a contributor world.
|
|
3
|
+
Scenery: --world-sky-low is the sky's horizon colour (the sky runs --world-sky → --world-sky-low), and --prop-hill and
|
|
4
|
+
--prop-bush-hi / --prop-bush / --prop-bush-lo paint the CSS hills and bushes that stand in for painted art. */
|
|
5
|
+
:root {
|
|
6
|
+
--world-name: "Meadow";
|
|
7
|
+
--world-sky: oklch(0.85 0.17 132); --world-ground: oklch(0.74 0.19 136); --world-ground-deep: oklch(0.58 0.16 140);
|
|
8
|
+
--world-accent: var(--blue-500); --world-accent-shade: var(--blue-700);
|
|
9
|
+
--world-path: var(--cream-200); --world-path-edge: var(--wood-300); --world-stroke: var(--ink-900);
|
|
10
|
+
--world-bg: linear-gradient(180deg, var(--world-sky) 0%, var(--world-ground) 55%, var(--world-ground-deep) 100%);
|
|
11
|
+
--world-sky-low: var(--green-100);
|
|
12
|
+
--prop-hill: var(--green-300); --prop-bush-hi: var(--green-100); --prop-bush: var(--green-500); --prop-bush-lo: var(--green-700);
|
|
13
|
+
}
|
|
14
|
+
/* 0 · Base Camp: the contributor world. Friends gather where the road begins and pack their memories for it.
|
|
15
|
+
Not a stop on the road, so it never appears in the map, the dock or a world picker. */
|
|
16
|
+
[data-world="base_camp"] {
|
|
17
|
+
--world-name: "Base Camp";
|
|
18
|
+
--world-sky: oklch(0.74 0.10 245); --world-ground: oklch(0.66 0.13 158); --world-ground-deep: oklch(0.44 0.08 172);
|
|
19
|
+
--world-accent: var(--gold-500); --world-accent-shade: var(--gold-700);
|
|
20
|
+
--world-path: var(--cream-200); --world-path-edge: var(--wood-300); --world-stroke: oklch(0.34 0.09 250);
|
|
21
|
+
--world-bg: linear-gradient(180deg, oklch(0.74 0.10 245) 0%, oklch(0.66 0.13 158) 55%, oklch(0.44 0.08 172) 100%);
|
|
22
|
+
--world-sky-low: oklch(0.92 0.07 72);
|
|
23
|
+
--prop-hill: oklch(0.76 0.11 150); --prop-bush-hi: oklch(0.86 0.12 145); --prop-bush: oklch(0.70 0.14 152); --prop-bush-lo: oklch(0.52 0.12 162);
|
|
24
|
+
}
|
|
25
|
+
/* 1 · Mango Grove: first impressions, meeting, early memories. Sunny mango orchard. */
|
|
26
|
+
[data-world="mango_grove"] {
|
|
27
|
+
--world-name: "Mango Grove";
|
|
28
|
+
--world-sky: oklch(0.93 0.09 95); --world-ground: oklch(0.80 0.16 118); --world-ground-deep: oklch(0.62 0.15 130);
|
|
29
|
+
--world-accent: oklch(0.78 0.17 62); --world-accent-shade: oklch(0.60 0.16 50);
|
|
30
|
+
--world-path: oklch(0.90 0.06 80); --world-path-edge: oklch(0.72 0.10 65); --world-stroke: oklch(0.42 0.10 70);
|
|
31
|
+
--world-bg: linear-gradient(180deg, oklch(0.93 0.09 95) 0%, oklch(0.80 0.16 118) 55%, oklch(0.62 0.15 130) 100%);
|
|
32
|
+
--world-sky-low: oklch(0.96 0.06 95);
|
|
33
|
+
--prop-hill: oklch(0.86 0.13 112); --prop-bush-hi: var(--green-100); --prop-bush: var(--green-500); --prop-bush-lo: var(--green-700);
|
|
34
|
+
}
|
|
35
|
+
/* 2 · Small Chops, Big Gist, funny stories, inside jokes, outings. Restaurants, rice, lively stalls. */
|
|
36
|
+
[data-world="small_chops"] {
|
|
37
|
+
--world-name: "Small Chops, Big Gist";
|
|
38
|
+
--world-sky: oklch(0.88 0.08 60); --world-ground: oklch(0.74 0.12 45); --world-ground-deep: oklch(0.56 0.12 35);
|
|
39
|
+
--world-accent: oklch(0.66 0.21 28); --world-accent-shade: oklch(0.50 0.18 25);
|
|
40
|
+
--world-path: oklch(0.84 0.05 60); --world-path-edge: oklch(0.60 0.07 50); --world-stroke: oklch(0.36 0.09 35);
|
|
41
|
+
--world-bg: linear-gradient(180deg, oklch(0.88 0.08 60) 0%, oklch(0.74 0.12 45) 55%, oklch(0.56 0.12 35) 100%);
|
|
42
|
+
--world-sky-low: oklch(0.94 0.05 70);
|
|
43
|
+
--prop-hill: oklch(0.80 0.10 50); --prop-bush-hi: oklch(0.90 0.10 75); --prop-bush: oklch(0.76 0.14 60); --prop-bush-lo: oklch(0.58 0.13 45);
|
|
44
|
+
}
|
|
45
|
+
/* 3 · The Good Energy Hills, appreciation, support, showing up. Green hills with gentle workout details. */
|
|
46
|
+
[data-world="good_energy"] {
|
|
47
|
+
--world-name: "The Good Energy Hills";
|
|
48
|
+
--world-sky: oklch(0.90 0.07 205); --world-ground: oklch(0.78 0.17 145); --world-ground-deep: oklch(0.58 0.15 148);
|
|
49
|
+
--world-accent: oklch(0.74 0.14 185); --world-accent-shade: oklch(0.56 0.12 185);
|
|
50
|
+
--world-path: oklch(0.92 0.04 90); --world-path-edge: oklch(0.70 0.08 80); --world-stroke: oklch(0.38 0.09 150);
|
|
51
|
+
--world-bg: linear-gradient(180deg, oklch(0.90 0.07 205) 0%, oklch(0.78 0.17 145) 55%, oklch(0.58 0.15 148) 100%);
|
|
52
|
+
--world-sky-low: oklch(0.95 0.04 190);
|
|
53
|
+
--prop-hill: oklch(0.84 0.14 140); --prop-bush-hi: var(--green-100); --prop-bush: var(--green-500); --prop-bush-lo: var(--green-700);
|
|
54
|
+
}
|
|
55
|
+
/* 4 · Someday in Japan, wishes, future adventures, hopes. Lanterns, gardens, distant mountain. */
|
|
56
|
+
[data-world="japan"] {
|
|
57
|
+
--world-name: "Someday in Japan";
|
|
58
|
+
--world-sky: oklch(0.84 0.08 340); --world-ground: oklch(0.68 0.10 300); --world-ground-deep: oklch(0.50 0.12 295);
|
|
59
|
+
--world-accent: oklch(0.64 0.21 25); --world-accent-shade: oklch(0.48 0.18 22);
|
|
60
|
+
--world-path: oklch(0.86 0.02 280); --world-path-edge: oklch(0.62 0.04 285); --world-stroke: oklch(0.36 0.10 300);
|
|
61
|
+
--world-blossom: oklch(0.88 0.09 350);
|
|
62
|
+
--world-bg: linear-gradient(180deg, oklch(0.84 0.08 340) 0%, oklch(0.68 0.10 300) 55%, oklch(0.50 0.12 295) 100%);
|
|
63
|
+
--world-sky-low: oklch(0.92 0.05 350);
|
|
64
|
+
--prop-hill: oklch(0.76 0.08 305); --prop-bush-hi: oklch(0.92 0.08 350); --prop-bush: oklch(0.80 0.11 350); --prop-bush-lo: oklch(0.62 0.12 340);
|
|
65
|
+
}
|
|
66
|
+
/* 5 · Summit: The author’s letter. Golden hour above the clouds. No scenery props here: the letter uses the night palette (colors.css). */
|
|
67
|
+
[data-world="summit"] {
|
|
68
|
+
--world-name: "The Summit";
|
|
69
|
+
--world-sky: oklch(0.34 0.10 285); --world-ground: oklch(0.62 0.15 55); --world-ground-deep: oklch(0.44 0.12 45);
|
|
70
|
+
--world-accent: var(--gold-500); --world-accent-shade: var(--gold-700);
|
|
71
|
+
--world-path: var(--gold-300); --world-path-edge: var(--gold-700); --world-stroke: oklch(0.30 0.07 50);
|
|
72
|
+
--world-bg: linear-gradient(180deg, oklch(0.34 0.10 285) 0%, oklch(0.62 0.15 55) 60%, oklch(0.44 0.12 45) 100%);
|
|
73
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* Lanre preview loader.
|
|
2
|
+
1) Tries the compiled runtime bundle (_ds_bundle.js) and detects its namespace.
|
|
3
|
+
2) If the bundle is missing or stale, transpiles the listed components/<group>/<Name>.jsx in-browser (Babel) instead.
|
|
4
|
+
Exposes window.MP (component registry) and window.MPReady (Promise<registry>).
|
|
5
|
+
Usage: <script src="tools/ds-loader.js" data-root="." data-components="buttons/Button,hud/CurrencyPill"></script> */
|
|
6
|
+
(function () {
|
|
7
|
+
var script = document.currentScript;
|
|
8
|
+
var ROOT = (script.getAttribute('data-root') || '.').replace(/\/$/, '');
|
|
9
|
+
var list = (script.getAttribute('data-components') || '').split(',').map(function (s) { return s.trim(); }).filter(Boolean);
|
|
10
|
+
var KNOWN = ['Lanre', 'LanreDS', 'LanreGameUIDesignSystem', 'ExplorationGamingDesignSystem', 'DS', 'DesignSystem'];
|
|
11
|
+
var registry = {};
|
|
12
|
+
window.MP = registry;
|
|
13
|
+
|
|
14
|
+
function hasFns(v) { try { return v && typeof v === 'object' && Object.keys(v).some(function (k) { return typeof v[k] === 'function' && /^[A-Z]/.test(k); }); } catch (e) { return false; } }
|
|
15
|
+
function findNS(before) {
|
|
16
|
+
for (var i = 0; i < KNOWN.length; i++) { if (hasFns(window[KNOWN[i]])) return window[KNOWN[i]]; }
|
|
17
|
+
var keys = Object.keys(window);
|
|
18
|
+
for (var j = 0; j < keys.length; j++) { var k = keys[j]; if (before[k]) continue; try { if (hasFns(window[k])) return window[k]; } catch (e) {} }
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function loadScript(src) { return new Promise(function (res, rej) { var s = document.createElement('script'); s.src = src; s.onload = res; s.onerror = rej; document.head.appendChild(s); }); }
|
|
22
|
+
function normalize(p) { var parts = []; p.split('/').forEach(function (seg) { if (seg === '..') parts.pop(); else if (seg !== '.' && seg !== '') parts.push(seg); }); return parts.join('/'); }
|
|
23
|
+
|
|
24
|
+
var cache = {};
|
|
25
|
+
async function loadModule(path) {
|
|
26
|
+
if (cache[path]) return cache[path];
|
|
27
|
+
var url = ROOT + '/' + path;
|
|
28
|
+
var res = null, err = null;
|
|
29
|
+
for (var attempt = 0; attempt < 4 && !res; attempt++) { // transient network hiccups happen when many previews load at once
|
|
30
|
+
try { var r = await fetch(url); if (r.ok) res = r; else if (r.status === 404) throw new Error('ds-loader: cannot fetch ' + url); } catch (e) { err = e; if (/cannot fetch/.test(String(e.message))) throw e; await new Promise(function (ok) { setTimeout(ok, 250 * (attempt + 1)); }); }
|
|
31
|
+
}
|
|
32
|
+
if (!res) throw err || new Error('ds-loader: cannot fetch ' + url);
|
|
33
|
+
var src = await res.text();
|
|
34
|
+
var dir = path.slice(0, path.lastIndexOf('/') + 1);
|
|
35
|
+
var deps = {}; var re = /from\s+['"]([^'"]+)['"]/g; var m;
|
|
36
|
+
while ((m = re.exec(src))) { var spec = m[1]; if (spec[0] === '.') { var p = normalize(dir + spec); if (!/\.(jsx|js)$/.test(p)) p += '.jsx'; deps[spec] = await loadModule(p); } }
|
|
37
|
+
var out = Babel.transform(src, { presets: [['env', { modules: 'commonjs' }], ['react', { runtime: 'classic' }]], plugins: ['transform-modules-commonjs'], filename: path }).code;
|
|
38
|
+
var module = { exports: {} };
|
|
39
|
+
var require = function (spec) {
|
|
40
|
+
if (spec === 'react') return React; if (spec === 'react-dom') return ReactDOM;
|
|
41
|
+
if (deps[spec]) return deps[spec]; throw new Error('ds-loader: unresolved import ' + spec + ' in ' + path);
|
|
42
|
+
};
|
|
43
|
+
new Function('require', 'module', 'exports', 'React', out)(require, module, module.exports, React);
|
|
44
|
+
cache[path] = module.exports; return module.exports;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
window.MPReady = (async function () {
|
|
48
|
+
var before = {}; Object.keys(window).forEach(function (k) { before[k] = true; });
|
|
49
|
+
var ns = null;
|
|
50
|
+
try {
|
|
51
|
+
var probe = await fetch(ROOT + '/_ds_bundle.js', { method: 'HEAD' });
|
|
52
|
+
if (probe.ok) { await loadScript(ROOT + '/_ds_bundle.js'); ns = findNS(before); }
|
|
53
|
+
} catch (e) { ns = null; }
|
|
54
|
+
var complete = ns && list.every(function (c) { return typeof ns[c.split('/').pop()] === 'function'; });
|
|
55
|
+
if (complete) { Object.assign(registry, ns); registry.__source = 'bundle'; return registry; }
|
|
56
|
+
for (var i = 0; i < list.length; i++) { var mod = await loadModule('components/' + list[i] + '.jsx'); Object.assign(registry, mod); }
|
|
57
|
+
registry.__source = 'jsx';
|
|
58
|
+
return registry;
|
|
59
|
+
})();
|
|
60
|
+
})();
|
package/README.md
DELETED