@mybricks/to-code-taro 1.1.8 → 1.2.2

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.
Files changed (62) hide show
  1. package/dist/cjs/generate/generateTaroProjectJson.js +11 -11
  2. package/dist/cjs/handleModule.js +1 -1
  3. package/dist/cjs/taro-template.json +6 -6008
  4. package/dist/cjs/utils/logic/handleProcess.js +1 -1
  5. package/dist/esm/generate/generateTaroProjectJson.js +12 -12
  6. package/dist/esm/handleModule.js +1 -1
  7. package/dist/esm/taro-template.json +6 -6008
  8. package/dist/esm/utils/logic/handleProcess.js +1 -1
  9. package/package.json +3 -9
  10. package/README.md +0 -58
  11. package/dist/cjs/core/mybricks/MyBricksDescriptor.js +0 -213
  12. package/dist/cjs/core/mybricks/Subject.js +0 -119
  13. package/dist/cjs/core/mybricks/constant.js +0 -70
  14. package/dist/cjs/core/mybricks/context.js +0 -33
  15. package/dist/cjs/core/mybricks/createEnv.js +0 -39
  16. package/dist/cjs/core/mybricks/createJSHandle.js +0 -191
  17. package/dist/cjs/core/mybricks/createModuleEventsHandle.js +0 -49
  18. package/dist/cjs/core/mybricks/createReactiveInputHandler.js +0 -63
  19. package/dist/cjs/core/mybricks/event.js +0 -70
  20. package/dist/cjs/core/mybricks/index.js +0 -871
  21. package/dist/cjs/core/mybricks/log.js +0 -37
  22. package/dist/cjs/core/mybricks/utils.js +0 -69
  23. package/dist/cjs/core/mybricks/variables.js +0 -217
  24. package/dist/cjs/core/utils/ComContext.js +0 -51
  25. package/dist/cjs/core/utils/PopupRenderer.js +0 -63
  26. package/dist/cjs/core/utils/comRefResolver.js +0 -112
  27. package/dist/cjs/core/utils/event.js +0 -53
  28. package/dist/cjs/core/utils/hooks.js +0 -238
  29. package/dist/cjs/core/utils/index.js +0 -77
  30. package/dist/cjs/core/utils/pageRouter.js +0 -104
  31. package/dist/cjs/core/utils/pool.js +0 -63
  32. package/dist/cjs/core/utils/popupRouter.js +0 -98
  33. package/dist/cjs/core/utils/slots.js +0 -183
  34. package/dist/cjs/core/utils/tabbar.js +0 -56
  35. package/dist/cjs/core/utils/useContext.js +0 -112
  36. package/dist/cjs/core/utils/with.js +0 -109
  37. package/dist/esm/core/mybricks/MyBricksDescriptor.js +0 -232
  38. package/dist/esm/core/mybricks/Subject.js +0 -149
  39. package/dist/esm/core/mybricks/constant.js +0 -18
  40. package/dist/esm/core/mybricks/context.js +0 -5
  41. package/dist/esm/core/mybricks/createEnv.js +0 -9
  42. package/dist/esm/core/mybricks/createJSHandle.js +0 -189
  43. package/dist/esm/core/mybricks/createModuleEventsHandle.js +0 -26
  44. package/dist/esm/core/mybricks/createReactiveInputHandler.js +0 -40
  45. package/dist/esm/core/mybricks/event.js +0 -44
  46. package/dist/esm/core/mybricks/index.js +0 -952
  47. package/dist/esm/core/mybricks/log.js +0 -8
  48. package/dist/esm/core/mybricks/utils.js +0 -41
  49. package/dist/esm/core/mybricks/variables.js +0 -190
  50. package/dist/esm/core/utils/ComContext.js +0 -16
  51. package/dist/esm/core/utils/PopupRenderer.js +0 -27
  52. package/dist/esm/core/utils/comRefResolver.js +0 -134
  53. package/dist/esm/core/utils/event.js +0 -32
  54. package/dist/esm/core/utils/hooks.js +0 -287
  55. package/dist/esm/core/utils/index.js +0 -12
  56. package/dist/esm/core/utils/pageRouter.js +0 -112
  57. package/dist/esm/core/utils/pool.js +0 -52
  58. package/dist/esm/core/utils/popupRouter.js +0 -117
  59. package/dist/esm/core/utils/slots.js +0 -194
  60. package/dist/esm/core/utils/tabbar.js +0 -47
  61. package/dist/esm/core/utils/useContext.js +0 -100
  62. package/dist/esm/core/utils/with.js +0 -115
