@jxsuite/runtime 0.19.0 → 0.21.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/dist/runtime.js +61 -19
- package/dist/runtime.js.map +6 -6
- package/package.json +3 -2
- package/src/runtime.js +198 -99
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
1
|
+
// ../../node_modules/.bun/@vue+shared@3.5.35/node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
2
2
|
function makeMap(str) {
|
|
3
3
|
const map = /* @__PURE__ */ Object.create(null);
|
|
4
4
|
for (const key of str.split(","))
|
|
@@ -46,7 +46,7 @@ var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
|
46
46
|
var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
47
47
|
var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
|
|
48
48
|
|
|
49
|
-
// ../../node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
49
|
+
// ../../node_modules/.bun/@vue+reactivity@3.5.35/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
50
50
|
function warn(msg, ...args) {
|
|
51
51
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
52
52
|
}
|
|
@@ -1091,9 +1091,6 @@ function targetTypeMap(rawType) {
|
|
|
1091
1091
|
return 0;
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
|
-
function getTargetType(value) {
|
|
1095
|
-
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
1096
|
-
}
|
|
1097
1094
|
function reactive(target) {
|
|
1098
1095
|
if (/* @__PURE__ */ isReadonly(target)) {
|
|
1099
1096
|
return target;
|
|
@@ -1113,14 +1110,17 @@ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandl
|
|
|
1113
1110
|
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
1114
1111
|
return target;
|
|
1115
1112
|
}
|
|
1116
|
-
|
|
1117
|
-
if (targetType === 0) {
|
|
1113
|
+
if (target["__v_skip"] || !Object.isExtensible(target)) {
|
|
1118
1114
|
return target;
|
|
1119
1115
|
}
|
|
1120
1116
|
const existingProxy = proxyMap.get(target);
|
|
1121
1117
|
if (existingProxy) {
|
|
1122
1118
|
return existingProxy;
|
|
1123
1119
|
}
|
|
1120
|
+
const targetType = targetTypeMap(toRawType(target));
|
|
1121
|
+
if (targetType === 0) {
|
|
1122
|
+
return target;
|
|
1123
|
+
}
|
|
1124
1124
|
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1125
1125
|
proxyMap.set(target, proxy);
|
|
1126
1126
|
return proxy;
|
|
@@ -1299,6 +1299,10 @@ var _serverFnConfig = { skip: false };
|
|
|
1299
1299
|
function setSkipServerFunctions(v) {
|
|
1300
1300
|
_serverFnConfig.skip = v;
|
|
1301
1301
|
}
|
|
1302
|
+
var _contentConfig = { skip: false };
|
|
1303
|
+
function setSkipContentResolution(v) {
|
|
1304
|
+
_contentConfig.skip = v;
|
|
1305
|
+
}
|
|
1302
1306
|
async function buildScope(doc, parentScope = {}, base = location.href) {
|
|
1303
1307
|
const raw = {};
|
|
1304
1308
|
for (const [key, val] of Object.entries(parentScope)) {
|
|
@@ -1382,8 +1386,9 @@ function hasSchemaKeywords(obj) {
|
|
|
1382
1386
|
return false;
|
|
1383
1387
|
}
|
|
1384
1388
|
function evaluateTemplate(str, state) {
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1389
|
+
const $map = state?.$map;
|
|
1390
|
+
const fn = new Function("state", "$map", "item", "index", `return \`${str}\``);
|
|
1391
|
+
return fn(state, $map, $map?.item, $map?.index);
|
|
1387
1392
|
}
|
|
1388
1393
|
var _moduleCache = new Map;
|
|
1389
1394
|
async function resolveFunction(def2, state, key, base) {
|
|
@@ -1558,23 +1563,24 @@ function applyProperties(el, def2, state) {
|
|
|
1558
1563
|
}
|
|
1559
1564
|
}
|
|
1560
1565
|
function bindProperty(el, key, val, state) {
|
|
1566
|
+
const target = el;
|
|
1561
1567
|
if (isRefObj(val)) {
|
|
1562
1568
|
if (key === "id") {
|
|
1563
|
-
|
|
1569
|
+
target[key] = resolveRef(val.$ref, state);
|
|
1564
1570
|
return;
|
|
1565
1571
|
}
|
|
1566
1572
|
effect(() => {
|
|
1567
|
-
|
|
1573
|
+
target[key] = resolveRef(val.$ref, state);
|
|
1568
1574
|
});
|
|
1569
1575
|
return;
|
|
1570
1576
|
}
|
|
1571
1577
|
if (isTemplateString(val)) {
|
|
1572
1578
|
effect(() => {
|
|
1573
|
-
|
|
1579
|
+
target[key] = evaluateTemplate(val, state);
|
|
1574
1580
|
});
|
|
1575
1581
|
return;
|
|
1576
1582
|
}
|
|
1577
|
-
|
|
1583
|
+
target[key] = val;
|
|
1578
1584
|
}
|
|
1579
1585
|
function applyStyle(el, styleDef, mediaQueries = {}, state = {}) {
|
|
1580
1586
|
const nested = {};
|
|
@@ -1760,7 +1766,8 @@ async function resolvePrototype(def2, state, key, base) {
|
|
|
1760
1766
|
const controller = new AbortController;
|
|
1761
1767
|
onEffectCleanup(() => {
|
|
1762
1768
|
controller.abort();
|
|
1763
|
-
|
|
1769
|
+
if (debounceTimer !== null)
|
|
1770
|
+
clearTimeout(debounceTimer);
|
|
1764
1771
|
});
|
|
1765
1772
|
const doFetch = () => fetch(url, {
|
|
1766
1773
|
signal: controller.signal,
|
|
@@ -1862,7 +1869,7 @@ async function resolvePrototype(def2, state, key, base) {
|
|
|
1862
1869
|
} = def2;
|
|
1863
1870
|
const req = indexedDB.open(database, version);
|
|
1864
1871
|
req.onupgradeneeded = (e) => {
|
|
1865
|
-
const db = e.target
|
|
1872
|
+
const db = e.target.result;
|
|
1866
1873
|
if (!db.objectStoreNames.contains(store)) {
|
|
1867
1874
|
const os = db.createObjectStore(store, { keyPath, autoIncrement });
|
|
1868
1875
|
for (const i of indexes)
|
|
@@ -1870,7 +1877,7 @@ async function resolvePrototype(def2, state, key, base) {
|
|
|
1870
1877
|
}
|
|
1871
1878
|
};
|
|
1872
1879
|
req.onsuccess = (e) => {
|
|
1873
|
-
const db = e.target
|
|
1880
|
+
const db = e.target.result;
|
|
1874
1881
|
idbState.value = {
|
|
1875
1882
|
database,
|
|
1876
1883
|
store,
|
|
@@ -1898,6 +1905,39 @@ async function resolvePrototype(def2, state, key, base) {
|
|
|
1898
1905
|
return new Blob(def2.parts ?? [], { type: def2.type ?? "text/plain" });
|
|
1899
1906
|
case "ReadableStream":
|
|
1900
1907
|
return null;
|
|
1908
|
+
case "ContentCollection":
|
|
1909
|
+
case "ContentEntry": {
|
|
1910
|
+
if (_contentConfig.skip) {
|
|
1911
|
+
return ref(def2.$prototype === "ContentCollection" ? [{ id: "", data: {} }] : null);
|
|
1912
|
+
}
|
|
1913
|
+
const s = ref(def2.$prototype === "ContentCollection" ? [] : null);
|
|
1914
|
+
effect(() => {
|
|
1915
|
+
let id = def2.id;
|
|
1916
|
+
if (id && typeof id === "object" && id.$ref?.startsWith("#/$params/")) {
|
|
1917
|
+
const paramName = id.$ref.replace("#/$params/", "");
|
|
1918
|
+
id = state?.$params?.[paramName];
|
|
1919
|
+
} else if (typeof id === "string" && id.includes("${")) {
|
|
1920
|
+
id = evaluateTemplate(id, state);
|
|
1921
|
+
}
|
|
1922
|
+
if (def2.$prototype === "ContentEntry" && !id)
|
|
1923
|
+
return;
|
|
1924
|
+
fetch("/__studio/content", {
|
|
1925
|
+
method: "POST",
|
|
1926
|
+
headers: { "Content-Type": "application/json" },
|
|
1927
|
+
body: JSON.stringify({
|
|
1928
|
+
$prototype: def2.$prototype,
|
|
1929
|
+
contentType: def2.contentType,
|
|
1930
|
+
id,
|
|
1931
|
+
filter: def2.filter,
|
|
1932
|
+
sort: def2.sort,
|
|
1933
|
+
limit: def2.limit
|
|
1934
|
+
})
|
|
1935
|
+
}).then((r) => r.ok ? r.json() : null).then((d) => {
|
|
1936
|
+
s.value = d;
|
|
1937
|
+
}).catch(() => {});
|
|
1938
|
+
});
|
|
1939
|
+
return s;
|
|
1940
|
+
}
|
|
1901
1941
|
default:
|
|
1902
1942
|
console.warn(`Jx: unknown $prototype "${def2.$prototype}" for "${key}". Did you mean to add '$src'?`);
|
|
1903
1943
|
return ref(null);
|
|
@@ -2066,7 +2106,8 @@ function classFromSchema(classDef) {
|
|
|
2066
2106
|
}
|
|
2067
2107
|
}
|
|
2068
2108
|
Object.defineProperty(DynClass, "name", { value: classDef.title, configurable: true });
|
|
2069
|
-
|
|
2109
|
+
const dynCtor = DynClass;
|
|
2110
|
+
return dynCtor;
|
|
2070
2111
|
}
|
|
2071
2112
|
async function resolveViaDevProxy(def2, state, key, base) {
|
|
2072
2113
|
const config = {};
|
|
@@ -2399,7 +2440,7 @@ async function defineElement(source, base) {
|
|
|
2399
2440
|
function renderCustomElementWithProps(def2, state, options, path) {
|
|
2400
2441
|
const el = document.createElement(def2.tagName);
|
|
2401
2442
|
if (options?.onNodeCreated)
|
|
2402
|
-
options.onNodeCreated(el, path, def2);
|
|
2443
|
+
options.onNodeCreated(el, path ?? [], def2);
|
|
2403
2444
|
for (const [key, val] of Object.entries(def2.$props ?? {})) {
|
|
2404
2445
|
if (isRefObj(val)) {
|
|
2405
2446
|
const resolved = resolveRef(val.$ref, state);
|
|
@@ -2456,6 +2497,7 @@ function distributeSlots(host, slottedChildren) {
|
|
|
2456
2497
|
export {
|
|
2457
2498
|
toCSSText,
|
|
2458
2499
|
setSkipServerFunctions,
|
|
2500
|
+
setSkipContentResolution,
|
|
2459
2501
|
resolveRef,
|
|
2460
2502
|
resolvePrototype,
|
|
2461
2503
|
resolve,
|
|
@@ -2470,5 +2512,5 @@ export {
|
|
|
2470
2512
|
Jx
|
|
2471
2513
|
};
|
|
2472
2514
|
|
|
2473
|
-
//# debugId=
|
|
2515
|
+
//# debugId=E96CE71CCED47BE764756E2164756E21
|
|
2474
2516
|
//# sourceMappingURL=runtime.js.map
|