@moneko/core 3.28.7 → 3.28.8

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,388 @@
1
+ {
2
+ "type": "Module",
3
+ "span": {
4
+ "start": 1194957,
5
+ "end": 1195243,
6
+ "ctxt": 0
7
+ },
8
+ "body": [
9
+ {
10
+ "type": "ImportDeclaration",
11
+ "span": {
12
+ "start": 1194957,
13
+ "end": 1194991,
14
+ "ctxt": 0
15
+ },
16
+ "specifiers": [
17
+ {
18
+ "type": "ImportSpecifier",
19
+ "span": {
20
+ "start": 1194966,
21
+ "end": 1194969,
22
+ "ctxt": 0
23
+ },
24
+ "local": {
25
+ "type": "Identifier",
26
+ "span": {
27
+ "start": 1194966,
28
+ "end": 1194969,
29
+ "ctxt": 2
30
+ },
31
+ "value": "css",
32
+ "optional": false
33
+ },
34
+ "imported": null,
35
+ "isTypeOnly": false
36
+ }
37
+ ],
38
+ "source": {
39
+ "type": "StringLiteral",
40
+ "span": {
41
+ "start": 1194977,
42
+ "end": 1194990,
43
+ "ctxt": 0
44
+ },
45
+ "value": "@moneko/css",
46
+ "raw": "'@moneko/css'"
47
+ },
48
+ "typeOnly": false,
49
+ "with": null,
50
+ "phase": "evaluation"
51
+ },
52
+ {
53
+ "type": "ImportDeclaration",
54
+ "span": {
55
+ "start": 1194992,
56
+ "end": 1195030,
57
+ "ctxt": 0
58
+ },
59
+ "specifiers": [
60
+ {
61
+ "type": "ImportSpecifier",
62
+ "span": {
63
+ "start": 1195001,
64
+ "end": 1195011,
65
+ "ctxt": 0
66
+ },
67
+ "local": {
68
+ "type": "Identifier",
69
+ "span": {
70
+ "start": 1195001,
71
+ "end": 1195011,
72
+ "ctxt": 2
73
+ },
74
+ "value": "createMemo",
75
+ "optional": false
76
+ },
77
+ "imported": null,
78
+ "isTypeOnly": false
79
+ }
80
+ ],
81
+ "source": {
82
+ "type": "StringLiteral",
83
+ "span": {
84
+ "start": 1195019,
85
+ "end": 1195029,
86
+ "ctxt": 0
87
+ },
88
+ "value": "solid-js",
89
+ "raw": "'solid-js'"
90
+ },
91
+ "typeOnly": false,
92
+ "with": null,
93
+ "phase": "evaluation"
94
+ },
95
+ {
96
+ "type": "FunctionDeclaration",
97
+ "identifier": {
98
+ "type": "Identifier",
99
+ "span": {
100
+ "start": 1195040,
101
+ "end": 1195041,
102
+ "ctxt": 2
103
+ },
104
+ "value": "A",
105
+ "optional": false
106
+ },
107
+ "declare": false,
108
+ "params": [],
109
+ "decorators": [],
110
+ "span": {
111
+ "start": 1195031,
112
+ "end": 1195225,
113
+ "ctxt": 3
114
+ },
115
+ "body": {
116
+ "type": "BlockStatement",
117
+ "span": {
118
+ "start": 1195044,
119
+ "end": 1195225,
120
+ "ctxt": 3
121
+ },
122
+ "stmts": [
123
+ {
124
+ "type": "VariableDeclaration",
125
+ "span": {
126
+ "start": 1195050,
127
+ "end": 1195152,
128
+ "ctxt": 0
129
+ },
130
+ "kind": "const",
131
+ "declare": false,
132
+ "declarations": [
133
+ {
134
+ "type": "VariableDeclarator",
135
+ "span": {
136
+ "start": 1195056,
137
+ "end": 1195151,
138
+ "ctxt": 0
139
+ },
140
+ "id": {
141
+ "type": "Identifier",
142
+ "span": {
143
+ "start": 1195056,
144
+ "end": 1195059,
145
+ "ctxt": 3
146
+ },
147
+ "value": "ass",
148
+ "optional": false,
149
+ "typeAnnotation": null
150
+ },
151
+ "init": {
152
+ "type": "CallExpression",
153
+ "span": {
154
+ "start": 1195062,
155
+ "end": 1195151,
156
+ "ctxt": 0
157
+ },
158
+ "callee": {
159
+ "type": "Identifier",
160
+ "span": {
161
+ "start": 1195062,
162
+ "end": 1195072,
163
+ "ctxt": 2
164
+ },
165
+ "value": "createMemo",
166
+ "optional": false
167
+ },
168
+ "arguments": [
169
+ {
170
+ "spread": null,
171
+ "expression": {
172
+ "type": "ArrowFunctionExpression",
173
+ "span": {
174
+ "start": 1195073,
175
+ "end": 1195150,
176
+ "ctxt": 0
177
+ },
178
+ "params": [],
179
+ "body": {
180
+ "type": "BlockStatement",
181
+ "span": {
182
+ "start": 1195077,
183
+ "end": 1195150,
184
+ "ctxt": 4
185
+ },
186
+ "stmts": [
187
+ {
188
+ "type": "VariableDeclaration",
189
+ "span": {
190
+ "start": 1195087,
191
+ "end": 1195126,
192
+ "ctxt": 0
193
+ },
194
+ "kind": "const",
195
+ "declare": false,
196
+ "declarations": [
197
+ {
198
+ "type": "VariableDeclarator",
199
+ "span": {
200
+ "start": 1195093,
201
+ "end": 1195125,
202
+ "ctxt": 0
203
+ },
204
+ "id": {
205
+ "type": "Identifier",
206
+ "span": {
207
+ "start": 1195093,
208
+ "end": 1195094,
209
+ "ctxt": 4
210
+ },
211
+ "value": "s",
212
+ "optional": false,
213
+ "typeAnnotation": null
214
+ },
215
+ "init": {
216
+ "type": "TaggedTemplateExpression",
217
+ "span": {
218
+ "start": 1195097,
219
+ "end": 1195125,
220
+ "ctxt": 0
221
+ },
222
+ "tag": {
223
+ "type": "Identifier",
224
+ "span": {
225
+ "start": 1195097,
226
+ "end": 1195100,
227
+ "ctxt": 2
228
+ },
229
+ "value": "css",
230
+ "optional": false
231
+ },
232
+ "typeParameters": null,
233
+ "template": {
234
+ "type": "TemplateLiteral",
235
+ "span": {
236
+ "start": 1195100,
237
+ "end": 1195125,
238
+ "ctxt": 0
239
+ },
240
+ "expressions": [],
241
+ "quasis": [
242
+ {
243
+ "type": "TemplateElement",
244
+ "span": {
245
+ "start": 1195101,
246
+ "end": 1195124,
247
+ "ctxt": 0
248
+ },
249
+ "tail": true,
250
+ "cooked": "\n color: red;\n ",
251
+ "raw": "\n color: red;\n "
252
+ }
253
+ ]
254
+ }
255
+ },
256
+ "definite": false
257
+ }
258
+ ]
259
+ },
260
+ {
261
+ "type": "ReturnStatement",
262
+ "span": {
263
+ "start": 1195135,
264
+ "end": 1195144,
265
+ "ctxt": 0
266
+ },
267
+ "argument": {
268
+ "type": "Identifier",
269
+ "span": {
270
+ "start": 1195142,
271
+ "end": 1195143,
272
+ "ctxt": 4
273
+ },
274
+ "value": "s",
275
+ "optional": false
276
+ }
277
+ }
278
+ ]
279
+ },
280
+ "async": false,
281
+ "generator": false,
282
+ "typeParameters": null,
283
+ "returnType": null
284
+ }
285
+ }
286
+ ],
287
+ "typeArguments": null
288
+ },
289
+ "definite": false
290
+ }
291
+ ]
292
+ },
293
+ {
294
+ "type": "ReturnStatement",
295
+ "span": {
296
+ "start": 1195157,
297
+ "end": 1195223,
298
+ "ctxt": 0
299
+ },
300
+ "argument": {
301
+ "type": "BinaryExpression",
302
+ "span": {
303
+ "start": 1195164,
304
+ "end": 1195222,
305
+ "ctxt": 0
306
+ },
307
+ "operator": "+",
308
+ "left": {
309
+ "type": "TaggedTemplateExpression",
310
+ "span": {
311
+ "start": 1195164,
312
+ "end": 1195216,
313
+ "ctxt": 0
314
+ },
315
+ "tag": {
316
+ "type": "Identifier",
317
+ "span": {
318
+ "start": 1195164,
319
+ "end": 1195167,
320
+ "ctxt": 2
321
+ },
322
+ "value": "css",
323
+ "optional": false
324
+ },
325
+ "typeParameters": null,
326
+ "template": {
327
+ "type": "TemplateLiteral",
328
+ "span": {
329
+ "start": 1195167,
330
+ "end": 1195216,
331
+ "ctxt": 0
332
+ },
333
+ "expressions": [],
334
+ "quasis": [
335
+ {
336
+ "type": "TemplateElement",
337
+ "span": {
338
+ "start": 1195168,
339
+ "end": 1195215,
340
+ "ctxt": 0
341
+ },
342
+ "tail": true,
343
+ "cooked": "\n .body {\n color: red;\n }\n ",
344
+ "raw": "\n .body {\n color: red;\n }\n "
345
+ }
346
+ ]
347
+ }
348
+ },
349
+ "right": {
350
+ "type": "Identifier",
351
+ "span": {
352
+ "start": 1195219,
353
+ "end": 1195222,
354
+ "ctxt": 3
355
+ },
356
+ "value": "ass",
357
+ "optional": false
358
+ }
359
+ }
360
+ }
361
+ ]
362
+ },
363
+ "generator": false,
364
+ "async": false,
365
+ "typeParameters": null,
366
+ "returnType": null
367
+ },
368
+ {
369
+ "type": "ExportDefaultExpression",
370
+ "span": {
371
+ "start": 1195226,
372
+ "end": 1195243,
373
+ "ctxt": 0
374
+ },
375
+ "expression": {
376
+ "type": "Identifier",
377
+ "span": {
378
+ "start": 1195241,
379
+ "end": 1195242,
380
+ "ctxt": 2
381
+ },
382
+ "value": "A",
383
+ "optional": false
384
+ }
385
+ }
386
+ ],
387
+ "interpreter": null
388
+ }
@@ -1 +1 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return c}});const t=require("@swc/core"),r=require("stylis"),l=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function a(e){let t=e.quasis.map(e=>e.raw);return t.reduce((e,r,l)=>(e.push(r),l!==t.length-1&&e.push(`xxx${l}:xxx`),e),[]).join("").trim()}async function c(e){let c=this.async(),{moduleName:n="@moneko/css",allowFuncs:i=["css","injectGlobal"]}=this.getOptions()||{};this.cacheable&&this.cacheable();try{let l=await (0,t.parse)(e,{syntax:"ecmascript"}),s=[];l.body.forEach(e=>{"ImportDeclaration"===e.type&&e.source.value===n&&e.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&i.includes(e.imported.value)?s.push(e.local.value):i.includes(e.local.value)&&s.push(e.local.value))})}),l.body.forEach(function t(l){if(l&&"object"==typeof l){if("TaggedTemplateExpression"===l.type&&"Identifier"===l.tag.type&&s.includes(l.tag.value)){let t=a(l.template),c=function(e,t){let l=a(e.template),c=function e(t){return"string"==typeof t?t:t.map(t=>{switch(t.type){case"import":case"decl":return t.value;case"comm":return"/"===t.props&&t.value.includes("@")?t.value:"";case"rule":return`${t.value.replace(/&\f/g,"&")}{${e(t.children)}}`;default:return`${t.value}{${e(t.children)}}`}}).join("")}((0,r.compile)(l)),n=function(e){let t;let r=/xxx(\d+):xxx/gm,l=[];for(;null!==(t=r.exec(e));)l.push({value:t[0],p1:parseInt(t[1],10),index:t.index});return l}(c);if(0===n.length)return c;let i=c,s=0;return n.forEach(r=>{let l=e.template.expressions[r.p1],a=`xxx${r.p1}:xxx`,c=i.indexOf(a,s);if(-1!==c&&"span"in l){let e=t.slice(l.span.start,l.span.end);i=i.slice(0,c)+e+i.slice(c+a.length),s=c+e.length}}),i}(l,e);e=e.replace(t,c)}for(let e in l)if(Object.prototype.hasOwnProperty.call(l,e)){let r=l[e];Array.isArray(r)?r.forEach(e=>t(e)):r&&"object"==typeof r&&t(r)}}}),c(null,e)}catch(e){c(e),(0,l.default)(e)}}
1
+ "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return a}});const t=require("@swc/core"),r=require("stylis"),n=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function l(e){return{type:"iTemplateElement",span:{start:0,end:0,ctxt:0},tail:!1,cooked:e,raw:e}}function s(e,t){if("Identifier"===e.tag.type&&t.includes(e.tag.value)){let t=e.template,n=function(e){let t=e.quasis.map(e=>e.cooked);return t.reduce((e,r,n)=>(e.push(r),n!==t.length-1&&e.push(`xxx${n}:xxx`),e),[]).join("").trim()}(t),s=function e(t){return t.map(t=>{switch(t.type){case"import":case"decl":return t.value;case"comm":return"/"===t.props&&t.value.includes("@")?t.value:"";case"rule":return`${t.value.replace(/&\f/g,"&")}{${e(t.children)}}`;default:return`${t.value}{${e(t.children)}}`}}).join("")}(function e(t,r){for(let n=0;n<t.length;n++){let l=t[n],s=l.parent,a=l.children;s?!function(e){var t;return"rule"===e.type&&e.parent&&(t=e.parent,e.line===t.line&&e.column===t.column)}(l)&&s.children.push(l):r.push(l),Array.isArray(a)&&(l.children=[],e(a,r))}return r}((0,r.compile)(n),[])),a=function(e,t){let r=function(e){let t;let r=/xxx(\d+):xxx/gm,n=[];for(;null!==(t=r.exec(e));)n.push({value:t[0],p1:parseInt(t[1],10),index:t.index});return n}(e);if(0===r.length)return""===e?[]:[l(e)];let n=[],s=[],a=0;return r.forEach(({value:i,p1:o,index:u},c)=>{let p=e.substring(a,u);a=a+p.length+i.length,p||0!==c?n.push(l(p)):n.push(l("")),s.push(t[o]),c===r.length-1&&n.push(l(e.substring(u+i.length)))}),s.reduce((e,t,r)=>e.concat([t],n[r+1]),[n[0]]).filter(e=>""!==e.raw)}(s,t.expressions);if(s.length>1){let e=[],r=[];a.forEach((t,n)=>{"iTemplateElement"===t.type?e.push({...t,type:"TemplateElement",tail:n===a.length-1}):r.push(t)}),t.quasis=e,t.expressions=r}}}async function a(e){let r=this.async(),{moduleName:l="@moneko/css",allowFuncs:a=["css","injectGlobal"]}=this.getOptions()||{};this.cacheable&&this.cacheable();try{let n=await (0,t.parse)(e,{syntax:"ecmascript"}),i=[];n.body.forEach(e=>{"ImportDeclaration"===e.type&&e.source.value===l&&e.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&a.includes(e.imported.value)?i.push(e.local.value):a.includes(e.local.value)&&i.push(e.local.value))})}),n.body.forEach(e=>{!function(e){if("ExportDeclaration"===e.type||"ExpressionStatement"===e.type){let t="declaration"in e?e.declaration:e.expression;t&&"CallExpression"===t.type&&t.arguments.forEach(e=>{e.expression&&"TaggedTemplateExpression"===e.expression.type&&s(e.expression,i)}),t&&"VariableDeclaration"===t.type&&t.declarations.forEach(e=>{e.init?.type==="TaggedTemplateExpression"&&s(e.init,i)})}else"CallExpression"===e.type&&e.arguments.forEach(e=>{e.expression&&"TaggedTemplateExpression"===e.expression.type&&s(e.expression,i)})}(e)});let{code:o}=await (0,t.print)(n);r(null,o)}catch(e){r(e),(0,n.default)(e)}}
@@ -1,4 +1,4 @@
1
- import { type Expression, type Import, type ModuleItem, parse, type TaggedTemplateExpression, type TemplateLiteral } from '@swc/core';
1
+ import { type Expression, type ModuleItem, parse, print, type TaggedTemplateExpression, type TemplateElement, type TemplateLiteral } from '@swc/core';
2
2
  import { compile, type Element } from 'stylis';