@@ -1,871 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/core/mybricks/index.js
21
- var mybricks_exports = {};
22
- __export(mybricks_exports, {
23
- BaseController: () => BaseController,
24
- Page: () => Page,
25
- Vars: () => Vars,
26
- createBus: () => createBus,
27
- createData: () => createData,
28
- createEventsHandle: () => createEventsHandle,
29
- createFx: () => createFx,
30
- createInputsHandle: () => createInputsHandle,
31
- createModifier: () => createModifier,
32
- createModuleInputsHandle: () => createModuleInputsHandle,
33
- createSlotsIO: () => createSlotsIO,
34
- createStyles: () => createStyles,
35
- emit: () => emit,
36
- join: () => join,
37
- merge: () => merge,
38
- pageController: () => pageController,
39
- transformApi: () => transformApi,
40
- transformBus: () => transformBus
41
- });
42
- module.exports = __toCommonJS(mybricks_exports);
43
- var import_constant = require("./constant");
44
- var import_log = require("./log");
45
- var import_Subject = require("./Subject");
46
- var import_context = require("./context");
47
- var import_utils = require("./utils");
48
- var import_createReactiveInputHandler = require("./createReactiveInputHandler");
49
- __reExport(mybricks_exports, require("./MyBricksDescriptor"), module.exports);
50
- __reExport(mybricks_exports, require("./createModuleEventsHandle"), module.exports);
51
- __reExport(mybricks_exports, require("./createJSHandle"), module.exports);
52
- __reExport(mybricks_exports, require("./Subject"), module.exports);
53
- __reExport(mybricks_exports, require("./createEnv"), module.exports);
54
- __reExport(mybricks_exports, require("./variables"), module.exports);
55
- __reExport(mybricks_exports, require("./event"), module.exports);
56
- var merge = (...subjects) => {
57
- const merge2 = new import_Subject.Subject();
58
- subjects.forEach((subject) => {
59
- if (subject == null ? void 0 : subject[import_constant.SUBJECT_SUBSCRIBE]) {
60
- subject[import_constant.SUBJECT_SUBSCRIBE]((value) => {
61
- merge2[import_constant.SUBJECT_NEXT](value);
62
- });
63
- } else {
64
- merge2[import_constant.SUBJECT_NEXT](subject);
65
- }
66
- });
67
- return merge2;
68
- };
69
- var createInputsHandle = (params, init = false) => {
70
- var _a;
71
- if (init) {
72
- const _inputEvents = {};
73
- const _inputEventsTodo = {};
74
- const _comInfo = {};
75
- const controllerContext = {
76
- initStyles: {},
77
- initData: {},
78
- dataChangedSubjects: {},
79
- // 唯一标记
80
- mark: {}
81
- };
82
- const proxy = new Proxy({}, {
83
- get(_, key) {
84
- if (key === "_inputEvents") {
85
- return _inputEvents;
86
- } else if (key === "_inputEventsTodo") {
87
- return _inputEventsTodo;
88
- } else if (key === "_comInfo") {
89
- return _comInfo;
90
- } else if (key === import_constant.CONTROLLER_CONTEXT) {
91
- return controllerContext;
92
- } else if (key === "_setStyle") {
93
- return (value0, value1) => {
94
- const next = (value) => {
95
- if (Object.prototype.toString.call(value) === "[object Object]") {
96
- Object.entries(value).forEach(([selector, nextStyle]) => {
97
- if (!controllerContext.styles) {
98
- const { initStyles } = controllerContext;
99
- if (!initStyles[selector]) {
100
- initStyles[selector] = nextStyle;
101
- } else {
102
- const initStyle = initStyles[selector];
103
- Object.entries(nextStyle).forEach(([key2, value2]) => {
104
- initStyle[key2] = value2;
105
- });
106
- }
107
- return;
108
- }
109
- const { style } = controllerContext.styles.getStyle(selector);
110
- const updators = controllerContext.styles.getUpdators(selector);
111
- Object.entries(nextStyle).forEach(([key2, value2]) => {
112
- style[key2] = value2;
113
- });
114
- if (updators) {
115
- updators.forEach((updator) => {
116
- updator(selector, style);
117
- });
118
- }
119
- });
120
- }
121
- };
122
- if (typeof value0 === "string" && value1) {
123
- if (value1 == null ? void 0 : value1[import_constant.SUBJECT_SUBSCRIBE]) {
124
- value1[import_constant.SUBJECT_SUBSCRIBE]((value) => {
125
- next({
126
- [value0]: value
127
- });
128
- });
129
- } else {
130
- next({
131
- [value0]: value1
132
- });
133
- }
134
- } else {
135
- if (value0 == null ? void 0 : value0[import_constant.SUBJECT_SUBSCRIBE]) {
136
- value0[import_constant.SUBJECT_SUBSCRIBE]((value) => {
137
- next(value);
138
- });
139
- } else {
140
- next(value0);
141
- }
142
- }
143
- };
144
- } else if (key === "_setData") {
145
- return (...args) => {
146
- if (args.length === 2) {
147
- const [path, value] = args;
148
- const next = (params2) => {
149
- const { path: path2, value: value2 } = params2;
150
- if (!controllerContext.data) {
151
- const { initData } = controllerContext;
152
- initData[path2] = value2;
153
- return;
154
- }
155
- (0, import_utils.safeSetByPath)({
156
- data: controllerContext.data,
157
- path: path2.split("."),
158
- value: {
159
- value: value2,
160
- [import_constant.EXCUTE_TYPE_KEY]: import_constant.EXCUTE_TYPE_VALUE.DATACHANGED
161
- }
162
- });
163
- };
164
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
165
- value[import_constant.SUBJECT_SUBSCRIBE]((value2, extra) => {
166
- if ((extra == null ? void 0 : extra[import_constant.EXCUTE_TYPE_KEY]) === import_constant.EXCUTE_TYPE_VALUE.DATACHANGED && (extra == null ? void 0 : extra.controllerMark) === controllerContext.mark) {
167
- return;
168
- }
169
- next({ value: value2, path });
170
- });
171
- } else {
172
- next({ value, path });
173
- }
174
- }
175
- };
176
- } else if (key === "_dataChanged") {
177
- return (path) => {
178
- const subject = new import_Subject.Subject();
179
- controllerContext.dataChangedSubjects[path] = subject;
180
- return subject;
181
- };
182
- }
183
- return (value) => {
184
- if (!_inputEvents[key]) {
185
- if (!_inputEventsTodo[key]) {
186
- _inputEventsTodo[key] = [];
187
- }
188
- const rels = {};
189
- _inputEventsTodo[key].push({
190
- value,
191
- rels
192
- });
193
- return new Proxy({}, {
194
- get(_2, key2) {
195
- return rels[key2] || (rels[key2] = new import_Subject.Subject());
196
- }
197
- });
198
- }
199
- return (0, import_createReactiveInputHandler.createReactiveInputHandler)({
200
- input(value2, proxy2) {
201
- (0, import_log.log)(`${import_constant.EXE_TITLE_MAP["input"]} ${_comInfo.title} | ${key}`, JSON.stringify(value2));
202
- return _inputEvents[key](value2, proxy2);
203
- },
204
- title: _comInfo.title,
205
- value,
206
- rels: {}
207
- });
208
- };
209
- }
210
- });
211
- return proxy;
212
- } else {
213
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].inputs) {
214
- const { controller, title, styles } = params;
215
- const { _inputEvents, _comInfo, _inputEventsTodo, [import_constant.CONTROLLER_CONTEXT]: controllerContext } = controller;
216
- _comInfo.title = title;
217
- controllerContext.initModifier = {
218
- visibility: ((_a = styles == null ? void 0 : styles.root) == null ? void 0 : _a.display) === "none" ? Visibility.None : Visibility.Visible
219
- };
220
- const createVisibilityHandler = (visibilityState) => {
221
- return (value) => {
222
- const setVisibility = () => {
223
- var _a2, _b;
224
- if (!((_a2 = controllerContext.modifier) == null ? void 0 : _a2.attribute)) {
225
- controllerContext.initModifier.visibility = visibilityState;
226
- } else {
227
- (_b = controllerContext.modifier.attribute) == null ? void 0 : _b.visibility(visibilityState);
228
- }
229
- };
230
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
231
- value[import_constant.SUBJECT_SUBSCRIBE](setVisibility);
232
- } else {
233
- setVisibility();
234
- }
235
- };
236
- };
237
- _inputEvents.show = createVisibilityHandler(Visibility.Visible);
238
- _inputEvents.hide = createVisibilityHandler(Visibility.None);
239
- _inputEvents.showOrHide = (value) => {
240
- const setVisibility = (value2) => {
241
- var _a2, _b;
242
- if (!((_a2 = controllerContext.modifier) == null ? void 0 : _a2.attribute)) {
243
- controllerContext.initModifier.visibility = !!value2 ? Visibility.Visible : Visibility.None;
244
- } else {
245
- (_b = controllerContext.modifier.attribute) == null ? void 0 : _b.visibility(!!value2 ? Visibility.Visible : Visibility.None);
246
- }
247
- };
248
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
249
- value[import_constant.SUBJECT_SUBSCRIBE](setVisibility);
250
- } else {
251
- setVisibility(value);
252
- }
253
- };
254
- ["show", "hide", "showOrHide"].forEach((key) => {
255
- const todo = _inputEventsTodo[key];
256
- if (todo) {
257
- Reflect.deleteProperty(_inputEventsTodo, key);
258
- todo.forEach(({ value }) => {
259
- _inputEvents[key](value);
260
- });
261
- }
262
- });
263
- const proxy = new Proxy(controller, {
264
- get(_, key) {
265
- return (input) => {
266
- if (!_inputEvents[key]) {
267
- if (_inputEventsTodo[key]) {
268
- _inputEventsTodo[key].forEach(({ value, rels }) => {
269
- (0, import_createReactiveInputHandler.createReactiveInputHandler)({
270
- input(value2, proxy2) {
271
- (0, import_log.log)(`${import_constant.EXE_TITLE_MAP["input"]} ${title} | ${key}`, JSON.stringify(value2));
272
- return input(value2, proxy2);
273
- },
274
- title,
275
- value,
276
- rels
277
- });
278
- });
279
- Reflect.deleteProperty(_inputEventsTodo, key);
280
- }
281
- }
282
- _inputEvents[key] = input;
283
- };
284
- }
285
- });
286
- params.controller[import_constant.CONTROLLER_CONTEXT].inputs = proxy;
287
- }
288
- return params.controller[import_constant.CONTROLLER_CONTEXT].inputs;
289
- }
290
- };
291
- var createEventsHandle = (params) => {
292
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].outputs) {
293
- params.controller[import_constant.CONTROLLER_CONTEXT].outputs = new Proxy(params.events || {}, {
294
- get(target, key) {
295
- var _a, _b, _c;
296
- const event = (_c = (_b = (_a = params.controller[import_constant.CONTROLLER_CONTEXT].appContext) == null ? void 0 : _a.comEvent) == null ? void 0 : _b[params.uid]) == null ? void 0 : _c[key];
297
- if (event) {
298
- const { getVar, getOutput, getInput } = params.controller[import_constant.CONTROLLER_CONTEXT];
299
- return (value) => {
300
- event(value, {
301
- getVar,
302
- getOutput,
303
- getInput
304
- });
305
- };
306
- }
307
- return target[key] || (() => {
308
- });
309
- }
310
- });
311
- }
312
- return params.controller[import_constant.CONTROLLER_CONTEXT].outputs;
313
- };
314
- var pageController = () => {
315
- return new Proxy({
316
- commit: new import_Subject.Subject(),
317
- cancel: new import_Subject.Subject(),
318
- apply: new import_Subject.Subject(),
319
- close: new import_Subject.Subject()
320
- }, {
321
- get(target, key) {
322
- return target[key];
323
- }
324
- });
325
- };
326
- var Page = class {
327
- appRouter;
328
- constructor(appRouter) {
329
- this.appRouter = appRouter;
330
- }
331
- /** 获取当前页面入参 */
332
- getParams(name) {
333
- const params = this.appRouter.getParams(name);
334
- const subject = new import_Subject.Subject();
335
- subject[import_constant.SUBJECT_NEXT](params == null ? void 0 : params.value);
336
- return subject;
337
- }
338
- /** 打开 */
339
- open(name, value) {
340
- const controller = pageController();
341
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
342
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
343
- this.appRouter.push(name, { value: value2, controller });
344
- });
345
- } else {
346
- this.appRouter.push(name, { value, controller });
347
- }
348
- return controller;
349
- }
350
- /** 打开 */
351
- replace(name, value) {
352
- const controller = pageController();
353
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
354
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
355
- this.appRouter.replace(name, { value: value2, controller });
356
- });
357
- } else {
358
- this.appRouter.replace(name, { value, controller });
359
- }
360
- return controller;
361
- }
362
- /** 确定 */
363
- commit(name, value) {
364
- const params = this.appRouter.getParams(name);
365
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
366
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
367
- this.appRouter.pop();
368
- setTimeout(() => {
369
- params.controller.commit[import_constant.SUBJECT_NEXT](value2);
370
- }, 100);
371
- });
372
- } else {
373
- this.appRouter.pop();
374
- setTimeout(() => {
375
- params.controller.commit[import_constant.SUBJECT_NEXT](value);
376
- }, 100);
377
- }
378
- }
379
- /** 取消 */
380
- cancel(name, value) {
381
- const params = this.appRouter.getParams(name);
382
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
383
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
384
- this.appRouter.pop();
385
- setTimeout(() => {
386
- params.controller.cancel[import_constant.SUBJECT_NEXT](value2);
387
- }, 100);
388
- });
389
- } else {
390
- this.appRouter.pop();
391
- setTimeout(() => {
392
- params.controller.cancel[import_constant.SUBJECT_NEXT](value);
393
- }, 100);
394
- }
395
- }
396
- /** 应用,不关闭 */
397
- apply(name, value) {
398
- const params = this.appRouter.getParams(name);
399
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
400
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
401
- params.controller.apply[import_constant.SUBJECT_NEXT](value2);
402
- });
403
- } else {
404
- params.controller.apply[import_constant.SUBJECT_NEXT](value);
405
- }
406
- }
407
- /** 关闭 */
408
- close(name, value) {
409
- const params = this.appRouter.getParams(name);
410
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
411
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
412
- this.appRouter.pop();
413
- setTimeout(() => {
414
- params.controller.close[import_constant.SUBJECT_NEXT](value2);
415
- }, 100);
416
- });
417
- } else {
418
- this.appRouter.pop();
419
- setTimeout(() => {
420
- params.controller.close[import_constant.SUBJECT_NEXT](value);
421
- }, 100);
422
- }
423
- }
424
- };
425
- var emit = (fn, value) => {
426
- const subject = new import_Subject.Subject();
427
- if (!fn) {
428
- return subject;
429
- }
430
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
431
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
432
- const res = fn(value2);
433
- if (res instanceof Promise) {
434
- res.then((value3) => {
435
- subject[import_constant.SUBJECT_NEXT](value3);
436
- });
437
- } else {
438
- subject[import_constant.SUBJECT_NEXT](res);
439
- }
440
- });
441
- } else {
442
- const res = fn(value);
443
- if (res instanceof Promise) {
444
- res.then((value2) => {
445
- subject[import_constant.SUBJECT_NEXT](value2);
446
- });
447
- } else {
448
- subject[import_constant.SUBJECT_NEXT](res);
449
- }
450
- }
451
- return subject;
452
- };
453
- var createFx = (fx) => {
454
- return (value, ...args) => {
455
- const outputs = {};
456
- const proxy = new Proxy({}, {
457
- get(_, key) {
458
- return outputs[key] || (outputs[key] = new import_Subject.Subject());
459
- }
460
- });
461
- const next = (value2) => {
462
- const res = fx(value2, ...args);
463
- if (res) {
464
- Object.entries(res).forEach(([key, value3]) => {
465
- if (!outputs[key]) {
466
- outputs[key] = new import_Subject.Subject();
467
- }
468
- if (value3 == null ? void 0 : value3[import_constant.SUBJECT_SUBSCRIBE]) {
469
- value3[import_constant.SUBJECT_SUBSCRIBE]((value4) => {
470
- outputs[key][import_constant.SUBJECT_NEXT](value4);
471
- });
472
- } else {
473
- outputs[key][import_constant.SUBJECT_NEXT](value3);
474
- }
475
- });
476
- }
477
- };
478
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
479
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
480
- next(value2);
481
- });
482
- } else {
483
- next(value);
484
- }
485
- return proxy;
486
- };
487
- };
488
- var createSlotsIO = (params) => {
489
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].slotsIO) {
490
- const slotsIOMap = {};
491
- params.controller[import_constant.CONTROLLER_CONTEXT].slotsIO = new Proxy({}, {
492
- get(_, key) {
493
- if (!slotsIOMap[key]) {
494
- const inputsMap = {};
495
- slotsIOMap[key] = {
496
- inputs: new Proxy({}, {
497
- get(_2, key2) {
498
- if (!inputsMap[key2]) {
499
- inputsMap[key2] = new import_Subject.Subject();
500
- }
501
- const next = (value) => {
502
- inputsMap[key2][import_constant.SUBJECT_NEXT](value);
503
- };
504
- next[import_constant.SUBJECT_SUBSCRIBE] = (next2) => {
505
- inputsMap[key2][import_constant.SUBJECT_SUBSCRIBE](next2);
506
- };
507
- return next;
508
- }
509
- }),
510
- outputs: new Proxy({}, {
511
- get(_2, key2) {
512
- return (next) => {
513
- return (value) => {
514
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
515
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
516
- next(value2);
517
- });
518
- } else {
519
- next(value);
520
- }
521
- };
522
- };
523
- }
524
- })
525
- };
526
- }
527
- return slotsIOMap[key];
528
- }
529
- });
530
- }
531
- return params.controller[import_constant.CONTROLLER_CONTEXT].slotsIO;
532
- };
533
- var createModuleInputsHandle = () => {
534
- const inputsMap = {};
535
- const outputsMap = {};
536
- return new Proxy({}, {
537
- get(_, key) {
538
- if (key === "outputs") {
539
- return new Proxy({}, {
540
- get(_2, key2) {
541
- if (!outputsMap[key2]) {
542
- outputsMap[key2] = new import_Subject.Subject();
543
- }
544
- return (value) => {
545
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
546
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
547
- outputsMap[key2][import_constant.SUBJECT_NEXT](value2);
548
- });
549
- } else {
550
- outputsMap[key2][import_constant.SUBJECT_NEXT](value);
551
- }
552
- };
553
- }
554
- });
555
- }
556
- if (!inputsMap[key]) {
557
- inputsMap[key] = new import_Subject.Subject();
558
- }
559
- const next = (value) => {
560
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
561
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
562
- inputsMap[key][import_constant.SUBJECT_NEXT](value2);
563
- });
564
- } else {
565
- inputsMap[key][import_constant.SUBJECT_NEXT](value);
566
- }
567
- return new Proxy({}, {
568
- get(_2, key2) {
569
- return outputsMap[key2] || (outputsMap[key2] = new import_Subject.Subject());
570
- }
571
- });
572
- };
573
- return new Proxy(next, {
574
- get(_2, proxyKey) {
575
- if (proxyKey === "subscribe" || proxyKey === import_constant.SUBJECT_SUBSCRIBE) {
576
- return (next2) => {
577
- inputsMap[key][import_constant.SUBJECT_SUBSCRIBE](next2);
578
- };
579
- } else if (proxyKey === "value" || proxyKey === import_constant.SUBJECT_VALUE) {
580
- return inputsMap[key][import_constant.SUBJECT_VALUE];
581
- }
582
- }
583
- });
584
- }
585
- });
586
- };
587
- var Styles = class {
588
- styles = {};
589
- map = /* @__PURE__ */ new Map();
590
- constructor(styles) {
591
- this.styles = styles;
592
- }
593
- getStyle(selector) {
594
- let style = this.styles[selector];
595
- if (!style) {
596
- this.styles[selector] = {};
597
- style = this.styles[selector];
598
- }
599
- return {
600
- selector,
601
- style,
602
- setUpdator: (updator, uid) => {
603
- if (!this.map.has(selector)) {
604
- this.map.set(selector, /* @__PURE__ */ new Map());
605
- }
606
- const selectorMap = this.map.get(selector);
607
- selectorMap.set(uid, updator);
608
- },
609
- ...style
610
- };
611
- }
612
- getUpdators(selector) {
613
- return this.map.get(selector);
614
- }
615
- };
616
- var createStyles = (params) => {
617
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].styles) {
618
- const initStyles = params.controller[import_constant.CONTROLLER_CONTEXT].initStyles;
619
- const { styles, parentSlot } = params;
620
- Object.entries(initStyles).forEach(([selector, initStyle]) => {
621
- if (!styles[selector]) {
622
- styles[selector] = initStyle;
623
- } else {
624
- const style = styles[selector];
625
- Object.entries(initStyle).forEach(([key, value]) => {
626
- style[key] = value;
627
- });
628
- }
629
- });
630
- if (parentSlot == null ? void 0 : parentSlot.itemWrap) {
631
- const { root, ...other } = styles;
632
- params.controller[import_constant.CONTROLLER_CONTEXT].styles = new Styles(other);
633
- } else {
634
- params.controller[import_constant.CONTROLLER_CONTEXT].styles = new Styles(styles);
635
- }
636
- }
637
- return new Proxy({}, {
638
- ownKeys() {
639
- return Object.keys(params.styles);
640
- },
641
- getOwnPropertyDescriptor(k) {
642
- return {
643
- enumerable: true,
644
- configurable: true
645
- };
646
- },
647
- get(_, key) {
648
- return params.controller[import_constant.CONTROLLER_CONTEXT].styles.getStyle(key);
649
- }
650
- });
651
- };
652
- var transformApi = (api) => {
653
- return (value, cb) => {
654
- const id = `${Math.random()}_${(/* @__PURE__ */ new Date()).getTime()}`;
655
- const outputs = {};
656
- const dispose = () => {
657
- };
658
- const proxy = new Proxy(dispose, {
659
- get(_, key) {
660
- return outputs[key] || (outputs[key] = new import_Subject.Subject());
661
- }
662
- });
663
- let isDispose = false;
664
- import_context.context.apiRun = id;
665
- const res = api(value);
666
- import_context.context.apiRun = null;
667
- if (res) {
668
- Object.entries(res).forEach(([key, value2]) => {
669
- var _a, _b;
670
- if (!outputs[key]) {
671
- outputs[key] = new import_Subject.Subject();
672
- }
673
- if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
674
- value2[import_constant.SUBJECT_SUBSCRIBE]((value3) => {
675
- var _a2, _b2;
676
- if (isDispose) {
677
- return;
678
- }
679
- isDispose = true;
680
- outputs[key][import_constant.SUBJECT_NEXT](value3);
681
- (_a2 = cb == null ? void 0 : cb[key]) == null ? void 0 : _a2.call(cb, value3);
682
- (_b2 = import_context.context.apiRunVariablesSubject[id]) == null ? void 0 : _b2.forEach((subject) => {
683
- subject.destroy();
684
- });
685
- });
686
- } else {
687
- if (isDispose) {
688
- return;
689
- }
690
- isDispose = true;
691
- outputs[key][import_constant.SUBJECT_NEXT](value2);
692
- (_a = cb == null ? void 0 : cb[key]) == null ? void 0 : _a.call(cb, value2);
693
- (_b = import_context.context.apiRunVariablesSubject[id]) == null ? void 0 : _b.forEach((subject) => {
694
- subject.destroy();
695
- });
696
- }
697
- });
698
- }
699
- return proxy;
700
- };
701
- };
702
- var transformBus = (bus) => {
703
- return (newBus) => {
704
- Object.entries(newBus).forEach(([key, newBus2]) => {
705
- bus[key] = (value) => {
706
- const outputs = {};
707
- const callBack = new Proxy({}, {
708
- get(_, key2) {
709
- return (value2) => {
710
- const output = outputs[key2] || (outputs[key2] = new import_Subject.Subject());
711
- output[import_constant.SUBJECT_NEXT](value2);
712
- };
713
- }
714
- });
715
- if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
716
- value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
717
- newBus2(value2, callBack);
718
- });
719
- } else {
720
- newBus2(value, callBack);
721
- }
722
- return new Proxy({}, {
723
- get(_, key2) {
724
- return outputs[key2] || (outputs[key2] = new import_Subject.Subject());
725
- }
726
- });
727
- };
728
- });
729
- };
730
- };
731
- var createBus = (bus) => {
732
- return () => {
733
- return new Proxy({}, {
734
- get() {
735
- return new import_Subject.Subject();
736
- }
737
- });
738
- };
739
- };
740
- var join = (lastSubject, nextSubject) => {
741
- const subject = new import_Subject.Subject();
742
- const next = () => {
743
- if (nextSubject == null ? void 0 : nextSubject[import_constant.SUBJECT_SUBSCRIBE]) {
744
- subject[import_constant.SUBJECT_NEXT](nextSubject[import_constant.SUBJECT_VALUE]);
745
- } else {
746
- subject[import_constant.SUBJECT_NEXT](nextSubject);
747
- }
748
- };
749
- if (lastSubject == null ? void 0 : lastSubject[import_constant.SUBJECT_SUBSCRIBE]) {
750
- lastSubject[import_constant.SUBJECT_SUBSCRIBE](() => {
751
- next();
752
- });
753
- } else {
754
- next();
755
- }
756
- return subject;
757
- };
758
- var createModifier = (params, Modifier) => {
759
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].modifier) {
760
- params.controller[import_constant.CONTROLLER_CONTEXT].modifier = new Modifier(params.controller[import_constant.CONTROLLER_CONTEXT].initModifier);
761
- }
762
- return params.controller[import_constant.CONTROLLER_CONTEXT].modifier;
763
- };
764
- var DATA_PROXY = Symbol("DATA_PROXY");
765
- var dataProxy = (params) => {
766
- const { data, path, config } = params;
767
- return new Proxy(data, {
768
- get(target, key, receiver) {
769
- if (key === DATA_PROXY) {
770
- return true;
771
- }
772
- const value = Reflect.get(target, key, receiver);
773
- if (typeof key !== "string" || target.hasOwnProperty(key)) {
774
- return value;
775
- }
776
- if ((0, import_utils.isObject)(value)) {
777
- if (value[DATA_PROXY]) {
778
- return value;
779
- }
780
- return dataProxy({
781
- data: value,
782
- path: path ? `${path}.${key}` : key,
783
- config
784
- });
785
- }
786
- return value;
787
- },
788
- set(target, key, value, receiver) {
789
- var _a;
790
- if (typeof key !== "string" || target.hasOwnProperty(key)) {
791
- Reflect.set(target, key, value, receiver);
792
- } else {
793
- if (!(value == null ? void 0 : value[import_constant.EXCUTE_TYPE_KEY])) {
794
- Reflect.set(target, key, value, receiver);
795
- (_a = config == null ? void 0 : config.set) == null ? void 0 : _a.call(config, {
796
- value,
797
- path: path ? `${path}.${key}` : key
798
- });
799
- } else {
800
- Reflect.set(target, key, value.value, receiver);
801
- }
802
- }
803
- return true;
804
- }
805
- });
806
- };
807
- var createData = (params, Data) => {
808
- if (!params.controller[import_constant.CONTROLLER_CONTEXT].data) {
809
- const { initData, dataChangedSubjects, mark } = params.controller[import_constant.CONTROLLER_CONTEXT];
810
- const nextData = Object.assign({}, params.data);
811
- Object.entries(initData).forEach(([path, value]) => {
812
- (0, import_utils.safeSetByPath)({
813
- data: nextData,
814
- path: path.split("."),
815
- value
816
- });
817
- });
818
- const data = new Data(nextData);
819
- const observeData = dataProxy({
820
- data,
821
- path: "",
822
- config: {
823
- set(params2) {
824
- const dataChangedSubject = dataChangedSubjects[params2.path];
825
- if (dataChangedSubject) {
826
- dataChangedSubject[import_constant.SUBJECT_NEXT](params2.value, {
827
- [import_constant.EXCUTE_TYPE_KEY]: import_constant.EXCUTE_TYPE_VALUE.DATACHANGED,
828
- controllerMark: mark
829
- });
830
- }
831
- }
832
- }
833
- });
834
- params.controller[import_constant.CONTROLLER_CONTEXT].data = observeData;
835
- }
836
- return params.controller[import_constant.CONTROLLER_CONTEXT].data;
837
- };
838
- var Vars = class {
839
- [import_constant.VARS_MARK] = true;
840
- };
841
- var BaseController = class {
842
- [import_constant.BASECONTROLLER_MARK] = true;
843
- };
844
- // Annotate the CommonJS export names for ESM import in node:
845
- 0 && (module.exports = {
846
- BaseController,
847
- Page,
848
- Vars,
849
- createBus,
850
- createData,
851
- createEventsHandle,
852
- createFx,
853
- createInputsHandle,
854
- createModifier,
855
- createModuleInputsHandle,
856
- createSlotsIO,
857
- createStyles,
858
- emit,
859
- join,
860
- merge,
861
- pageController,
862
- transformApi,
863
- transformBus,
864
- ...require("./MyBricksDescriptor"),
865
- ...require("./createModuleEventsHandle"),
866
- ...require("./createJSHandle"),
867
- ...require("./Subject"),
868
- ...require("./createEnv"),
869
- ...require("./variables"),
870
- ...require("./event")
871
- });