glass-easel-devtools-agent 0.9.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.
@@ -0,0 +1,392 @@
1
+ import type { Protocol } from 'devtools-protocol'
2
+ import type { EventDetail, GlassEaselVar, NodeId, RequestResponse } from './index'
3
+
4
+ export type AgentEventKind = {
5
+ setChildNodes: SetChildNodes
6
+ childNodeInserted: ChildNodeInserted
7
+ childNodeRemoved: ChildNodeRemoved
8
+ childNodeCountUpdated: ChildNodeCountUpdated
9
+ attributeRemoved: AttributeRemoved
10
+ attributeModified: AttributeModified
11
+ characterDataModified: CharacterDataModified
12
+ }
13
+
14
+ export type AgentRequestKind = {
15
+ describeNode: DescribeNode
16
+ enable: Enable
17
+ getDocument: GetDocument
18
+ pushNodesByBackendIdsToFrontend: PushNodesByBackendIdsToFrontend
19
+ removeAttribute: RemoveAttribute
20
+ setAttributeValue: SetAttributeValue
21
+ setAttributesAsText: SetAttributesAsText
22
+ getAttributes: GetAttributes
23
+ getGlassEaselAttributes: GetGlassEaselAttributes
24
+ useGlassEaselAttributeInConsole: UseGlassEaselAttributeInConsole
25
+ getGlassEaselComposedChildren: GetGlassEaselComposedChildren
26
+ requestChildNodes: RequestChildNodes
27
+ removeNode: RemoveNode
28
+ resolveNode: ResolveNode
29
+ setInspectedNode: SetInspectedNode
30
+ useGlassEaselElementInConsole: UseGlassEaselElementInConsole
31
+ setNodeValue: SetNodeValue
32
+ scrollIntoViewIfNeeded: ScrollIntoViewIfNeeded
33
+ getNodeForLocation: GetNodeForLocation
34
+ querySelector: QuerySelector
35
+ querySelectorAll: QuerySelectorAll
36
+ getBoxModel: GetBoxModel
37
+ }
38
+
39
+ export type Quad = [number, number, number, number, number, number, number, number]
40
+
41
+ const enum CDPNodeType {
42
+ ELEMENT_NODE = 1,
43
+ ATTRIBUTE_NODE = 2,
44
+ TEXT_NODE = 3,
45
+ DOCUMENT_NODE = 9,
46
+ DOCUMENT_TYPE_NODE = 10,
47
+ DOCUMENT_FRAGMENT_NODE = 11,
48
+ }
49
+
50
+ export const enum GlassEaselNodeType {
51
+ Unknown = 0x100,
52
+ TextNode,
53
+ NativeNode,
54
+ Component,
55
+ VirtualNode,
56
+ }
57
+
58
+ export const glassEaselNodeTypeToCDP = (t: GlassEaselNodeType) => {
59
+ if (t === GlassEaselNodeType.TextNode) return CDPNodeType.TEXT_NODE
60
+ if (t === GlassEaselNodeType.NativeNode) return CDPNodeType.ELEMENT_NODE
61
+ if (t === GlassEaselNodeType.Component) return CDPNodeType.ELEMENT_NODE
62
+ if (t === GlassEaselNodeType.VirtualNode) return CDPNodeType.ELEMENT_NODE
63
+ if (t === GlassEaselNodeType.Unknown) return CDPNodeType.DOCUMENT_NODE
64
+ return CDPNodeType.DOCUMENT_NODE
65
+ }
66
+
67
+ /**
68
+ * Node with simple information.
69
+ */
70
+ export type BackendNode = {
71
+ /** The backend node id. */
72
+ backendNodeId: NodeId
73
+ /** The basic type of the node. */
74
+ nodeType: CDPNodeType
75
+ /** The type of the node. */
76
+ glassEaselNodeType: GlassEaselNodeType
77
+ /** The tag name of the node. */
78
+ nodeName: string
79
+ /** Is virtual (virtual node or virtual-host component) or not. */
80
+ virtual: boolean
81
+ /** Is slot-inherited or not. */
82
+ inheritSlots: boolean
83
+ }
84
+
85
+ /**
86
+ * Basic information of a node.
87
+ */
88
+ export type Node = BackendNode & {
89
+ /** Node id. */
90
+ nodeId: NodeId
91
+ /** Node id of its parent (if any); for shadow-root, this is its host. */
92
+ parentId?: NodeId
93
+ /** The local name of the node (for components, it is the component name). */
94
+ localName: string
95
+ /** The text content (if any). */
96
+ nodeValue: string
97
+ /** The attributes (see `GetAttributes` for details). */
98
+ attributes: string[]
99
+ /** The count of the core attributes */
100
+ glassEaselAttributeCount: number
101
+ /** The type of the shadow-root type (if any). */
102
+ shadowRootType?: 'open'
103
+ /** The shadow root nodes (if any, at most one child). */
104
+ shadowRoots?: Node[]
105
+ /** The shadow-tree children (can be undefined which means to fetch in future). */
106
+ children?: Node[]
107
+ /** The slot content. */
108
+ distributedNodes?: BackendNode[]
109
+ }
110
+
111
+ /**
112
+ * Inform that the panel is enabled.
113
+ */
114
+ export interface DescribeNode extends RequestResponse {
115
+ request: { nodeId?: NodeId; backendNodeId?: NodeId; depth?: number }
116
+ response: { node: Node }
117
+ cdpRequestResponse: [Protocol.DOM.DescribeNodeRequest, Protocol.DOM.DescribeNodeResponse]
118
+ }
119
+
120
+ /**
121
+ * Inform that the panel is enabled.
122
+ */
123
+ export interface Enable extends RequestResponse {
124
+ request: Record<string, never>
125
+ cdpRequestResponse: [Protocol.DOM.EnableRequest, unknown]
126
+ }
127
+
128
+ /**
129
+ * Retrive the top-level document.
130
+ *
131
+ * This will always return a node that contains all mount points.
132
+ * The `nodeId` of it is always `1` .
133
+ */
134
+ export interface GetDocument extends RequestResponse {
135
+ request: { depth?: number }
136
+ response: { root: Node }
137
+ cdpRequestResponse: [Protocol.DOM.GetDocumentRequest, Protocol.DOM.GetDocumentResponse]
138
+ }
139
+
140
+ /**
141
+ * Activate some nodes and listening to further mutations.
142
+ */
143
+ export interface PushNodesByBackendIdsToFrontend extends RequestResponse {
144
+ request: { backendNodeIds: NodeId[] }
145
+ response: { nodeIds: NodeId[] }
146
+ cdpRequestResponse: [
147
+ Protocol.DOM.PushNodesByBackendIdsToFrontendRequest,
148
+ Protocol.DOM.PushNodesByBackendIdsToFrontendResponse,
149
+ ]
150
+ }
151
+
152
+ /**
153
+ * Remove an attribute.
154
+ */
155
+ export interface RemoveAttribute extends RequestResponse {
156
+ request: { nodeId: NodeId; name: string }
157
+ cdpRequestResponse: [Protocol.DOM.RemoveAttributeRequest, unknown]
158
+ }
159
+
160
+ /**
161
+ * Set an attribute.
162
+ */
163
+ export interface SetAttributeValue extends RequestResponse {
164
+ request: { nodeId: NodeId; name: string; value: string }
165
+ cdpRequestResponse: [Protocol.DOM.SetAttributeValueRequest, unknown]
166
+ }
167
+
168
+ /**
169
+ * Set attributes as text.
170
+ *
171
+ * This method is designed for the compatibilities with CDP (and not preferred).
172
+ */
173
+ export interface SetAttributesAsText extends RequestResponse {
174
+ request: { nodeId: NodeId; text: string; name?: string }
175
+ cdpRequestResponse: [Protocol.DOM.SetAttributesAsTextRequest, unknown]
176
+ }
177
+
178
+ /**
179
+ * Get attribute names and values of a node.
180
+ *
181
+ * The name-value pairs are stringified and flattened into a single string array.
182
+ * Common glass-easel managed attributes (e.g. `id` `class` ), datasets, and marks are also included.
183
+ */
184
+ export interface GetAttributes extends RequestResponse {
185
+ request: { nodeId: NodeId }
186
+ response: { attributes: string[]; glassEaselAttributeCount: number }
187
+ cdpRequestResponse: [Protocol.DOM.GetAttributesRequest, Protocol.DOM.GetAttributesResponse]
188
+ }
189
+
190
+ /**
191
+ * Get special attribute names of a node.
192
+ */
193
+ export interface GetGlassEaselAttributes extends RequestResponse {
194
+ request: { nodeId: NodeId }
195
+ response: {
196
+ glassEaselNodeType: GlassEaselNodeType
197
+ virtual: boolean
198
+ is: string
199
+ id: string
200
+ class: string
201
+ slot: string
202
+ slotName: string | undefined
203
+ slotValues: { name: string; value: GlassEaselVar }[] | undefined
204
+ eventBindings: {
205
+ name: string
206
+ capture: boolean
207
+ count: number
208
+ hasCatch: boolean
209
+ hasMutBind: boolean
210
+ }[]
211
+ normalAttributes?: { name: string; value: GlassEaselVar }[]
212
+ properties?: { name: string; value: GlassEaselVar }[]
213
+ externalClasses?: { name: string; value: string }[]
214
+ dataset: { name: string; value: GlassEaselVar }[]
215
+ marks: { name: string; value: GlassEaselVar }[]
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Use the value of a normal attribute or a property in console.
221
+ */
222
+ export interface UseGlassEaselAttributeInConsole {
223
+ request: { nodeId: NodeId; attribute: string }
224
+ response: { varName: string }
225
+ }
226
+
227
+ /**
228
+ * Get the composed children of a node.
229
+ */
230
+ export interface GetGlassEaselComposedChildren extends RequestResponse {
231
+ request: { nodeId: NodeId }
232
+ response: { nodes: Node[] }
233
+ }
234
+
235
+ /**
236
+ * Get child nodes.
237
+ */
238
+ export interface RequestChildNodes extends RequestResponse {
239
+ request: { nodeId: NodeId }
240
+ cdpRequestResponse: [Protocol.DOM.RequestChildNodesRequest, unknown]
241
+ }
242
+
243
+ /**
244
+ * Remove a node.
245
+ */
246
+ export interface RemoveNode extends RequestResponse {
247
+ request: { nodeId: NodeId }
248
+ cdpRequestResponse: [Protocol.DOM.RemoveNodeRequest, unknown]
249
+ }
250
+
251
+ /**
252
+ * Set a node as a global variable.
253
+ */
254
+ export interface ResolveNode extends RequestResponse {
255
+ request: { nodeId: NodeId } | { backendNodeId: NodeId }
256
+ response: { glassEaselGeneratedVarName: string }
257
+ cdpRequestResponse: [Protocol.DOM.ResolveNodeRequest, Protocol.DOM.ResolveNodeResponse]
258
+ }
259
+
260
+ /**
261
+ * Set the inspected focusing node.
262
+ */
263
+ export interface SetInspectedNode extends RequestResponse {
264
+ request: { nodeId: NodeId }
265
+ cdpRequestResponse: [Protocol.DOM.SetInspectedNodeRequest, unknown]
266
+ }
267
+
268
+ /**
269
+ * Set the inspected focusing node.
270
+ */
271
+ export interface UseGlassEaselElementInConsole extends RequestResponse {
272
+ request: { nodeId: NodeId }
273
+ response: { varName: string }
274
+ }
275
+
276
+ /**
277
+ * Set the text content.
278
+ */
279
+ export interface SetNodeValue extends RequestResponse {
280
+ request: { nodeId: NodeId; value: string }
281
+ cdpRequestResponse: [Protocol.DOM.SetNodeValueRequest, unknown]
282
+ }
283
+
284
+ /**
285
+ * Scroll to show the target element.
286
+ */
287
+ export interface ScrollIntoViewIfNeeded extends RequestResponse {
288
+ request: { nodeId: NodeId } | { backendNodeId: NodeId }
289
+ cdpRequestResponse: [Protocol.DOM.ScrollIntoViewIfNeededRequest, unknown]
290
+ }
291
+
292
+ /**
293
+ * Element from X/Y location.
294
+ */
295
+ export interface GetNodeForLocation extends RequestResponse {
296
+ request: { x: number; y: number }
297
+ response: { backendNodeId: NodeId }
298
+ cdpRequestResponse: [
299
+ Protocol.DOM.GetNodeForLocationRequest,
300
+ Protocol.DOM.GetNodeForLocationResponse,
301
+ ]
302
+ }
303
+
304
+ /**
305
+ * Query selector.
306
+ */
307
+ export interface QuerySelector extends RequestResponse {
308
+ request: { nodeId: NodeId; selector: string }
309
+ response: { nodeId: NodeId }
310
+ cdpRequestResponse: [Protocol.DOM.QuerySelectorRequest, Protocol.DOM.QuerySelectorResponse]
311
+ }
312
+
313
+ /**
314
+ * Query selector for all nodes.
315
+ */
316
+ export interface QuerySelectorAll extends RequestResponse {
317
+ request: { nodeId: NodeId; selector: string }
318
+ response: { nodeIds: NodeId[] }
319
+ cdpRequestResponse: [Protocol.DOM.QuerySelectorAllRequest, Protocol.DOM.QuerySelectorAllResponse]
320
+ }
321
+
322
+ /**
323
+ * Get box model and related information.
324
+ */
325
+ export interface GetBoxModel extends RequestResponse {
326
+ request: { nodeId: NodeId } | { backendNodeId: NodeId }
327
+ response: {
328
+ content: Quad
329
+ padding: Quad
330
+ border: Quad
331
+ margin: Quad
332
+ width: number
333
+ height: number
334
+ }
335
+ cdpRequestResponse: [Protocol.DOM.GetBoxModelRequest, Protocol.DOM.GetBoxModelResponse]
336
+ }
337
+
338
+ export interface SetChildNodes extends EventDetail {
339
+ detail: { parentId: NodeId; nodes: Node[] }
340
+ cdpEventDetail: Protocol.DOM.SetChildNodesEvent
341
+ }
342
+
343
+ /**
344
+ * A new child node is inserted.
345
+ *
346
+ * `previousNodeId` can be `0` which means insertion as the first child.
347
+ */
348
+ export interface ChildNodeInserted extends EventDetail {
349
+ detail: { parentNodeId: NodeId; previousNodeId: NodeId; node: Node }
350
+ cdpEventDetail: Protocol.DOM.ChildNodeInsertedEvent
351
+ }
352
+
353
+ /**
354
+ * A child node is removed.
355
+ */
356
+ export interface ChildNodeRemoved extends EventDetail {
357
+ detail: { parentNodeId: NodeId; nodeId: NodeId }
358
+ cdpEventDetail: Protocol.DOM.ChildNodeRemovedEvent
359
+ }
360
+
361
+ export interface ChildNodeCountUpdated extends EventDetail {
362
+ detail: { nodeId: NodeId; childNodeCount: number }
363
+ cdpEventDetail: Protocol.DOM.ChildNodeCountUpdatedEvent
364
+ }
365
+
366
+ export interface AttributeRemoved extends EventDetail {
367
+ detail: { nodeId: NodeId; name: string; nameType: 'attribute' }
368
+ cdpEventDetail: Protocol.DOM.AttributeRemovedEvent
369
+ }
370
+
371
+ export interface AttributeModified extends EventDetail {
372
+ detail: {
373
+ nodeId: NodeId
374
+ name: string
375
+ value: string
376
+ detail: GlassEaselVar
377
+ nameType:
378
+ | 'basic'
379
+ | 'attribute'
380
+ | 'component-property'
381
+ | 'slot-value'
382
+ | 'dataset'
383
+ | 'mark'
384
+ | 'external-class'
385
+ }
386
+ cdpEventDetail: Protocol.DOM.AttributeModifiedEvent
387
+ }
388
+
389
+ export interface CharacterDataModified extends EventDetail {
390
+ detail: { nodeId: NodeId; characterData: string }
391
+ cdpEventDetail: Protocol.DOM.CharacterDataModifiedEvent
392
+ }
@@ -0,0 +1,52 @@
1
+ import type * as dom from './dom'
2
+ import type * as css from './css'
3
+ import type * as overlay from './overlay'
4
+
5
+ export * from './var'
6
+ export * as dom from './dom'
7
+ export * as css from './css'
8
+ export * as overlay from './overlay'
9
+
10
+ export type AgentSendMessage =
11
+ | { kind: '' }
12
+ | { kind: 'event'; name: string; detail: any }
13
+ | { kind: 'response'; id: number; detail: any }
14
+ | { kind: 'error'; id: number; message?: string; stack?: string }
15
+
16
+ export type AgentRecvMessage =
17
+ | { kind: '' }
18
+ | { kind: 'request'; id: number; name: string; detail: any }
19
+
20
+ type Impl<T, U extends T> = U
21
+
22
+ export interface EventDetail {
23
+ detail: unknown
24
+ cdpEventDetail?: unknown
25
+ }
26
+
27
+ export interface RequestResponse {
28
+ request: unknown
29
+ response: unknown
30
+ cdpRequestResponse?: [unknown, unknown]
31
+ }
32
+
33
+ type KeyPrefix<P extends string, R extends Record<string, any>> = {
34
+ [T in keyof R as T extends string ? `${P}.${T}` : never]: R[T]
35
+ }
36
+
37
+ export type AgentEventKind = Impl<
38
+ Record<string, EventDetail>,
39
+ KeyPrefix<'DOM', dom.AgentEventKind> &
40
+ KeyPrefix<'CSS', css.AgentEventKind> &
41
+ KeyPrefix<'Overlay', overlay.AgentEventKind>
42
+ >
43
+
44
+ export type AgentRequestKind = Impl<
45
+ Record<string, RequestResponse>,
46
+ KeyPrefix<'DOM', dom.AgentRequestKind> &
47
+ KeyPrefix<'CSS', css.AgentRequestKind> &
48
+ KeyPrefix<'Overlay', overlay.AgentRequestKind>
49
+ >
50
+
51
+ /** The node id ( `0` is preserved). */
52
+ export type NodeId = number
@@ -0,0 +1,62 @@
1
+ import type { Protocol } from 'devtools-protocol'
2
+ import type { EventDetail, NodeId, RequestResponse } from './index'
3
+
4
+ export type AgentRequestKind = {
5
+ highlightNode: HighlightNode
6
+ hideHighlight: HideHighlight
7
+ setInspectMode: SetInspectMode
8
+ }
9
+
10
+ export type AgentEventKind = {
11
+ inspectModeCanceled: InspectModeCanceled
12
+ inspectNodeRequested: InspectNodeRequested
13
+ nodeHighlightRequested: NodeHighlightRequested
14
+ }
15
+
16
+ /**
17
+ * Highlight a node.
18
+ */
19
+ export interface HighlightNode extends RequestResponse {
20
+ request: { nodeId: NodeId } | { backendNodeId: NodeId }
21
+ cdpRequestResponse: [Protocol.Overlay.HighlightNodeRequest, unknown]
22
+ }
23
+
24
+ /**
25
+ * Remove the highlight.
26
+ */
27
+ export interface HideHighlight extends RequestResponse {
28
+ request: Record<string, never>
29
+ cdpRequestResponse: [unknown, unknown]
30
+ }
31
+
32
+ /**
33
+ * Remove the highlight.
34
+ */
35
+ export interface SetInspectMode extends RequestResponse {
36
+ request: { mode: 'searchForNode' | 'none' }
37
+ cdpRequestResponse: [Protocol.Overlay.SetInspectModeRequest, unknown]
38
+ }
39
+
40
+ /**
41
+ * Inspect focusing a node.
42
+ */
43
+ export interface InspectModeCanceled extends EventDetail {
44
+ detail: Record<string, never>
45
+ cdpEventDetail: unknown
46
+ }
47
+
48
+ /**
49
+ * Inspect focusing a node.
50
+ */
51
+ export interface InspectNodeRequested extends EventDetail {
52
+ detail: { backendNodeId: NodeId }
53
+ cdpEventDetail: Protocol.Overlay.InspectNodeRequestedEvent
54
+ }
55
+
56
+ /**
57
+ * Inspect highlighting a node.
58
+ */
59
+ export interface NodeHighlightRequested extends EventDetail {
60
+ detail: { nodeId: NodeId }
61
+ cdpEventDetail: Protocol.Overlay.NodeHighlightRequestedEvent
62
+ }
@@ -0,0 +1,37 @@
1
+ export type GlassEaselVar =
2
+ | { type: 'primitive'; value: string | number | boolean | null | undefined }
3
+ | { type: 'symbol'; value: string }
4
+ | { type: 'function' }
5
+ | { type: 'object' }
6
+ | { type: 'array' }
7
+
8
+ export const toGlassEaselVar = (v: unknown): GlassEaselVar => {
9
+ if (
10
+ typeof v === 'string' ||
11
+ typeof v === 'number' ||
12
+ typeof v === 'boolean' ||
13
+ v === null ||
14
+ v === undefined
15
+ ) {
16
+ return { type: 'primitive', value: v }
17
+ }
18
+ if (typeof v === 'symbol') {
19
+ return { type: 'symbol', value: v.toString() }
20
+ }
21
+ if (typeof v === 'function') {
22
+ return { type: 'function' }
23
+ }
24
+ if (Array.isArray(v)) {
25
+ return { type: 'array' }
26
+ }
27
+ return { type: 'object' }
28
+ }
29
+
30
+ export const glassEaselVarToString = (v: GlassEaselVar): string => {
31
+ if (v.type === 'primitive') return String(v.value)
32
+ if (v.type === 'symbol') return v.value
33
+ if (v.type === 'function') return '() => {...}'
34
+ if (v.type === 'object') return '{...}'
35
+ if (v.type === 'array') return '[...]'
36
+ return '[unknown]'
37
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,20 @@
1
+ export declare const DEV: boolean
2
+
3
+ export const error = (msg: string, ...args: unknown[]) => {
4
+ // eslint-disable-next-line no-console
5
+ console.error(`[glass-easel-miniprogram-agent] ${msg}`, ...args)
6
+ }
7
+
8
+ export const warn = (msg: string, ...args: unknown[]) => {
9
+ // eslint-disable-next-line no-console
10
+ console.warn(`[glass-easel-miniprogram-agent] ${msg}`, ...args)
11
+ }
12
+
13
+ export const debug = (msg: string, ...args: unknown[]) => {
14
+ // eslint-disable-next-line no-console
15
+ if (DEV) console.debug(`[glass-easel-miniprogram-agent] ${msg}`, ...args)
16
+ }
17
+
18
+ export const backendUnsupported = (apiName: string) => {
19
+ throw new Error(`"${apiName}" is not supported by the backend`)
20
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES6", "ES7", "ESNext"],
5
+ "types": ["node"],
6
+ "declaration": true,
7
+ "declarationDir": "dist"
8
+ },
9
+ "include": [
10
+ "src/**/*.ts"
11
+ ]
12
+ }
@@ -0,0 +1,49 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+
4
+ const path = require('path')
5
+ const { DefinePlugin } = require('webpack')
6
+
7
+ module.exports = [
8
+ {
9
+ mode: 'production',
10
+ entry: './src/index.ts',
11
+ output: {
12
+ filename: 'index.js',
13
+ path: path.join(__dirname, 'dist'),
14
+ library: {
15
+ type: 'commonjs2',
16
+ },
17
+ },
18
+ resolve: {
19
+ extensions: ['.ts', '.js'],
20
+ alias: {
21
+ 'glass-easel': 'glass-easel',
22
+ },
23
+ },
24
+ module: {
25
+ rules: [
26
+ {
27
+ test: /\.ts$/,
28
+ loader: 'ts-loader',
29
+ exclude: /node_modules/,
30
+ },
31
+ {
32
+ test: /\.wxml$/,
33
+ loader: path.join(__dirname, 'wxml_loader'),
34
+ exclude: /node_modules/,
35
+ },
36
+ ],
37
+ },
38
+ performance: {
39
+ hints: false,
40
+ maxEntrypointSize: 4 * 1024 * 1024,
41
+ maxAssetSize: 4 * 1024 * 1024,
42
+ },
43
+ plugins: [
44
+ new DefinePlugin({
45
+ DEV: 'false',
46
+ }),
47
+ ],
48
+ },
49
+ ]
@@ -0,0 +1,12 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+
4
+ const { DefinePlugin } = require('webpack')
5
+ const config = require('./webpack.config')
6
+
7
+ config[0].mode = 'development'
8
+ config[0].devtool = 'inline-source-map'
9
+ config[0].plugins[0] = new DefinePlugin({ DEV: 'true' })
10
+ // config[0].resolve.alias['glass-easel'] = 'glass-easel/dist/glass_easel.dev.all.es.js'
11
+
12
+ module.exports = config
package/wxml_loader.js ADDED
@@ -0,0 +1,14 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ const { TmplGroup } = require('glass-easel-template-compiler')
3
+
4
+ module.exports = (src) => {
5
+ const group = new TmplGroup()
6
+ group.addTmpl('', src)
7
+ const genObjectSrc = group.getTmplGenObjectGroups()
8
+ group.free()
9
+ // console.info(genObjectSrc)
10
+ return `
11
+ var groupList = ${genObjectSrc};
12
+ module.exports = { groupList: groupList, content: groupList[''] };
13
+ `
14
+ }