3
3
  import type { LoaderContext } from 'webpack';
4
4
  import log from '../commom/log.mjs';
@@ -7,8 +7,17 @@ export interface CssInJsMinifyOption {
7
7
  moduleName?: string;
8
8
  allowFuncs?: string[];
9
9
  }
10
- declare function stringifyTree(elements: Element[] | string);
11
- declare function createRawStringFromTemplateLiteral(quasi: TemplateLiteral);
10
+ declare function haveSameLocation(element1: Element, element2: Element);
11
+ declare function isAutoInsertedRule(element: Element);
12
+ declare function toInputTree(elements: Element[], tree: Element[]);
13
+ declare function stringifyTree(elements: Element[]);
12
14
  declare function getDynamicMatches(str: string);
13
- declare function minify(node: TaggedTemplateExpression, sourceCode: string);
15
+ declare function interleave(strings: (ITemplateElement | Expression)[], interpolations: Expression[]);
16
+ declare function createRawStringFromTemplateLiteral(template: TemplateLiteral);
17
+ interface ITemplateElement extends Omit<TemplateElement, 'type'> {
18
+ type: 'iTemplateElement';
19
+ }
20
+ declare function createTemplateElement(raw: string): ITemplateElement;
21
+ declare function replacePlaceholdersWithExpressions(str: string, expressions: Expression[]);
22
+ declare function transform(expression: TaggedTemplateExpression, names: string[]);
14
23
  export default async function cssInJsMinifyLoader(this: LoaderContext<CssInJsMinifyOption>, sourceCode: string);