shaders 2.5.114 → 2.5.115
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/js/createPreview.d.ts +7 -3
- package/dist/js/createPreview.d.ts.map +1 -1
- package/dist/js/createPreview.js +110 -4
- package/dist/js/createShader.js +1 -1
- package/dist/js/types.d.ts +32 -0
- package/dist/js/types.d.ts.map +1 -1
- package/dist/react/Preview.js +113 -9
- package/dist/react/Shader.js +1 -1
- package/dist/react/bundle.js +183 -183
- package/dist/react/engine/Preview.d.ts +29 -0
- package/dist/react/engine/Preview.d.ts.map +1 -1
- package/dist/solid/engine/Preview.d.ts +18 -0
- package/dist/solid/engine/Preview.d.ts.map +1 -1
- package/dist/solid/engine/Preview.js +69 -2
- package/dist/solid/engine/Shader.js +1 -1
- package/dist/svelte/engine/Preview.svelte.d.ts +18 -0
- package/dist/svelte/index.js +124 -13
- package/dist/svelte/source/engine/Preview.svelte +134 -10
- package/dist/vue/Preview.vue_vue_type_script_setup_true_lang.js +111 -8
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/package.json +1 -1
|
@@ -157,7 +157,9 @@ var Preview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
157
157
|
apiBaseUrl: { default: "https://shaders.com" },
|
|
158
158
|
obfuscationKey: { default: "shaders-preview-key" },
|
|
159
159
|
watermarkText: { default: "Unlock your Shaders Pro license" },
|
|
160
|
-
watermarkLink: { default: "https://shaders.com/dashboard?pricing=true" }
|
|
160
|
+
watermarkLink: { default: "https://shaders.com/dashboard?pricing=true" },
|
|
161
|
+
configuration: {},
|
|
162
|
+
version: {}
|
|
161
163
|
},
|
|
162
164
|
setup(__props) {
|
|
163
165
|
const componentMap = {
|
|
@@ -288,11 +290,100 @@ var Preview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
288
290
|
throw new Error("Failed to decode shader definition: invalid data or incorrect key");
|
|
289
291
|
}
|
|
290
292
|
}
|
|
293
|
+
const RESERVED_IDENTIFIERS = new Set([
|
|
294
|
+
"break",
|
|
295
|
+
"case",
|
|
296
|
+
"catch",
|
|
297
|
+
"class",
|
|
298
|
+
"const",
|
|
299
|
+
"continue",
|
|
300
|
+
"default",
|
|
301
|
+
"delete",
|
|
302
|
+
"do",
|
|
303
|
+
"else",
|
|
304
|
+
"export",
|
|
305
|
+
"extends",
|
|
306
|
+
"finally",
|
|
307
|
+
"for",
|
|
308
|
+
"function",
|
|
309
|
+
"if",
|
|
310
|
+
"import",
|
|
311
|
+
"in",
|
|
312
|
+
"instanceof",
|
|
313
|
+
"new",
|
|
314
|
+
"return",
|
|
315
|
+
"super",
|
|
316
|
+
"switch",
|
|
317
|
+
"this",
|
|
318
|
+
"throw",
|
|
319
|
+
"try",
|
|
320
|
+
"typeof",
|
|
321
|
+
"var",
|
|
322
|
+
"void",
|
|
323
|
+
"while",
|
|
324
|
+
"with",
|
|
325
|
+
"yield"
|
|
326
|
+
]);
|
|
327
|
+
function slugifyIdentifier(label, fallback) {
|
|
328
|
+
const cleaned = label.replace(/[^A-Za-z0-9]+/g, " ").trim();
|
|
329
|
+
if (!cleaned) return fallback;
|
|
330
|
+
const camel = cleaned.split(/\s+/).map((part, i) => i === 0 ? part.charAt(0).toLowerCase() + part.slice(1) : part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
331
|
+
const safe = /^[A-Za-z_$]/.test(camel) ? camel : `_${camel}`;
|
|
332
|
+
return RESERVED_IDENTIFIERS.has(safe) ? `_${safe}` : safe;
|
|
333
|
+
}
|
|
334
|
+
function buildKeyPropIdentifierMap(keyProps) {
|
|
335
|
+
const used = new Set(["style"]);
|
|
336
|
+
const map = /* @__PURE__ */ new Map();
|
|
337
|
+
if (!keyProps?.length) return map;
|
|
338
|
+
keyProps.forEach((kp, i) => {
|
|
339
|
+
if (!kp.targets?.length) return;
|
|
340
|
+
const base = slugifyIdentifier(kp.label, `keyProp${i}`);
|
|
341
|
+
let ident = base;
|
|
342
|
+
let suffix = 1;
|
|
343
|
+
while (used.has(ident)) {
|
|
344
|
+
suffix++;
|
|
345
|
+
ident = `${base}${suffix}`;
|
|
346
|
+
}
|
|
347
|
+
used.add(ident);
|
|
348
|
+
map.set(ident, kp);
|
|
349
|
+
});
|
|
350
|
+
return map;
|
|
351
|
+
}
|
|
352
|
+
function findInTree(id, list) {
|
|
353
|
+
for (const c of list) {
|
|
354
|
+
if (c.id === id) return c;
|
|
355
|
+
if (c.children?.length) {
|
|
356
|
+
const hit = findInTree(id, c.children);
|
|
357
|
+
if (hit) return hit;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
function applyConfiguration(definition, configuration, keyProps) {
|
|
363
|
+
if (!configuration || !keyProps?.length) return definition;
|
|
364
|
+
const entries = Object.entries(configuration);
|
|
365
|
+
if (entries.length === 0) return definition;
|
|
366
|
+
const identMap = buildKeyPropIdentifierMap(keyProps);
|
|
367
|
+
const cloned = JSON.parse(JSON.stringify(definition.components));
|
|
368
|
+
for (const [ident, value] of entries) {
|
|
369
|
+
const kp = identMap.get(ident);
|
|
370
|
+
if (!kp) continue;
|
|
371
|
+
for (const t of kp.targets ?? []) {
|
|
372
|
+
const comp = findInTree(t.component_id, cloned);
|
|
373
|
+
if (comp?.props && t.prop in comp.props) comp.props[t.prop] = value;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
...definition,
|
|
378
|
+
components: cloned
|
|
379
|
+
};
|
|
380
|
+
}
|
|
291
381
|
const props = __props;
|
|
292
382
|
const fetchedDefinition = ref(null);
|
|
383
|
+
const fetchedKeyProps = ref(null);
|
|
293
384
|
const resolvedDefinition = computed(() => {
|
|
294
|
-
if (fetchedDefinition.value) return
|
|
295
|
-
return
|
|
385
|
+
if (!fetchedDefinition.value) return null;
|
|
386
|
+
return applyConfiguration(fetchedDefinition.value, props.configuration, fetchedKeyProps.value);
|
|
296
387
|
});
|
|
297
388
|
async function fetchAndDecode(url) {
|
|
298
389
|
try {
|
|
@@ -300,7 +391,10 @@ var Preview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
300
391
|
if (!response.ok) throw new Error(`Failed to fetch: ${response.status}`);
|
|
301
392
|
const data = await response.json();
|
|
302
393
|
const item = data.preset || data.shader;
|
|
303
|
-
if (item?.definition && typeof item.definition === "string")
|
|
394
|
+
if (item?.definition && typeof item.definition === "string") {
|
|
395
|
+
fetchedDefinition.value = decodePreviewDefinition(item.definition, props.obfuscationKey);
|
|
396
|
+
fetchedKeyProps.value = Array.isArray(item.key_props) ? item.key_props : null;
|
|
397
|
+
}
|
|
304
398
|
} catch (e) {
|
|
305
399
|
console.error("[Shaders Preview] Failed to fetch preview:", e);
|
|
306
400
|
}
|
|
@@ -308,14 +402,23 @@ var Preview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
308
402
|
watch(() => props.shader, (token) => {
|
|
309
403
|
if (token) {
|
|
310
404
|
fetchedDefinition.value = null;
|
|
405
|
+
fetchedKeyProps.value = null;
|
|
311
406
|
fetchAndDecode(`${props.apiBaseUrl}/api/preview/shader/${token}`);
|
|
312
|
-
} else if (!props.presetId)
|
|
407
|
+
} else if (!props.presetId) {
|
|
408
|
+
fetchedDefinition.value = null;
|
|
409
|
+
fetchedKeyProps.value = null;
|
|
410
|
+
}
|
|
313
411
|
}, { immediate: true });
|
|
314
|
-
watch(() => props.presetId, (id) => {
|
|
412
|
+
watch(() => [props.presetId, props.version], ([id, version]) => {
|
|
315
413
|
if (id) {
|
|
316
414
|
fetchedDefinition.value = null;
|
|
317
|
-
|
|
318
|
-
|
|
415
|
+
fetchedKeyProps.value = null;
|
|
416
|
+
const versionParam = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
417
|
+
fetchAndDecode(`${props.apiBaseUrl}/api/preview/preset/${id}${versionParam}`);
|
|
418
|
+
} else if (!props.shader) {
|
|
419
|
+
fetchedDefinition.value = null;
|
|
420
|
+
fetchedKeyProps.value = null;
|
|
421
|
+
}
|
|
319
422
|
}, { immediate: true });
|
|
320
423
|
onMounted(() => {
|
|
321
424
|
console.warn("[Shaders] Preview component is intended for use with a Shaders license. Visit https://shaders.com for more information.");
|
|
@@ -60,7 +60,7 @@ var Shader_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
60
60
|
const startTelemetryWhenReady = () => {
|
|
61
61
|
const checkRendering = () => {
|
|
62
62
|
if (rendererInstance.value.getPerformanceStats().fps > 0) {
|
|
63
|
-
telemetryCollector = startTelemetry(rendererInstance.value, "2.5.
|
|
63
|
+
telemetryCollector = startTelemetry(rendererInstance.value, "2.5.115", props.disableTelemetry, props.isPreview);
|
|
64
64
|
if (telemetryCollector) telemetryCollector.start();
|
|
65
65
|
telemetryStartTimeout = null;
|
|
66
66
|
} else telemetryStartTimeout = setTimeout(checkRendering, 500);
|