@githumbi/grabby 0.1.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/CHANGELOG.md +11 -0
- package/LICENSE +22 -0
- package/README.md +262 -0
- package/builders.json +14 -0
- package/dist/angular/index.d.ts +279 -0
- package/dist/angular/index.js +5145 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/babel-plugin/index.cjs +95 -0
- package/dist/babel-plugin/index.cjs.map +1 -0
- package/dist/babel-plugin/index.d.cts +28 -0
- package/dist/babel-plugin/index.d.ts +28 -0
- package/dist/babel-plugin/index.js +60 -0
- package/dist/babel-plugin/index.js.map +1 -0
- package/dist/builder/builders/application/index.js +141 -0
- package/dist/builder/builders/application/index.js.map +1 -0
- package/dist/builder/builders/application/schema.json +7 -0
- package/dist/builder/builders/dev-server/index.js +137 -0
- package/dist/builder/builders/dev-server/index.js.map +1 -0
- package/dist/builder/builders/dev-server/schema.json +26 -0
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/package.json +1 -0
- package/dist/chunk-6CBIOKZV.cjs +45 -0
- package/dist/chunk-6CBIOKZV.cjs.map +1 -0
- package/dist/chunk-M3DOFJA7.js +45 -0
- package/dist/chunk-M3DOFJA7.js.map +1 -0
- package/dist/cli/index.js +406 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.cjs +5081 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +96 -0
- package/dist/core/index.d.ts +96 -0
- package/dist/core/index.js +5081 -0
- package/dist/core/index.js.map +1 -0
- package/dist/esbuild-plugin/index.cjs +134 -0
- package/dist/esbuild-plugin/index.cjs.map +1 -0
- package/dist/esbuild-plugin/index.d.cts +21 -0
- package/dist/esbuild-plugin/index.d.ts +21 -0
- package/dist/esbuild-plugin/index.js +96 -0
- package/dist/esbuild-plugin/index.js.map +1 -0
- package/dist/export/index.cjs +166 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +86 -0
- package/dist/export/index.d.ts +86 -0
- package/dist/export/index.js +137 -0
- package/dist/export/index.js.map +1 -0
- package/dist/grabby.global.js +635 -0
- package/dist/live/index.cjs +30 -0
- package/dist/live/index.cjs.map +1 -0
- package/dist/live/index.d.cts +20 -0
- package/dist/live/index.d.ts +20 -0
- package/dist/live/index.js +30 -0
- package/dist/live/index.js.map +1 -0
- package/dist/loader.global.js +1 -0
- package/dist/plugin/index.cjs +229 -0
- package/dist/plugin/index.cjs.map +1 -0
- package/dist/plugin/index.d.cts +76 -0
- package/dist/plugin/index.d.ts +76 -0
- package/dist/plugin/index.js +186 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/react/index.d.ts +290 -0
- package/dist/react/index.js +5110 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-CMgpkvBz.d.cts +265 -0
- package/dist/types-CMgpkvBz.d.ts +265 -0
- package/package.json +191 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/babel-plugin/index.ts
|
|
31
|
+
var babel_plugin_exports = {};
|
|
32
|
+
__export(babel_plugin_exports, {
|
|
33
|
+
default: () => babel_plugin_default,
|
|
34
|
+
grabbyBabelPlugin: () => grabbyBabelPlugin
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(babel_plugin_exports);
|
|
37
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
38
|
+
|
|
39
|
+
// src/core/adapters/stamp.ts
|
|
40
|
+
var SOURCE_ATTRIBUTE = "data-grabby-loc";
|
|
41
|
+
|
|
42
|
+
// src/babel-plugin/index.ts
|
|
43
|
+
var SKIP = /* @__PURE__ */ new Set(["Fragment", "StrictMode", "Suspense", "SuspenseList", "Profiler"]);
|
|
44
|
+
function grabbyBabelPlugin(options = {}) {
|
|
45
|
+
const attribute = options.attribute ?? SOURCE_ATTRIBUTE;
|
|
46
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
47
|
+
return function grabbyReactSource({ types: t }) {
|
|
48
|
+
return {
|
|
49
|
+
name: "grabby-react-source",
|
|
50
|
+
visitor: {
|
|
51
|
+
JSXOpeningElement(nodePath, state) {
|
|
52
|
+
const filename = state.filename ?? state.file?.opts?.filename;
|
|
53
|
+
if (!filename || filename.includes("node_modules")) return;
|
|
54
|
+
const node = nodePath.node;
|
|
55
|
+
if (node.name?.type === "JSXNamespacedName") return;
|
|
56
|
+
const name = elementName(node.name);
|
|
57
|
+
if (name && SKIP.has(name)) return;
|
|
58
|
+
const already = node.attributes.some(
|
|
59
|
+
(attr) => attr.type === "JSXAttribute" && attr.name?.name === attribute
|
|
60
|
+
);
|
|
61
|
+
if (already) return;
|
|
62
|
+
const loc = node.loc?.start;
|
|
63
|
+
if (!loc) return;
|
|
64
|
+
const relative = import_node_path.default.relative(rootDir, filename).split(import_node_path.default.sep).join("/");
|
|
65
|
+
const component = componentName(node.name);
|
|
66
|
+
const value = `${relative}:${loc.line}:${loc.column + 1}${component ? `:${component}` : ""}`;
|
|
67
|
+
node.attributes.unshift(
|
|
68
|
+
t.jsxAttribute(t.jsxIdentifier(attribute), t.stringLiteral(value))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function componentName(name) {
|
|
76
|
+
if (!name) return null;
|
|
77
|
+
if (name.type === "JSXIdentifier") return /^[A-Z]/.test(name.name) ? name.name : null;
|
|
78
|
+
if (name.type === "JSXMemberExpression") {
|
|
79
|
+
const object = name.object?.type === "JSXIdentifier" ? name.object.name : componentName(name.object);
|
|
80
|
+
return object && name.property?.name ? `${object}.${name.property.name}` : null;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function elementName(name) {
|
|
85
|
+
if (!name) return null;
|
|
86
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
87
|
+
if (name.type === "JSXMemberExpression") return elementName(name.property);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
var babel_plugin_default = grabbyBabelPlugin;
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
grabbyBabelPlugin
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/babel-plugin/index.ts","../../src/core/adapters/stamp.ts"],"sourcesContent":["import path from 'node:path';\nimport { SOURCE_ATTRIBUTE } from '../core/adapters/stamp';\n\nexport interface GrabbyBabelOptions {\n /** Paths are stamped relative to this. Default: process.cwd() */\n rootDir?: string;\n /** Attribute to stamp. Default: \"data-grabby-loc\" */\n attribute?: string;\n}\n\n/** React built-ins that take no DOM props, so stamping them does nothing useful. */\nconst SKIP = new Set(['Fragment', 'StrictMode', 'Suspense', 'SuspenseList', 'Profiler']);\n\n/**\n * Stamps every JSX element with its `file:line:column` so grabby can\n * report where a grabbed element was written.\n *\n * Wire it through @vitejs/plugin-react:\n *\n * react({ babel: { plugins: [grabbyBabelPlugin()] } })\n *\n * The attribute is prepended, so a `{...props}` spread still wins. That's\n * deliberate: for `<Button />` the stamp travels with the props onto the\n * rendered DOM node, and the grab points at the page rather than the library.\n */\nexport function grabbyBabelPlugin(options: GrabbyBabelOptions = {}) {\n const attribute = options.attribute ?? SOURCE_ATTRIBUTE;\n const rootDir = options.rootDir ?? process.cwd();\n\n return function grabbyReactSource({ types: t }: { types: any }) {\n return {\n name: 'grabby-react-source',\n visitor: {\n JSXOpeningElement(nodePath: any, state: any) {\n const filename: string | undefined = state.filename ?? state.file?.opts?.filename;\n if (!filename || filename.includes('node_modules')) return;\n\n const node = nodePath.node;\n if (node.name?.type === 'JSXNamespacedName') return;\n\n const name = elementName(node.name);\n if (name && SKIP.has(name)) return;\n\n const already = node.attributes.some(\n (attr: any) => attr.type === 'JSXAttribute' && attr.name?.name === attribute,\n );\n if (already) return;\n\n const loc = node.loc?.start;\n if (!loc) return;\n\n const relative = path.relative(rootDir, filename).split(path.sep).join('/');\n // Components also record their name: production builds minify\n // function names, so the fiber would only say \"vu\" or \"M\".\n const component = componentName(node.name);\n const value = `${relative}:${loc.line}:${loc.column + 1}${component ? `:${component}` : ''}`;\n\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier(attribute), t.stringLiteral(value)),\n );\n },\n },\n };\n };\n}\n\n/** `Card`, `Table.Row`: capitalised or member JSX names; native tags return null. */\nfunction componentName(name: any): string | null {\n if (!name) return null;\n if (name.type === 'JSXIdentifier') return /^[A-Z]/.test(name.name) ? name.name : null;\n if (name.type === 'JSXMemberExpression') {\n const object = name.object?.type === 'JSXIdentifier' ? name.object.name : componentName(name.object);\n return object && name.property?.name ? `${object}.${name.property.name}` : null;\n }\n return null;\n}\n\nfunction elementName(name: any): string | null {\n if (!name) return null;\n if (name.type === 'JSXIdentifier') return name.name;\n if (name.type === 'JSXMemberExpression') return elementName(name.property);\n return null;\n}\n\nexport default grabbyBabelPlugin;\n","export const SOURCE_ATTRIBUTE = 'data-grabby-loc';\n\nconst LOCATION = /^(.*?):(\\d+):(\\d+)(?::([A-Za-z_$][\\w$.]*))?$/;\n\n/**\n * Reads the `file:line:column` stamp the Grabby build plugin puts on elements\n * (JSX and Vue templates), walking up to the nearest ancestor that has one.\n */\nexport function resolveSource(element: Element): {\n filePath: string | null;\n line: number | null;\n column: number | null;\n} {\n let current: Element | null = element;\n while (current) {\n const raw = current.getAttribute?.(SOURCE_ATTRIBUTE);\n if (raw) return parseLocation(raw);\n current = current.parentElement;\n }\n return { filePath: null, line: null, column: null };\n}\n\nfunction parseLocation(raw: string): {\n filePath: string | null;\n line: number | null;\n column: number | null;\n} {\n const match = LOCATION.exec(raw);\n if (!match) return { filePath: raw, line: null, column: null };\n return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };\n}\n\nexport interface Stamp {\n file: string;\n line: number | null;\n column: number | null;\n /** The component written at that spot (`<Card …>`), when it was a component. */\n name: string | null;\n}\n\n/** The stamp on this exact element (not an ancestor's), if it has one. */\nexport function ownStamp(element: Element | null): Stamp | null {\n const raw = element?.getAttribute?.(SOURCE_ATTRIBUTE);\n if (!raw) return null;\n const match = LOCATION.exec(raw);\n if (!match) return { file: raw, line: null, column: null, name: null };\n return { file: match[1], line: Number(match[2]), column: Number(match[3]), name: match[4] ?? null };\n}\n\n/** True when the page was built with the Grabby source plugin. */\nexport function hasSourceStamps(): boolean {\n try {\n return document.querySelector(`[${SOURCE_ATTRIBUTE}]`) !== null;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;;;ACAV,IAAM,mBAAmB;;;ADWhC,IAAM,OAAO,oBAAI,IAAI,CAAC,YAAY,cAAc,YAAY,gBAAgB,UAAU,CAAC;AAchF,SAAS,kBAAkB,UAA8B,CAAC,GAAG;AAClE,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI;AAE/C,SAAO,SAAS,kBAAkB,EAAE,OAAO,EAAE,GAAmB;AAC9D,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,QACP,kBAAkB,UAAe,OAAY;AAC3C,gBAAM,WAA+B,MAAM,YAAY,MAAM,MAAM,MAAM;AACzE,cAAI,CAAC,YAAY,SAAS,SAAS,cAAc,EAAG;AAEpD,gBAAM,OAAO,SAAS;AACtB,cAAI,KAAK,MAAM,SAAS,oBAAqB;AAE7C,gBAAM,OAAO,YAAY,KAAK,IAAI;AAClC,cAAI,QAAQ,KAAK,IAAI,IAAI,EAAG;AAE5B,gBAAM,UAAU,KAAK,WAAW;AAAA,YAC9B,CAAC,SAAc,KAAK,SAAS,kBAAkB,KAAK,MAAM,SAAS;AAAA,UACrE;AACA,cAAI,QAAS;AAEb,gBAAM,MAAM,KAAK,KAAK;AACtB,cAAI,CAAC,IAAK;AAEV,gBAAM,WAAW,iBAAAA,QAAK,SAAS,SAAS,QAAQ,EAAE,MAAM,iBAAAA,QAAK,GAAG,EAAE,KAAK,GAAG;AAG1E,gBAAM,YAAY,cAAc,KAAK,IAAI;AACzC,gBAAM,QAAQ,GAAG,QAAQ,IAAI,IAAI,IAAI,IAAI,IAAI,SAAS,CAAC,GAAG,YAAY,IAAI,SAAS,KAAK,EAAE;AAE1F,eAAK,WAAW;AAAA,YACd,EAAE,aAAa,EAAE,cAAc,SAAS,GAAG,EAAE,cAAc,KAAK,CAAC;AAAA,UACnE;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAGA,SAAS,cAAc,MAA0B;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,KAAK,SAAS,gBAAiB,QAAO,SAAS,KAAK,KAAK,IAAI,IAAI,KAAK,OAAO;AACjF,MAAI,KAAK,SAAS,uBAAuB;AACvC,UAAM,SAAS,KAAK,QAAQ,SAAS,kBAAkB,KAAK,OAAO,OAAO,cAAc,KAAK,MAAM;AACnG,WAAO,UAAU,KAAK,UAAU,OAAO,GAAG,MAAM,IAAI,KAAK,SAAS,IAAI,KAAK;AAAA,EAC7E;AACA,SAAO;AACT;AAEA,SAAS,YAAY,MAA0B;AAC7C,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,KAAK,SAAS,gBAAiB,QAAO,KAAK;AAC/C,MAAI,KAAK,SAAS,sBAAuB,QAAO,YAAY,KAAK,QAAQ;AACzE,SAAO;AACT;AAEA,IAAO,uBAAQ;","names":["path"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface GrabbyBabelOptions {
|
|
2
|
+
/** Paths are stamped relative to this. Default: process.cwd() */
|
|
3
|
+
rootDir?: string;
|
|
4
|
+
/** Attribute to stamp. Default: "data-grabby-loc" */
|
|
5
|
+
attribute?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Stamps every JSX element with its `file:line:column` so grabby can
|
|
9
|
+
* report where a grabbed element was written.
|
|
10
|
+
*
|
|
11
|
+
* Wire it through @vitejs/plugin-react:
|
|
12
|
+
*
|
|
13
|
+
* react({ babel: { plugins: [grabbyBabelPlugin()] } })
|
|
14
|
+
*
|
|
15
|
+
* The attribute is prepended, so a `{...props}` spread still wins. That's
|
|
16
|
+
* deliberate: for `<Button />` the stamp travels with the props onto the
|
|
17
|
+
* rendered DOM node, and the grab points at the page rather than the library.
|
|
18
|
+
*/
|
|
19
|
+
declare function grabbyBabelPlugin(options?: GrabbyBabelOptions): ({ types: t }: {
|
|
20
|
+
types: any;
|
|
21
|
+
}) => {
|
|
22
|
+
name: string;
|
|
23
|
+
visitor: {
|
|
24
|
+
JSXOpeningElement(nodePath: any, state: any): void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { type GrabbyBabelOptions, grabbyBabelPlugin as default, grabbyBabelPlugin };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface GrabbyBabelOptions {
|
|
2
|
+
/** Paths are stamped relative to this. Default: process.cwd() */
|
|
3
|
+
rootDir?: string;
|
|
4
|
+
/** Attribute to stamp. Default: "data-grabby-loc" */
|
|
5
|
+
attribute?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Stamps every JSX element with its `file:line:column` so grabby can
|
|
9
|
+
* report where a grabbed element was written.
|
|
10
|
+
*
|
|
11
|
+
* Wire it through @vitejs/plugin-react:
|
|
12
|
+
*
|
|
13
|
+
* react({ babel: { plugins: [grabbyBabelPlugin()] } })
|
|
14
|
+
*
|
|
15
|
+
* The attribute is prepended, so a `{...props}` spread still wins. That's
|
|
16
|
+
* deliberate: for `<Button />` the stamp travels with the props onto the
|
|
17
|
+
* rendered DOM node, and the grab points at the page rather than the library.
|
|
18
|
+
*/
|
|
19
|
+
declare function grabbyBabelPlugin(options?: GrabbyBabelOptions): ({ types: t }: {
|
|
20
|
+
types: any;
|
|
21
|
+
}) => {
|
|
22
|
+
name: string;
|
|
23
|
+
visitor: {
|
|
24
|
+
JSXOpeningElement(nodePath: any, state: any): void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { type GrabbyBabelOptions, grabbyBabelPlugin as default, grabbyBabelPlugin };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/babel-plugin/index.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
// src/core/adapters/stamp.ts
|
|
5
|
+
var SOURCE_ATTRIBUTE = "data-grabby-loc";
|
|
6
|
+
|
|
7
|
+
// src/babel-plugin/index.ts
|
|
8
|
+
var SKIP = /* @__PURE__ */ new Set(["Fragment", "StrictMode", "Suspense", "SuspenseList", "Profiler"]);
|
|
9
|
+
function grabbyBabelPlugin(options = {}) {
|
|
10
|
+
const attribute = options.attribute ?? SOURCE_ATTRIBUTE;
|
|
11
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
12
|
+
return function grabbyReactSource({ types: t }) {
|
|
13
|
+
return {
|
|
14
|
+
name: "grabby-react-source",
|
|
15
|
+
visitor: {
|
|
16
|
+
JSXOpeningElement(nodePath, state) {
|
|
17
|
+
const filename = state.filename ?? state.file?.opts?.filename;
|
|
18
|
+
if (!filename || filename.includes("node_modules")) return;
|
|
19
|
+
const node = nodePath.node;
|
|
20
|
+
if (node.name?.type === "JSXNamespacedName") return;
|
|
21
|
+
const name = elementName(node.name);
|
|
22
|
+
if (name && SKIP.has(name)) return;
|
|
23
|
+
const already = node.attributes.some(
|
|
24
|
+
(attr) => attr.type === "JSXAttribute" && attr.name?.name === attribute
|
|
25
|
+
);
|
|
26
|
+
if (already) return;
|
|
27
|
+
const loc = node.loc?.start;
|
|
28
|
+
if (!loc) return;
|
|
29
|
+
const relative = path.relative(rootDir, filename).split(path.sep).join("/");
|
|
30
|
+
const component = componentName(node.name);
|
|
31
|
+
const value = `${relative}:${loc.line}:${loc.column + 1}${component ? `:${component}` : ""}`;
|
|
32
|
+
node.attributes.unshift(
|
|
33
|
+
t.jsxAttribute(t.jsxIdentifier(attribute), t.stringLiteral(value))
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function componentName(name) {
|
|
41
|
+
if (!name) return null;
|
|
42
|
+
if (name.type === "JSXIdentifier") return /^[A-Z]/.test(name.name) ? name.name : null;
|
|
43
|
+
if (name.type === "JSXMemberExpression") {
|
|
44
|
+
const object = name.object?.type === "JSXIdentifier" ? name.object.name : componentName(name.object);
|
|
45
|
+
return object && name.property?.name ? `${object}.${name.property.name}` : null;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function elementName(name) {
|
|
50
|
+
if (!name) return null;
|
|
51
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
52
|
+
if (name.type === "JSXMemberExpression") return elementName(name.property);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
var babel_plugin_default = grabbyBabelPlugin;
|
|
56
|
+
export {
|
|
57
|
+
babel_plugin_default as default,
|
|
58
|
+
grabbyBabelPlugin
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/babel-plugin/index.ts","../../src/core/adapters/stamp.ts"],"sourcesContent":["import path from 'node:path';\nimport { SOURCE_ATTRIBUTE } from '../core/adapters/stamp';\n\nexport interface GrabbyBabelOptions {\n /** Paths are stamped relative to this. Default: process.cwd() */\n rootDir?: string;\n /** Attribute to stamp. Default: \"data-grabby-loc\" */\n attribute?: string;\n}\n\n/** React built-ins that take no DOM props, so stamping them does nothing useful. */\nconst SKIP = new Set(['Fragment', 'StrictMode', 'Suspense', 'SuspenseList', 'Profiler']);\n\n/**\n * Stamps every JSX element with its `file:line:column` so grabby can\n * report where a grabbed element was written.\n *\n * Wire it through @vitejs/plugin-react:\n *\n * react({ babel: { plugins: [grabbyBabelPlugin()] } })\n *\n * The attribute is prepended, so a `{...props}` spread still wins. That's\n * deliberate: for `<Button />` the stamp travels with the props onto the\n * rendered DOM node, and the grab points at the page rather than the library.\n */\nexport function grabbyBabelPlugin(options: GrabbyBabelOptions = {}) {\n const attribute = options.attribute ?? SOURCE_ATTRIBUTE;\n const rootDir = options.rootDir ?? process.cwd();\n\n return function grabbyReactSource({ types: t }: { types: any }) {\n return {\n name: 'grabby-react-source',\n visitor: {\n JSXOpeningElement(nodePath: any, state: any) {\n const filename: string | undefined = state.filename ?? state.file?.opts?.filename;\n if (!filename || filename.includes('node_modules')) return;\n\n const node = nodePath.node;\n if (node.name?.type === 'JSXNamespacedName') return;\n\n const name = elementName(node.name);\n if (name && SKIP.has(name)) return;\n\n const already = node.attributes.some(\n (attr: any) => attr.type === 'JSXAttribute' && attr.name?.name === attribute,\n );\n if (already) return;\n\n const loc = node.loc?.start;\n if (!loc) return;\n\n const relative = path.relative(rootDir, filename).split(path.sep).join('/');\n // Components also record their name: production builds minify\n // function names, so the fiber would only say \"vu\" or \"M\".\n const component = componentName(node.name);\n const value = `${relative}:${loc.line}:${loc.column + 1}${component ? `:${component}` : ''}`;\n\n node.attributes.unshift(\n t.jsxAttribute(t.jsxIdentifier(attribute), t.stringLiteral(value)),\n );\n },\n },\n };\n };\n}\n\n/** `Card`, `Table.Row`: capitalised or member JSX names; native tags return null. */\nfunction componentName(name: any): string | null {\n if (!name) return null;\n if (name.type === 'JSXIdentifier') return /^[A-Z]/.test(name.name) ? name.name : null;\n if (name.type === 'JSXMemberExpression') {\n const object = name.object?.type === 'JSXIdentifier' ? name.object.name : componentName(name.object);\n return object && name.property?.name ? `${object}.${name.property.name}` : null;\n }\n return null;\n}\n\nfunction elementName(name: any): string | null {\n if (!name) return null;\n if (name.type === 'JSXIdentifier') return name.name;\n if (name.type === 'JSXMemberExpression') return elementName(name.property);\n return null;\n}\n\nexport default grabbyBabelPlugin;\n","export const SOURCE_ATTRIBUTE = 'data-grabby-loc';\n\nconst LOCATION = /^(.*?):(\\d+):(\\d+)(?::([A-Za-z_$][\\w$.]*))?$/;\n\n/**\n * Reads the `file:line:column` stamp the Grabby build plugin puts on elements\n * (JSX and Vue templates), walking up to the nearest ancestor that has one.\n */\nexport function resolveSource(element: Element): {\n filePath: string | null;\n line: number | null;\n column: number | null;\n} {\n let current: Element | null = element;\n while (current) {\n const raw = current.getAttribute?.(SOURCE_ATTRIBUTE);\n if (raw) return parseLocation(raw);\n current = current.parentElement;\n }\n return { filePath: null, line: null, column: null };\n}\n\nfunction parseLocation(raw: string): {\n filePath: string | null;\n line: number | null;\n column: number | null;\n} {\n const match = LOCATION.exec(raw);\n if (!match) return { filePath: raw, line: null, column: null };\n return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };\n}\n\nexport interface Stamp {\n file: string;\n line: number | null;\n column: number | null;\n /** The component written at that spot (`<Card …>`), when it was a component. */\n name: string | null;\n}\n\n/** The stamp on this exact element (not an ancestor's), if it has one. */\nexport function ownStamp(element: Element | null): Stamp | null {\n const raw = element?.getAttribute?.(SOURCE_ATTRIBUTE);\n if (!raw) return null;\n const match = LOCATION.exec(raw);\n if (!match) return { file: raw, line: null, column: null, name: null };\n return { file: match[1], line: Number(match[2]), column: Number(match[3]), name: match[4] ?? null };\n}\n\n/** True when the page was built with the Grabby source plugin. */\nexport function hasSourceStamps(): boolean {\n try {\n return document.querySelector(`[${SOURCE_ATTRIBUTE}]`) !== null;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;;;ACAV,IAAM,mBAAmB;;;ADWhC,IAAM,OAAO,oBAAI,IAAI,CAAC,YAAY,cAAc,YAAY,gBAAgB,UAAU,CAAC;AAchF,SAAS,kBAAkB,UAA8B,CAAC,GAAG;AAClE,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI;AAE/C,SAAO,SAAS,kBAAkB,EAAE,OAAO,EAAE,GAAmB;AAC9D,WAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,QACP,kBAAkB,UAAe,OAAY;AAC3C,gBAAM,WAA+B,MAAM,YAAY,MAAM,MAAM,MAAM;AACzE,cAAI,CAAC,YAAY,SAAS,SAAS,cAAc,EAAG;AAEpD,gBAAM,OAAO,SAAS;AACtB,cAAI,K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names":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/builder/builders/application/index.ts
|
|
31
|
+
var application_exports = {};
|
|
32
|
+
__export(application_exports, {
|
|
33
|
+
default: () => application_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(application_exports);
|
|
36
|
+
var import_architect = require("@angular-devkit/architect");
|
|
37
|
+
var import_build = require("@angular/build");
|
|
38
|
+
|
|
39
|
+
// src/esbuild-plugin/scan.ts
|
|
40
|
+
var import_typescript = __toESM(require("typescript"), 1);
|
|
41
|
+
var import_path = __toESM(require("path"), 1);
|
|
42
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
43
|
+
function scanComponentSources(rootDir) {
|
|
44
|
+
const sourceMap = {};
|
|
45
|
+
const files = findTypeScriptFiles(rootDir);
|
|
46
|
+
for (const filePath of files) {
|
|
47
|
+
const content = import_fs.default.readFileSync(filePath, "utf8");
|
|
48
|
+
if (!content.includes("@Component")) continue;
|
|
49
|
+
const relativePath = import_path.default.relative(rootDir, filePath).replace(/\\/g, "/");
|
|
50
|
+
const components = extractComponents(content, filePath);
|
|
51
|
+
for (const comp of components) {
|
|
52
|
+
sourceMap[comp.name] = { file: relativePath, line: comp.line };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return sourceMap;
|
|
56
|
+
}
|
|
57
|
+
function extractComponents(code, filePath) {
|
|
58
|
+
const sourceFile = import_typescript.default.createSourceFile(
|
|
59
|
+
filePath,
|
|
60
|
+
code,
|
|
61
|
+
import_typescript.default.ScriptTarget.Latest,
|
|
62
|
+
true,
|
|
63
|
+
import_typescript.default.ScriptKind.TS
|
|
64
|
+
);
|
|
65
|
+
const results = [];
|
|
66
|
+
function visit(node) {
|
|
67
|
+
if (import_typescript.default.isClassDeclaration(node) && node.name) {
|
|
68
|
+
const decorators = import_typescript.default.getDecorators(node);
|
|
69
|
+
if (!decorators) return;
|
|
70
|
+
const hasComponent = decorators.some((d) => {
|
|
71
|
+
if (!import_typescript.default.isCallExpression(d.expression)) return false;
|
|
72
|
+
if (!import_typescript.default.isIdentifier(d.expression.expression)) return false;
|
|
73
|
+
return d.expression.expression.text === "Component";
|
|
74
|
+
});
|
|
75
|
+
if (hasComponent) {
|
|
76
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
77
|
+
results.push({ name: node.name.text, line: line + 1 });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
import_typescript.default.forEachChild(node, visit);
|
|
81
|
+
}
|
|
82
|
+
visit(sourceFile);
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
function findTypeScriptFiles(rootDir) {
|
|
86
|
+
const results = [];
|
|
87
|
+
const srcDir = import_path.default.join(rootDir, "src");
|
|
88
|
+
if (!import_fs.default.existsSync(srcDir)) return results;
|
|
89
|
+
walk(srcDir, results);
|
|
90
|
+
return results;
|
|
91
|
+
}
|
|
92
|
+
function walk(dir, results) {
|
|
93
|
+
let entries;
|
|
94
|
+
try {
|
|
95
|
+
entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
|
|
96
|
+
} catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
101
|
+
const fullPath = import_path.default.join(dir, entry.name);
|
|
102
|
+
if (entry.isDirectory()) {
|
|
103
|
+
walk(fullPath, results);
|
|
104
|
+
} else if (entry.name.endsWith(".ts") && !entry.name.endsWith(".spec.ts") && !entry.name.endsWith(".d.ts")) {
|
|
105
|
+
results.push(fullPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/esbuild-plugin/plugin.ts
|
|
111
|
+
function grabbyEsbuildPlugin(options) {
|
|
112
|
+
return {
|
|
113
|
+
name: "grabby",
|
|
114
|
+
setup(build) {
|
|
115
|
+
if (options?.enabled === false) return;
|
|
116
|
+
const rootDir = options?.rootDir || process.cwd();
|
|
117
|
+
const sourceMap = scanComponentSources(rootDir);
|
|
118
|
+
if (Object.keys(sourceMap).length === 0) return;
|
|
119
|
+
const json = JSON.stringify(sourceMap);
|
|
120
|
+
const existingBanner = build.initialOptions.banner;
|
|
121
|
+
const bannerObj = typeof existingBanner === "object" ? existingBanner : {};
|
|
122
|
+
const existingJs = bannerObj.js || "";
|
|
123
|
+
build.initialOptions.banner = {
|
|
124
|
+
...bannerObj,
|
|
125
|
+
js: `globalThis.__GRABBY_SOURCE_MAP__=${json};${existingJs}`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/builder/builders/application/index.ts
|
|
132
|
+
var application_default = (0, import_architect.createBuilder)(async function* (options, context) {
|
|
133
|
+
const isProduction = !!options.optimization;
|
|
134
|
+
yield* (0, import_build.buildApplication)(options, context, {
|
|
135
|
+
codePlugins: [grabbyEsbuildPlugin({
|
|
136
|
+
rootDir: context.workspaceRoot,
|
|
137
|
+
enabled: !isProduction
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/builder/builders/application/index.ts","../../../../src/esbuild-plugin/scan.ts","../../../../src/esbuild-plugin/plugin.ts"],"sourcesContent":["import { createBuilder } from '@angular-devkit/architect';\nimport { buildApplication } from '@angular/build';\nimport { grabbyEsbuildPlugin } from '../../../esbuild-plugin';\n\nexport default createBuilder(async function* (options: any, context) {\n const isProduction = !!options.optimization;\n yield* buildApplication(options, context, {\n codePlugins: [grabbyEsbuildPlugin({\n rootDir: context.workspaceRoot,\n enabled: !isProduction,\n })],\n });\n});\n","import ts from 'typescript';\nimport path from 'path';\nimport fs from 'fs';\n\nexport interface ComponentSourceInfo {\n file: string;\n line: number;\n}\n\nexport type SourceMap = Record<string, ComponentSourceInfo>;\n\n/**\n * Scans the project for `.component.ts` files and extracts component\n * class names with their source locations. Returns a map of\n * `{ ComponentName: { file, line } }`.\n */\nexport function scanComponentSources(rootDir: string): SourceMap {\n const sourceMap: SourceMap = {};\n const files = findTypeScriptFiles(rootDir);\n\n for (const filePath of files) {\n const content = fs.readFileSync(filePath, 'utf8');\n if (!content.includes('@Component')) continue;\n\n const relativePath = path.relative(rootDir, filePath).replace(/\\\\/g, '/');\n const components = extractComponents(content, filePath);\n\n for (const comp of components) {\n sourceMap[comp.name] = { file: relativePath, line: comp.line };\n }\n }\n\n return sourceMap;\n}\n\ninterface ComponentInfo {\n name: string;\n line: number;\n}\n\nfunction extractComponents(code: string, filePath: string): ComponentInfo[] {\n const sourceFile = ts.createSourceFile(\n filePath,\n code,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const results: ComponentInfo[] = [];\n\n function visit(node: ts.Node): void {\n if (ts.isClassDeclaration(node) && node.name) {\n const decorators = ts.getDecorators(node);\n if (!decorators) return;\n\n const hasComponent = decorators.some((d) => {\n if (!ts.isCallExpression(d.expression)) return false;\n if (!ts.isIdentifier(d.expression.expression)) return false;\n return d.expression.expression.text === 'Component';\n });\n\n if (hasComponent) {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n results.push({ name: node.name.text, line: line + 1 });\n }\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction findTypeScriptFiles(rootDir: string): string[] {\n const results: string[] = [];\n const srcDir = path.join(rootDir, 'src');\n\n if (!fs.existsSync(srcDir)) return results;\n\n walk(srcDir, results);\n return results;\n}\n\nfunction walk(dir: string, results: string[]): void {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n walk(fullPath, results);\n } else if (entry.name.endsWith('.ts') && !entry.name.endsWith('.spec.ts') && !entry.name.endsWith('.d.ts')) {\n results.push(fullPath);\n }\n }\n}\n","import type { Plugin } from 'esbuild';\nimport { scanComponentSources } from './scan';\n\nexport function grabbyEsbuildPlugin(options?: {\n rootDir?: string;\n /** Set to false to disable the transform (e.g., in production). Default: true */\n enabled?: boolean;\n}): Plugin {\n return {\n name: 'grabby',\n setup(build) {\n if (options?.enabled === false) return;\n\n const rootDir = options?.rootDir || process.cwd();\n const sourceMap = scanComponentSources(rootDir);\n\n if (Object.keys(sourceMap).length === 0) return;\n\n // Inject the source map as a global variable via banner\n const json = JSON.stringify(sourceMap);\n const existingBanner = build.initialOptions.banner;\n const bannerObj = typeof existingBanner === 'object' ? existingBanner : {};\n const existingJs = bannerObj.js || '';\n build.initialOptions.banner = {\n ...bannerObj,\n js: `globalThis.__GRABBY_SOURCE_MAP__=${json};${existingJs}`,\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA8B;AAC9B,mBAAiC;;;ACDjC,wBAAe;AACf,kBAAiB;AACjB,gBAAe;AAcR,SAAS,qBAAqB,SAA4B;AAC/D,QAAM,YAAuB,CAAC;AAC9B,QAAM,QAAQ,oBAAoB,OAAO;AAEzC,aAAW,YAAY,OAAO;AAC5B,UAAM,UAAU,UAAAA,QAAG,aAAa,UAAU,MAAM;AAChD,QAAI,CAAC,QAAQ,SAAS,YAAY,EAAG;AAErC,UAAM,eAAe,YAAAC,QAAK,SAAS,SAAS,QAAQ,EAAE,QAAQ,OAAO,GAAG;AACxE,UAAM,aAAa,kBAAkB,SAAS,QAAQ;AAEtD,eAAW,QAAQ,YAAY;AAC7B,gBAAU,KAAK,IAAI,IAAI,EAAE,MAAM,cAAc,MAAM,KAAK,KAAK;AAAA,IAC/D;AAAA,EACF;AAEA,SAAO;AACT;AAOA,SAAS,kBAAkB,MAAc,UAAmC;AAC1E,QAAM,aAAa,kBAAAC,QAAG;AAAA,IACpB;AAAA,IACA;AAAA,IACA,kBAAAA,QAAG,aAAa;AAAA,IAChB;AAAA,IACA,kBAAAA,QAAG,WAAW;AAAA,EAChB;AAEA,QAAM,UAA2B,CAAC;AAElC,WAAS,MAAM,MAAqB;AAClC,QAAI,kBA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AAS,UAAU,KAAK,CAAC,MAAM,KAAK,SAAS,OAAO,GAAG;AAC1G,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AACF;;;ACrGO,SAAS,oBAAoB,SAIzB;AACT,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,OAAO;AACX,UAAI,SAAS,YAAY,MAAO;AAEhC,YAAM,UAAU,SAAS,WAAW,QAAQ,IAAI;AAChD,YAAM,YAAY,qBAAqB,OAAO;AAE9C,UAAI,OAAO,KAAK,SAAS,EAAE,WAAW,EAAG;AAGzC,YAAM,OAAO,KAAK,UAAU,SAAS;AACrC,YAAM,iBAAiB,MAAM,eAAe;AAC5C,YAAM,YAAY,OAAO,mBAAmB,WAAW,iBAAiB,CAAC;AACzE,YAAM,aAAa,UAAU,MAAM;AACnC,YAAM,eAAe,SAAS;AAAA,QAC5B,GAAG;AAAA,QACH,IAAI,oCAAoC,IAAI,IAAI,UAAU;AAAA,MAC5D;AAAA,IACF;AAAA,EACF;AACF;;;AFzBA,IAAO,0BAAQ,gCAAc,iBAAiB,SAAc,SAAS;AACnE,QAAM,eAAe,CAAC,CAAC,QAAQ;AAC/B,aAAO,+BAAiB,SAAS,SAAS;AAAA,IACxC,aAAa,CAAC,oBAAoB;AAAA,MAChC,SAAS,QAAQ;AAAA,MACjB,SAAS,CAAC;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH,CAAC;","names":["fs","path","ts"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/builder/builders/dev-server/index.ts
|
|
31
|
+
var dev_server_exports = {};
|
|
32
|
+
__export(dev_server_exports, {
|
|
33
|
+
default: () => dev_server_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(dev_server_exports);
|
|
36
|
+
var import_architect = require("@angular-devkit/architect");
|
|
37
|
+
var import_build = require("@angular/build");
|
|
38
|
+
|
|
39
|
+
// src/esbuild-plugin/scan.ts
|
|
40
|
+
var import_typescript = __toESM(require("typescript"), 1);
|
|
41
|
+
var import_path = __toESM(require("path"), 1);
|
|
42
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
43
|
+
function scanComponentSources(rootDir) {
|
|
44
|
+
const sourceMap = {};
|
|
45
|
+
const files = findTypeScriptFiles(rootDir);
|
|
46
|
+
for (const filePath of files) {
|
|
47
|
+
const content = import_fs.default.readFileSync(filePath, "utf8");
|
|
48
|
+
if (!content.includes("@Component")) continue;
|
|
49
|
+
const relativePath = import_path.default.relative(rootDir, filePath).replace(/\\/g, "/");
|
|
50
|
+
const components = extractComponents(content, filePath);
|
|
51
|
+
for (const comp of components) {
|
|
52
|
+
sourceMap[comp.name] = { file: relativePath, line: comp.line };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return sourceMap;
|
|
56
|
+
}
|
|
57
|
+
function extractComponents(code, filePath) {
|
|
58
|
+
const sourceFile = import_typescript.default.createSourceFile(
|
|
59
|
+
filePath,
|
|
60
|
+
code,
|
|
61
|
+
import_typescript.default.ScriptTarget.Latest,
|
|
62
|
+
true,
|
|
63
|
+
import_typescript.default.ScriptKind.TS
|
|
64
|
+
);
|
|
65
|
+
const results = [];
|
|
66
|
+
function visit(node) {
|
|
67
|
+
if (import_typescript.default.isClassDeclaration(node) && node.name) {
|
|
68
|
+
const decorators = import_typescript.default.getDecorators(node);
|
|
69
|
+
if (!decorators) return;
|
|
70
|
+
const hasComponent = decorators.some((d) => {
|
|
71
|
+
if (!import_typescript.default.isCallExpression(d.expression)) return false;
|
|
72
|
+
if (!import_typescript.default.isIdentifier(d.expression.expression)) return false;
|
|
73
|
+
return d.expression.expression.text === "Component";
|
|
74
|
+
});
|
|
75
|
+
if (hasComponent) {
|
|
76
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
77
|
+
results.push({ name: node.name.text, line: line + 1 });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
import_typescript.default.forEachChild(node, visit);
|
|
81
|
+
}
|
|
82
|
+
visit(sourceFile);
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
function findTypeScriptFiles(rootDir) {
|
|
86
|
+
const results = [];
|
|
87
|
+
const srcDir = import_path.default.join(rootDir, "src");
|
|
88
|
+
if (!import_fs.default.existsSync(srcDir)) return results;
|
|
89
|
+
walk(srcDir, results);
|
|
90
|
+
return results;
|
|
91
|
+
}
|
|
92
|
+
function walk(dir, results) {
|
|
93
|
+
let entries;
|
|
94
|
+
try {
|
|
95
|
+
entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
|
|
96
|
+
} catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
101
|
+
const fullPath = import_path.default.join(dir, entry.name);
|
|
102
|
+
if (entry.isDirectory()) {
|
|
103
|
+
walk(fullPath, results);
|
|
104
|
+
} else if (entry.name.endsWith(".ts") && !entry.name.endsWith(".spec.ts") && !entry.name.endsWith(".d.ts")) {
|
|
105
|
+
results.push(fullPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/esbuild-plugin/plugin.ts
|
|
111
|
+
function grabbyEsbuildPlugin(options) {
|
|
112
|
+
return {
|
|
113
|
+
name: "grabby",
|
|
114
|
+
setup(build) {
|
|
115
|
+
if (options?.enabled === false) return;
|
|
116
|
+
const rootDir = options?.rootDir || process.cwd();
|
|
117
|
+
const sourceMap = scanComponentSources(rootDir);
|
|
118
|
+
if (Object.keys(sourceMap).length === 0) return;
|
|
119
|
+
const json = JSON.stringify(sourceMap);
|
|
120
|
+
const existingBanner = build.initialOptions.banner;
|
|
121
|
+
const bannerObj = typeof existingBanner === "object" ? existingBanner : {};
|
|
122
|
+
const existingJs = bannerObj.js || "";
|
|
123
|
+
build.initialOptions.banner = {
|
|
124
|
+
...bannerObj,
|
|
125
|
+
js: `globalThis.__GRABBY_SOURCE_MAP__=${json};${existingJs}`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/builder/builders/dev-server/index.ts
|
|
132
|
+
var dev_server_default = (0, import_architect.createBuilder)(async function* (options, context) {
|
|
133
|
+
yield* (0, import_build.executeDevServerBuilder)(options, context, {
|
|
134
|
+
buildPlugins: [grabbyEsbuildPlugin({ rootDir: context.workspaceRoot })]
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/builder/builders/dev-server/index.ts","../../../../src/esbuild-plugin/scan.ts","../../../../src/esbuild-plugin/plugin.ts"],"sourcesContent":["import { createBuilder } from '@angular-devkit/architect';\nimport { executeDevServerBuilder } from '@angular/build';\nimport { grabbyEsbuildPlugin } from '../../../esbuild-plugin';\n\nexport default createBuilder(async function* (options: any, context) {\n yield* executeDevServerBuilder(options, context, {\n buildPlugins: [grabbyEsbuildPlugin({ rootDir: context.workspaceRoot })],\n });\n});\n","import ts from 'typescript';\nimport path from 'path';\nimport fs from 'fs';\n\nexport interface ComponentSourceInfo {\n file: string;\n line: number;\n}\n\nexport type SourceMap = Record<string, ComponentSourceInfo>;\n\n/**\n * Scans the project for `.component.ts` files and extracts component\n * class names with their source locations. Returns a map of\n * `{ ComponentName: { file, line } }`.\n */\nexport function scanComponentSources(rootDir: string): SourceMap {\n const sourceMap: SourceMap = {};\n const files = findTypeScriptFiles(rootDir);\n\n for (const filePath of files) {\n const content = fs.readFileSync(filePath, 'utf8');\n if (!content.includes('@Component')) continue;\n\n const relativePath = path.relative(rootDir, filePath).replace(/\\\\/g, '/');\n const components = extractComponents(content, filePath);\n\n for (const comp of components) {\n sourceMap[comp.name] = { file: relativePath, line: comp.line };\n }\n }\n\n return sourceMap;\n}\n\ninterface ComponentInfo {\n name: string;\n line: number;\n}\n\nfunction extractComponents(code: string, filePath: string): ComponentInfo[] {\n const sourceFile = ts.createSourceFile(\n filePath,\n code,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const results: ComponentInfo[] = [];\n\n function visit(node: ts.Node): void {\n if (ts.isClassDeclaration(node) && node.name) {\n const decorators = ts.getDecorators(node);\n if (!decorators) return;\n\n const hasComponent = decorators.some((d) => {\n if (!ts.isCallExpression(d.expression)) return false;\n if (!ts.isIdentifier(d.expression.expression)) return false;\n return d.expression.expression.text === 'Component';\n });\n\n if (hasComponent) {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n results.push({ name: node.name.text, line: line + 1 });\n }\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction findTypeScriptFiles(rootDir: string): string[] {\n const results: string[] = [];\n const srcDir = path.join(rootDir, 'src');\n\n if (!fs.existsSync(srcDir)) return results;\n\n walk(srcDir, results);\n return results;\n}\n\nfunction walk(dir: string, results: string[]): void {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;\n\n const fullPath = path.join(dir, entry.name);\n\n if (entry.isDirectory()) {\n walk(fullPath, results);\n } else if (entry.name.endsWith('.ts') && !entry.name.endsWith('.spec.ts') && !entry.name.endsWith('.d.ts')) {\n results.push(fullPath);\n }\n }\n}\n","import type { Plugin } from 'esbuild';\nimport { scanComponentSources } from './scan';\n\nexport function grabbyEsbuildPlugin(options?: {\n rootDir?: string;\n /** Set to false to disable the transform (e.g., in production). Default: true */\n enabled?: boolean;\n}): Plugin {\n return {\n name: 'grabby',\n setup(build) {\n if (options?.enabled === false) return;\n\n const rootDir = options?.rootDir || process.cwd();\n const sourceMap = scanComponentSources(rootDir);\n\n if (Object.keys(sourceMap).length === 0) return;\n\n // Inject the source map as a global variable via banner\n const json = JSON.stringify(sourceMap);\n const existingBanner = build.initialOptions.banner;\n const bannerObj = typeof existingBanner === 'object' ? existingBanner : {};\n const existingJs = bannerObj.js || '';\n build.initialOptions.banner = {\n ...bannerObj,\n js: `globalThis.__GRABBY_SOURCE_MAP__=${json};${existingJs}`,\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;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,eAAe;AAC5C,YAAM,YAAY,OAAO,mBAAmB,WAAW,iBAAiB,CAAC;AACzE,YAAM,aAAa,UAAU,MAAM;AACnC,YAAM,eAAe,SAAS;AAAA,QAC5B,GAAG;AAAA,QACH,IAAI,oCAAoC,IAAI,IAAI,UAAU;AAAA,MAC5D;AAAA,IACF;AAAA,EACF;AACF;;;AFzBA,IAAO,yBAAQ,gCAAc,iBAAiB,SAAc,SAAS;AACnE,aAAO,sCAAwB,SAAS,SAAS;AAAA,IAC/C,cAAc,CAAC,oBAAoB,EAAE,SAAS,QAAQ,cAAc,CAAC,CAAC;AAAA,EACxE,CAAC;AACH,CAAC;","names":["fs","path","ts"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"title": "Grabby Dev Server Builder",
|
|
4
|
+
"description": "Wraps @angular/build:dev-server with Grabby source injection. Declares the common dev-server options so `ng serve --port 4300` style flags work; anything else in angular.json passes through unchanged.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"buildTarget": { "type": "string", "description": "A build builder target to serve in the format of `project:target[:configuration]`." },
|
|
8
|
+
"port": { "type": "number", "default": 4200, "description": "Port to listen on." },
|
|
9
|
+
"host": { "type": "string", "default": "localhost", "description": "Host to listen on." },
|
|
10
|
+
"open": { "type": "boolean", "default": false, "alias": "o", "description": "Opens the url in default browser." },
|
|
11
|
+
"proxyConfig": { "type": "string", "description": "Proxy configuration file." },
|
|
12
|
+
"ssl": { "type": "boolean", "default": false, "description": "Serve using HTTPS." },
|
|
13
|
+
"sslKey": { "type": "string", "description": "SSL key to use for serving HTTPS." },
|
|
14
|
+
"sslCert": { "type": "string", "description": "SSL certificate to use for serving HTTPS." },
|
|
15
|
+
"allowedHosts": { "type": "array", "items": { "type": "string" }, "description": "Hosts that are allowed to access the dev server." },
|
|
16
|
+
"servePath": { "type": "string", "description": "The pathname where the application will be served." },
|
|
17
|
+
"liveReload": { "type": "boolean", "default": true, "description": "Whether to reload the page on change." },
|
|
18
|
+
"hmr": { "type": "boolean", "description": "Enable hot module replacement." },
|
|
19
|
+
"watch": { "type": "boolean", "default": true, "description": "Rebuild on change." },
|
|
20
|
+
"poll": { "type": "number", "description": "File watching poll interval in milliseconds." },
|
|
21
|
+
"verbose": { "type": "boolean", "description": "Adds more details to output logging." },
|
|
22
|
+
"prebundle": { "description": "Enable and control the Vite-based development server's prebundling capabilities." },
|
|
23
|
+
"inspect": { "description": "Activate debugging inspector." }
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": true
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|