instruckt 0.4.21 → 0.4.22
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/instruckt.cjs.js +100 -23
- package/dist/instruckt.cjs.js.map +1 -1
- package/dist/instruckt.d.mts +6 -2
- package/dist/instruckt.d.ts +6 -2
- package/dist/instruckt.esm.js +100 -23
- package/dist/instruckt.esm.js.map +1 -1
- package/dist/instruckt.iife.js +22 -22
- package/dist/instruckt.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/instruckt.cjs.js
CHANGED
|
@@ -2949,43 +2949,70 @@ function detect(el) {
|
|
|
2949
2949
|
return null;
|
|
2950
2950
|
}
|
|
2951
2951
|
function getContext(el) {
|
|
2952
|
-
var _a2, _b;
|
|
2952
|
+
var _a2, _b, _c, _d, _e;
|
|
2953
2953
|
if (!isAvailable()) return null;
|
|
2954
2954
|
const wireEl = detect(el);
|
|
2955
2955
|
if (!wireEl) return null;
|
|
2956
2956
|
const wireId = wireEl.getAttribute("wire:id");
|
|
2957
2957
|
let componentName = "Unknown";
|
|
2958
|
+
let className;
|
|
2958
2959
|
const snapshotAttr = wireEl.getAttribute("wire:snapshot");
|
|
2959
2960
|
if (snapshotAttr) {
|
|
2960
2961
|
try {
|
|
2961
2962
|
const snapshot = JSON.parse(snapshotAttr);
|
|
2962
2963
|
componentName = (_b = (_a2 = snapshot == null ? void 0 : snapshot.memo) == null ? void 0 : _a2.name) != null ? _b : "Unknown";
|
|
2964
|
+
className = (_e = (_c = snapshot == null ? void 0 : snapshot.memo) == null ? void 0 : _c.path) != null ? _e : (_d = snapshot == null ? void 0 : snapshot.memo) == null ? void 0 : _d.name;
|
|
2963
2965
|
} catch (e) {
|
|
2964
2966
|
}
|
|
2965
2967
|
}
|
|
2966
2968
|
return {
|
|
2967
2969
|
framework: "livewire",
|
|
2968
2970
|
component: componentName,
|
|
2969
|
-
wire_id: wireId
|
|
2971
|
+
wire_id: wireId,
|
|
2972
|
+
class_name: className
|
|
2970
2973
|
};
|
|
2971
2974
|
}
|
|
2972
2975
|
|
|
2973
2976
|
// src/adapters/vue.ts
|
|
2977
|
+
function isUserFile(file) {
|
|
2978
|
+
if (!file) return false;
|
|
2979
|
+
return !file.includes("node_modules");
|
|
2980
|
+
}
|
|
2981
|
+
function getInstanceFile(instance) {
|
|
2982
|
+
var _a2, _b, _c;
|
|
2983
|
+
return (_c = (_a2 = instance.type) == null ? void 0 : _a2.__file) != null ? _c : (_b = instance.$options) == null ? void 0 : _b.__file;
|
|
2984
|
+
}
|
|
2985
|
+
function getInstanceName(instance) {
|
|
2986
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2987
|
+
return (_h = (_g = (_e = (_c = (_a2 = instance.$options) == null ? void 0 : _a2.name) != null ? _c : (_b = instance.$options) == null ? void 0 : _b.__name) != null ? _e : (_d = instance.type) == null ? void 0 : _d.name) != null ? _g : (_f = instance.type) == null ? void 0 : _f.__name) != null ? _h : "Anonymous";
|
|
2988
|
+
}
|
|
2974
2989
|
function detect2(el) {
|
|
2975
2990
|
var _a2;
|
|
2991
|
+
let firstMatch = null;
|
|
2976
2992
|
let node = el;
|
|
2977
2993
|
while (node && node !== document.documentElement) {
|
|
2978
2994
|
const instance = (_a2 = node.__vueParentComponent) != null ? _a2 : node.__vue__;
|
|
2979
|
-
if (instance)
|
|
2995
|
+
if (instance) {
|
|
2996
|
+
const file = getInstanceFile(instance);
|
|
2997
|
+
if (isUserFile(file)) return instance;
|
|
2998
|
+
if (!firstMatch) firstMatch = instance;
|
|
2999
|
+
}
|
|
2980
3000
|
node = node.parentElement;
|
|
2981
3001
|
}
|
|
2982
|
-
|
|
3002
|
+
if (firstMatch == null ? void 0 : firstMatch.parent) {
|
|
3003
|
+
let instance = firstMatch.parent;
|
|
3004
|
+
while (instance) {
|
|
3005
|
+
const file = getInstanceFile(instance);
|
|
3006
|
+
if (isUserFile(file)) return instance;
|
|
3007
|
+
instance = instance.parent;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
return firstMatch;
|
|
2983
3011
|
}
|
|
2984
3012
|
function getContext2(el) {
|
|
2985
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2986
3013
|
const instance = detect2(el);
|
|
2987
3014
|
if (!instance) return null;
|
|
2988
|
-
const name = (
|
|
3015
|
+
const name = getInstanceName(instance);
|
|
2989
3016
|
const data = {};
|
|
2990
3017
|
if (instance.props) {
|
|
2991
3018
|
Object.assign(data, instance.props);
|
|
@@ -3001,9 +3028,11 @@ function getContext2(el) {
|
|
|
3001
3028
|
}
|
|
3002
3029
|
}
|
|
3003
3030
|
}
|
|
3031
|
+
const file = getInstanceFile(instance);
|
|
3004
3032
|
return {
|
|
3005
3033
|
framework: "vue",
|
|
3006
3034
|
component: name,
|
|
3035
|
+
source_file: file,
|
|
3007
3036
|
component_uid: instance.uid !== void 0 ? String(instance.uid) : void 0,
|
|
3008
3037
|
data
|
|
3009
3038
|
};
|
|
@@ -3027,6 +3056,7 @@ function getContext3(el) {
|
|
|
3027
3056
|
return {
|
|
3028
3057
|
framework: "svelte",
|
|
3029
3058
|
component,
|
|
3059
|
+
source_file: filePath || void 0,
|
|
3030
3060
|
data: filePath ? { file: filePath } : void 0
|
|
3031
3061
|
};
|
|
3032
3062
|
}
|
|
@@ -3040,20 +3070,31 @@ function getFiberKey(el) {
|
|
|
3040
3070
|
}
|
|
3041
3071
|
return null;
|
|
3042
3072
|
}
|
|
3043
|
-
function
|
|
3073
|
+
function isUserSource(source) {
|
|
3074
|
+
if (!source) return false;
|
|
3075
|
+
return !source.fileName.includes("node_modules");
|
|
3076
|
+
}
|
|
3077
|
+
function findComponent(fiber) {
|
|
3078
|
+
let firstMatch = null;
|
|
3044
3079
|
let node = fiber;
|
|
3045
3080
|
while (node) {
|
|
3046
3081
|
const { type } = node;
|
|
3082
|
+
let name = null;
|
|
3047
3083
|
if (typeof type === "function" && type.name) {
|
|
3048
|
-
const
|
|
3049
|
-
if (
|
|
3084
|
+
const n = type.name;
|
|
3085
|
+
if (n[0] === n[0].toUpperCase() && n.length > 1) name = n;
|
|
3050
3086
|
}
|
|
3051
|
-
if (typeof type === "object" && type !== null && type.displayName) {
|
|
3052
|
-
|
|
3087
|
+
if (!name && typeof type === "object" && type !== null && type.displayName) {
|
|
3088
|
+
name = type.displayName;
|
|
3089
|
+
}
|
|
3090
|
+
if (name) {
|
|
3091
|
+
const info = { name, source: node._debugSource };
|
|
3092
|
+
if (isUserSource(node._debugSource)) return info;
|
|
3093
|
+
if (!firstMatch) firstMatch = info;
|
|
3053
3094
|
}
|
|
3054
3095
|
node = node.return;
|
|
3055
3096
|
}
|
|
3056
|
-
return "Component";
|
|
3097
|
+
return firstMatch != null ? firstMatch : { name: "Component" };
|
|
3057
3098
|
}
|
|
3058
3099
|
function getProps(fiber) {
|
|
3059
3100
|
var _a2, _b;
|
|
@@ -3076,9 +3117,15 @@ function getContext4(el) {
|
|
|
3076
3117
|
if (key) {
|
|
3077
3118
|
const fiber = node[key];
|
|
3078
3119
|
if (fiber) {
|
|
3079
|
-
const
|
|
3120
|
+
const { name, source } = findComponent(fiber);
|
|
3080
3121
|
const data = getProps(fiber);
|
|
3081
|
-
return {
|
|
3122
|
+
return {
|
|
3123
|
+
framework: "react",
|
|
3124
|
+
component: name,
|
|
3125
|
+
source_file: source == null ? void 0 : source.fileName,
|
|
3126
|
+
source_line: source == null ? void 0 : source.lineNumber,
|
|
3127
|
+
data
|
|
3128
|
+
};
|
|
3082
3129
|
}
|
|
3083
3130
|
}
|
|
3084
3131
|
node = node.parentElement;
|
|
@@ -3086,6 +3133,30 @@ function getContext4(el) {
|
|
|
3086
3133
|
return null;
|
|
3087
3134
|
}
|
|
3088
3135
|
|
|
3136
|
+
// src/adapters/blade.ts
|
|
3137
|
+
function getTrackedViews() {
|
|
3138
|
+
var _a2;
|
|
3139
|
+
const el = document.getElementById("instruckt-views");
|
|
3140
|
+
if (!el) return [];
|
|
3141
|
+
try {
|
|
3142
|
+
return JSON.parse((_a2 = el.textContent) != null ? _a2 : "[]");
|
|
3143
|
+
} catch (e) {
|
|
3144
|
+
return [];
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
function getContext5(_el) {
|
|
3148
|
+
var _a2;
|
|
3149
|
+
const views = getTrackedViews();
|
|
3150
|
+
if (views.length === 0) return null;
|
|
3151
|
+
const pageView = views.length > 1 ? (_a2 = views.find((v) => !v.name.startsWith("layouts.") && !v.name.startsWith("components."))) != null ? _a2 : views[views.length - 1] : views[0];
|
|
3152
|
+
return {
|
|
3153
|
+
framework: "blade",
|
|
3154
|
+
component: pageView.name,
|
|
3155
|
+
source_file: pageView.file,
|
|
3156
|
+
data: { views: views.map((v) => v.file) }
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3089
3160
|
// src/instruckt.ts
|
|
3090
3161
|
function pageKey() {
|
|
3091
3162
|
return window.location.pathname;
|
|
@@ -3194,7 +3265,7 @@ var _Instruckt = class _Instruckt {
|
|
|
3194
3265
|
this.showAnnotationPopup(pending);
|
|
3195
3266
|
};
|
|
3196
3267
|
this.config = __spreadValues({
|
|
3197
|
-
adapters: ["livewire", "vue", "svelte", "react"],
|
|
3268
|
+
adapters: ["livewire", "vue", "svelte", "react", "blade"],
|
|
3198
3269
|
theme: "auto",
|
|
3199
3270
|
position: "bottom-right"
|
|
3200
3271
|
}, config);
|
|
@@ -3288,12 +3359,10 @@ var _Instruckt = class _Instruckt {
|
|
|
3288
3359
|
this.loadFromStorage();
|
|
3289
3360
|
try {
|
|
3290
3361
|
const remote = await this.api.getAnnotations();
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
this.saveToStorage();
|
|
3296
|
-
}
|
|
3362
|
+
const remoteIds = new Set(remote.map((a) => a.id));
|
|
3363
|
+
const localOnly = this.annotations.filter((a) => !remoteIds.has(a.id));
|
|
3364
|
+
this.annotations = [...remote, ...localOnly];
|
|
3365
|
+
this.saveToStorage();
|
|
3297
3366
|
} catch (e) {
|
|
3298
3367
|
}
|
|
3299
3368
|
this.syncMarkers();
|
|
@@ -3576,6 +3645,10 @@ var _Instruckt = class _Instruckt {
|
|
|
3576
3645
|
const ctx = getContext4(el);
|
|
3577
3646
|
if (ctx) return ctx;
|
|
3578
3647
|
}
|
|
3648
|
+
if (adapters.includes("blade")) {
|
|
3649
|
+
const ctx = getContext5(el);
|
|
3650
|
+
if (ctx) return ctx;
|
|
3651
|
+
}
|
|
3579
3652
|
return null;
|
|
3580
3653
|
}
|
|
3581
3654
|
// ── Submit ────────────────────────────────────────────────────
|
|
@@ -3751,11 +3824,15 @@ No open annotations.`;
|
|
|
3751
3824
|
lines.push("");
|
|
3752
3825
|
const hPrefix = multiPage ? "###" : "##";
|
|
3753
3826
|
annotations.forEach((a, i) => {
|
|
3754
|
-
var _a2, _b, _c;
|
|
3827
|
+
var _a2, _b, _c, _d;
|
|
3755
3828
|
const componentSuffix = ((_a2 = a.framework) == null ? void 0 : _a2.component) ? ` in \`${a.framework.component}\`` : "";
|
|
3756
3829
|
lines.push(`${hPrefix} ${i + 1}. ${a.comment}`);
|
|
3830
|
+
lines.push(`- ID: \`${a.id}\``);
|
|
3757
3831
|
lines.push(`- Element: \`${a.element}\`${componentSuffix}`);
|
|
3758
|
-
if ((
|
|
3832
|
+
if ((_b = a.framework) == null ? void 0 : _b.source_file) {
|
|
3833
|
+
const loc = a.framework.source_line ? `${a.framework.source_file}:${a.framework.source_line}` : a.framework.source_file;
|
|
3834
|
+
lines.push(`- Source: \`${loc}\``);
|
|
3835
|
+
} else if ((_d = (_c = a.framework) == null ? void 0 : _c.data) == null ? void 0 : _d.file) {
|
|
3759
3836
|
lines.push(`- File: \`${a.framework.data.file}\``);
|
|
3760
3837
|
}
|
|
3761
3838
|
if (a.cssClasses) {
|