@panphora/clayjs 1.0.0 → 1.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/README.md +23 -0
- package/dist/clay.standalone.js +22327 -0
- package/entries/clay-data.js +1 -1
- package/package.json +9 -2
- package/src/core/etag.js +127 -0
- package/src/core/host-attrs.js +58 -3
- package/src/core/host-meta.js +20 -3
- package/src/core/is-edit-mode.js +14 -5
- package/src/core/save-conflict-notice.js +191 -0
- package/src/core/save-core.js +329 -7
- package/src/core/save.js +98 -4
- package/src/core/snapshot.js +38 -17
- package/src/core/stale-host-notice.js +95 -0
- package/src/lib/hostile-css.js +49 -0
- package/src/lib/root-attrs.js +62 -7
- package/src/loader-logic.js +44 -0
- package/src/loader.js +11 -5
- package/src/plugins/indicator.js +13 -2
- package/src/plugins/sortable.js +5 -5
- package/src/standalone.js +98 -0
- package/src/sync/live-sync.js +208 -15
- package/src/ui/index.js +7 -0
- package/src/vendor/hypercms.vendor.js +13 -13
- package/src/lib/load-vendor-script.js +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Lazy-load vendor scripts in edit mode only
|
|
3
|
-
|
|
4
|
-
Injects a <script clay="no-save no-watch"> tag that loads the vendor script.
|
|
5
|
-
The clay no-save token ensures it's stripped when the page is saved.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
import { loadVendorScript } from '../lib/load-vendor-script.js';
|
|
9
|
-
|
|
10
|
-
// Load and get global
|
|
11
|
-
const Sortable = await loadVendorScript(url, 'Sortable');
|
|
12
|
-
|
|
13
|
-
// Just load (no return value needed)
|
|
14
|
-
loadVendorScript(url);
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Load a vendor script via script tag with clay no-save
|
|
19
|
-
* @param {string} url - URL to the vendor script
|
|
20
|
-
* @param {Object} [options] - Options
|
|
21
|
-
* @param {string} [options.globalName] - Window property to return when loaded (for classic scripts)
|
|
22
|
-
* @param {boolean} [options.module] - Set true for ES modules (type="module")
|
|
23
|
-
* @returns {Promise<any>} Resolves with window[globalName] or undefined
|
|
24
|
-
*/
|
|
25
|
-
export function loadVendorScript(url, options = {}) {
|
|
26
|
-
// Support legacy signature: loadVendorScript(url, globalName)
|
|
27
|
-
if (typeof options === 'string') {
|
|
28
|
-
options = { globalName: options };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { globalName, module: isModule } = options;
|
|
32
|
-
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const script = document.createElement('script');
|
|
35
|
-
script.src = url;
|
|
36
|
-
script.setAttribute("clay", "no-save no-watch");
|
|
37
|
-
if (isModule) {
|
|
38
|
-
script.type = 'module';
|
|
39
|
-
}
|
|
40
|
-
script.onload = () => resolve(globalName ? window[globalName] : undefined);
|
|
41
|
-
script.onerror = () => reject(new Error(`Failed to load vendor script: ${url}`));
|
|
42
|
-
document.head.appendChild(script);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get vendor URL relative to a module's location
|
|
48
|
-
* @param {string} importMetaUrl - import.meta.url of the calling module
|
|
49
|
-
* @param {string} vendorFile - Filename of the vendor script
|
|
50
|
-
* @returns {string} Full URL to vendor script
|
|
51
|
-
*/
|
|
52
|
-
export function getVendorUrl(importMetaUrl, vendorFile) {
|
|
53
|
-
const baseUrl = importMetaUrl.substring(0, importMetaUrl.lastIndexOf('/'));
|
|
54
|
-
return `${baseUrl}/${vendorFile}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default loadVendorScript;
|