@orderlyshop/web-components 0.1.0-build.7051 → 0.1.0-build.7056
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 +32 -20
- package/bin/orderly-generate-server-renderers.mjs +624 -0
- package/bin/orderly-hydrate-static-pages.mjs +3 -2
- package/bin/orderly-init-shop.mjs +15 -72
- package/dist/browser/orderly-web-components.define.global.js +94 -83
- package/dist/browser/orderly-web-components.define.global.js.map +1 -1
- package/dist/browser/orderly-web-components.global.js +94 -83
- package/dist/browser/orderly-web-components.global.js.map +1 -1
- package/dist/{default-shop-Qipu74bd.d.ts → default-shop-D3ONKY6z.d.ts} +4 -1
- package/dist/default-shop.d.ts +1 -1
- package/dist/default-shop.js +2 -0
- package/dist/default-shop.js.map +1 -1
- package/dist/define-B607vO7u.d.ts +9 -0
- package/dist/define.d.ts +1 -1
- package/dist/define.js +402 -62
- package/dist/define.js.map +1 -1
- package/dist/index.d.ts +20 -7
- package/dist/index.js +405 -63
- package/dist/index.js.map +1 -1
- package/dist/navigation.js +2 -0
- package/dist/navigation.js.map +1 -1
- package/dist/{shop-Dm2UjjIN.d.ts → shop-D1M9VnvQ.d.ts} +1 -1
- package/dist/shop.d.ts +2 -2
- package/dist/shop.js +391 -51
- package/dist/shop.js.map +1 -1
- package/dist/stores.js +43 -2
- package/dist/stores.js.map +1 -1
- package/examples/shop/README.md +6 -4
- package/examples/shop/package.json +2 -2
- package/examples/shop/src/includes/head.html +1 -1
- package/examples/shop/vite.config.mjs +2 -67
- package/package.json +7 -3
- package/server/README.md +57 -80
- package/server/ssr.mjs +783 -0
- package/server/vite.mjs +48 -0
- package/dist/define-jKa_4XhP.d.ts +0 -9
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ npx orderly-init-shop --account-id 00000000-0000-0000-0000-000000000000
|
|
|
28
28
|
|
|
29
29
|
Re-running `npx orderly-init-shop` in an existing shop is non-destructive by default. Existing scaffold files are left unchanged with warnings, while missing new scaffold files are added. Use `--force` only when you explicitly want scaffold files overwritten.
|
|
30
30
|
|
|
31
|
-
The scaffold uses Vite for local development and static builds, but Vite is added to the generated shop's `devDependencies`. Consumers should test locally from `http://localhost:61677` or `https://localhost:61677` because those are the expected local development origins for backend CORS. The generated Vite setup defaults to `http://localhost:61677`; if a local reverse proxy or TLS terminator is added, keep the same `localhost:61677` origin over HTTPS. `@orderlyshop/web-components` does not depend on Vite at runtime.
|
|
31
|
+
The scaffold uses Vite for local development and static builds, but Vite is added to the generated shop's `devDependencies`. Dev mode SSR for product/category URLs is enabled by default, so View Source on local category/product URLs shows semantic server-rendered markup. Consumers should test locally from `http://localhost:61677` or `https://localhost:61677` because those are the expected local development origins for backend CORS. The generated Vite setup defaults to `http://localhost:61677`; if a local reverse proxy or TLS terminator is added, keep the same `localhost:61677` origin over HTTPS. `@orderlyshop/web-components` does not depend on Vite at runtime.
|
|
32
32
|
|
|
33
33
|
## Browser Standalone Bundle
|
|
34
34
|
|
|
@@ -377,7 +377,7 @@ Build with generated category pages and then clean the generated source files. S
|
|
|
377
377
|
npx orderly-build-category-pages
|
|
378
378
|
```
|
|
379
379
|
|
|
380
|
-
`orderly-build-category-pages` also hydrates the built `dist/index.html` and generated `dist/categories/**/index.html` pages with SEO-friendly fallback HTML. The hydration step embeds
|
|
380
|
+
`orderly-build-category-pages` also hydrates the built `dist/index.html` and generated `dist/categories/**/index.html` pages with SEO-friendly fallback HTML. The hydration step embeds semantic product cards per category using `SearchService.Search`; it reads `--base-url`, `VITE_ORDERLY_BASE_URL`, or `ORDERLY_BASE_URL`, and otherwise uses the default `https://service.orderly.shop` backend. Live web components read the semantic fallback as initial state, hide it, and then continue as normal client components.
|
|
381
381
|
|
|
382
382
|
Hydrate an already-built site manually, for example in a nightly job:
|
|
383
383
|
|
|
@@ -389,6 +389,26 @@ Use `--skip-products` for metadata-only hydration, `--strict-products` when a ni
|
|
|
389
389
|
|
|
390
390
|
The category generator expects `src/navigation.ts` or `src/navigation.js` to export `navigationDefinitions` and the template page to contain `<orderly-category-page></orderly-category-page>`. TypeScript navigation files use the current shop project's `typescript` dependency for one-off transpilation. Useful options include `--navigation`, `--template`, `--categories-dir`, `--site-title`, `--component-tag`, and `--export`. The older `--taxonomy` flag and `categoryDefinitions` export are still accepted as compatibility aliases.
|
|
391
391
|
|
|
392
|
+
## Local SSR Dev Mode
|
|
393
|
+
|
|
394
|
+
Scaffolded shops use SSR in dev mode by default through the package Vite middleware:
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
import { orderlySsrDevServer } from "@orderlyshop/web-components/server/vite";
|
|
398
|
+
|
|
399
|
+
export default defineConfig({
|
|
400
|
+
plugins: [htmlIncludes(), orderlySsrDevServer(), rootHtmlOutput()]
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
When you run `npm run dev`, product and category URLs such as `http://localhost:61677/products/example.html/` and `http://localhost:61677/categories/sko/` are served from the normal `src/product.html` and `src/category.html` templates with semantic SSR HTML injected before Vite transforms the page. Use browser View Source to inspect the server-rendered markup.
|
|
405
|
+
|
|
406
|
+
SSR responses include a small inline critical CSS block for the semantic fallback markup. Normal browser requests hide that fallback and route component light DOM, such as utility banners, until the web components hydrate, so users do not see an unstyled intermediate layout. Googlebot user agents receive the visible fallback layout instead. The HTML source is identical in both cases; only fallback visibility changes.
|
|
407
|
+
|
|
408
|
+
After the first SSR entry render, the default storefront router intercepts same-origin category, product, checkout, payment-result, and configured static-page links. Navigation then stays virtual with `pushState` and persistent app-shell state, while the anchors still keep real `href` values for SEO, no-JS clients, copied links, and direct entry URLs. Set `storefrontRouter: { enabled: false }` only if the host app deliberately wants physical navigation after every click.
|
|
409
|
+
|
|
410
|
+
Set `ORDERLY_DEV_SSR=0` or run `npm run dev -- --no-ssr` to debug pure client-side rendering. Dev SSR uses `VITE_ORDERLY_BASE_URL`, `ORDERLY_BASE_URL`, or `https://service.orderly.shop`, defaults to `grpc-web`, and keeps a short per-URL in-memory cache. Override the cache with `ORDERLY_DEV_SSR_CACHE_TTL_MS`.
|
|
411
|
+
|
|
392
412
|
## Publish Static Sites
|
|
393
413
|
|
|
394
414
|
Installing `@orderlyshop/web-components` also installs a publish command for the consuming shop project. Run it from the project directory. The command generates category pages, builds, hydrates the built homepage/category pages, and publishes the resulting `dist` folder as vanilla HTML/JS/CSS.
|
|
@@ -419,33 +439,25 @@ Re-enter saved FTP settings:
|
|
|
419
439
|
npx orderly-publish-site --target ftp --configure
|
|
420
440
|
```
|
|
421
441
|
|
|
422
|
-
## Server Side Product URLs
|
|
423
|
-
|
|
424
|
-
Category pages can be generated and hydrated statically. Product pages usually need real URLs without generating one HTML file per product. The package ships server helper files under `server/` for this pattern:
|
|
442
|
+
## Server Side Product And Category URLs
|
|
425
443
|
|
|
426
|
-
|
|
427
|
-
- `server/php/orderly-product.php` reuses the built `product.html`, injects declarative SSR fallback markup into `<orderly-product-detail-page>`, and preserves built JS/CSS references.
|
|
428
|
-
- `server/nginx/orderly-products.conf` provides the equivalent Nginx rewrite for PHP-FPM.
|
|
429
|
-
- `server/node/product-snapshot-server.mjs` is an optional Node snapshot endpoint that calls `SearchService.Search` through `@orderlyshop/core-client` and returns product title, brand, price, image, and description as JSON.
|
|
430
|
-
|
|
431
|
-
Apache deployment example:
|
|
444
|
+
Production SSR for Apache/PHP is generated into the built site:
|
|
432
445
|
|
|
433
446
|
```sh
|
|
434
447
|
npm run build
|
|
435
|
-
|
|
436
|
-
cp node_modules/@orderlyshop/web-components/server/php/orderly-product.php dist/orderly-product.php
|
|
448
|
+
npx orderly-generate-server-renderers --site-title "My Shop"
|
|
437
449
|
```
|
|
438
450
|
|
|
439
|
-
|
|
451
|
+
Scaffolded shops run that generator from `npm run build` by default. It writes `dist/product.php`, `dist/category.php`, `dist/.htaccess`, and `dist/orderly-ssr-manifest.json`. The PHP renderers call `SearchService.Search` over gRPC-web, inject semantic HTML into the built `product.html` or `category.html`, and preserve the normal web-component scripts and styles.
|
|
440
452
|
|
|
441
|
-
|
|
442
|
-
ORDERLY_BACKEND_URL=https://service.orderly.shop \
|
|
443
|
-
node node_modules/@orderlyshop/web-components/server/node/product-snapshot-server.mjs
|
|
453
|
+
Runtime options:
|
|
444
454
|
|
|
445
|
-
|
|
446
|
-
|
|
455
|
+
- `ORDERLY_BASE_URL` overrides the backend URL used by PHP.
|
|
456
|
+
- `ORDERLY_SSR_TIMEOUT` controls PHP backend timeout in seconds.
|
|
457
|
+
- `ORDERLY_SSR_HEADERS` can add internal server-side request headers. Do not expose API keys or bearer tokens to browser JavaScript.
|
|
458
|
+
- `ORDERLY_SSR_MANIFEST` can point PHP to a manifest outside the web root.
|
|
447
459
|
|
|
448
|
-
The
|
|
460
|
+
The semantic fallback uses real headings, links, images, schema.org Product/Offer metadata, and small `data-orderly-*` attributes only for behavior-critical values. Components hydrate from that HTML, then hide the fallback and continue as normal interactive web components. Generated SSR output keeps the same HTML for users and crawlers, hides fallback visibility for normal browser hydration, and serves a visible fallback layout to Googlebot. See [`server/README.md`](./server/README.md) for details.
|
|
449
461
|
|
|
450
462
|
## Define Elements
|
|
451
463
|
|