@joy-ride/joy-ride 0.1.1 → 0.2.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/README.md CHANGED
@@ -22,7 +22,11 @@ Drive through any website. Joy Ride turns page elements into a playground for ca
22
22
 
23
23
  The script starts Joy Ride on the page. For custom vehicles, liquid recipes, controls, events, and framework integration, use the [API guide](packages/ui/src/documentation/api.md).
24
24
 
25
- Install the root package with `npm install @joy-ride/joy-ride` and import `JoyRide from '@joy-ride/joy-ride'` in a client-side entry point. The script above loads the same runtime through unpkg and starts it automatically; the module import waits for your call to `JoyRide.mount()`.
25
+ Install the root package with `npm install @joy-ride/joy-ride` and import `JoyRide from '@joy-ride/joy-ride'` in a client-side entry point. The script above loads the same runtime through unpkg and starts it automatically. For a client application that does not install the runtime, dynamically import `https://unpkg.com/@joy-ride/joy-ride@latest/npm/index.js` when needed and call `JoyRide.mount(options)`.
26
+
27
+ Mark an initial destination with `data-jr-arrive-to` to have the car fade in and skid to that element automatically. Add `data-jr-arrive-to-delay-ms="1000"` to start the entrance one second after mount. Without a marker, the embed skids into the viewport center from a random direction. Call `ride.arriveAt({ ...options, delayMs: 1000 })` for a later entrance.
28
+
29
+ For a quieter embed, start with `JoyRide.mount(JoyRide.options.presets.sfw({ workMode: { brandName: 'Drive' } }))`. Override only the settings you need; the preset supplies the rest.
26
30
 
27
31
  Package owners can follow the [npm publishing guide](docs/npm-publishing.md) for later releases.
28
32
 
@@ -1,5 +1,9 @@
1
1
  import { c as PlaygroundConfiguration } from "./playground-xDP5-tDc.js";
2
2
  /** A self-contained bookmark URL that captures the complete configuration. */
3
3
  export declare function bookmarkletUrl(configuration: PlaygroundConfiguration): string;
4
- /** Readable, asynchronous embed for pasting into an HTML page. */
5
- export declare function fullEmbedCode(configuration: PlaygroundConfiguration): string;
4
+ /** A small HTML button that loads the CDN module only on demand. */
5
+ export declare function fullEmbedCode(configuration: PlaygroundConfiguration): string;
6
+ /** Browser-native, on-demand CDN loading for a client-side application or React effect. */
7
+ export declare function asyncEmbedCode(configuration: PlaygroundConfiguration): string;
8
+ /** A bundled client-side entry point, when the host installs the npm package. */
9
+ export declare function npmEmbedCode(configuration: PlaygroundConfiguration): string;
@@ -1,30 +1 @@
1
- var e=`https://unpkg.com/@joy-ride/joy-ride@latest/npm/embed.js`;function t(t){let n=t.definitions?.vehicles;if(!n)return t;let r=typeof document<`u`&&document.baseURI||e;return{...t,definitions:{...t.definitions,vehicles:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{...t,...t.image?.src?{image:{...t.image,src:new URL(t.image.src,r).href}}:{}}]))}}}function n(n){return`javascript:(()=>{const u=${JSON.stringify(e)},o=${JSON.stringify(t(n))},d=window.JoyRide;if(d){d.active?d.active.dispose():d.mount(o);return}const s=document.createElement('script');s.type='module';s.src=u;s.async=true;s.charset='utf-8';s.onload=()=>window.JoyRide.mount(o);document.head.append(s)})()`}function r(n){let r=n.workMode;return`<button type="button" id="joy-ride-toggle">${(r?.brandName??(r?.sfw?`Drive`:`Joy Ride`)).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}</button>
2
- <script>
3
- const joyRideOptions = ${JSON.stringify(t(n),null,2).replace(/</g,`\\u003c`).replace(/\n/g,`
4
- `)};
5
- const joyRideScriptUrl = ${JSON.stringify(e)};
6
- let joyRideLoading;
7
-
8
- function loadJoyRide() {
9
- if (window.JoyRide) return Promise.resolve(window.JoyRide);
10
- return joyRideLoading ??= new Promise((resolve, reject) => {
11
- const script = document.createElement('script');
12
- script.type = 'module';
13
- script.src = joyRideScriptUrl;
14
- script.async = true;
15
- script.charset = 'utf-8';
16
- script.onload = () => resolve(window.JoyRide);
17
- script.onerror = () => {
18
- joyRideLoading = undefined;
19
- reject(new Error('Joy Ride could not load'));
20
- };
21
- document.head.append(script);
22
- });
23
- }
24
-
25
- document.querySelector('#joy-ride-toggle').addEventListener('click', async () => {
26
- const joyRide = await loadJoyRide();
27
- if (joyRide.active) joyRide.active.dispose();
28
- else joyRide.mount(joyRideOptions);
29
- });
30
- <\/script>`}export{n as bookmarkletUrl,r as fullEmbedCode};
1
+ export{t as asyncEmbedCode,n as bookmarkletUrl,r as fullEmbedCode,i as npmEmbedCode}from"./embed-chunks/bookmarklet-DlL5EMxG.js";