@joy-ride/joy-ride 0.1.0 → 0.2.1

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
@@ -13,14 +13,22 @@ Drive through any website. Joy Ride turns page elements into a playground for ca
13
13
  <div data-jr-solid>A wall</div>
14
14
  <div data-jr-liquid="paint">Paint</div>
15
15
 
16
- <script type="module" src="https://jakiestfu.github.io/joy-ride/embed.js" data-jr-auto></script>
16
+ <script
17
+ type="module"
18
+ src="https://unpkg.com/@joy-ride/joy-ride@latest/npm/embed.js"
19
+ data-jr-auto
20
+ ></script>
17
21
  ```
18
22
 
19
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).
20
24
 
21
- The root `@joy-ride/joy-ride` npm package is prepared for its first publish. Once available, install it with `npm install @joy-ride/joy-ride` and import `JoyRide from '@joy-ride/joy-ride'` in a client-side entry point. For a script tag, use the `@joy-ride/joy-ride/embed` entry. The hosted script above remains the working option until then.
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)`.
22
26
 
23
- Package owners can follow the [npm publishing guide](docs/npm-publishing.md) for the first publish and later releases.
27
+ Mark an initial destination with `data-jr-arrive-to` to have the car fade in and skid to that element automatically. Without the marker, call `ride.arriveAt(...)` whenever your application wants an arrival.
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.
30
+
31
+ Package owners can follow the [npm publishing guide](docs/npm-publishing.md) for later releases.
24
32
 
25
33
  ## Develop locally
26
34
 
@@ -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://jakiestfu.github.io/joy-ride/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-Bek8gyOY.js";