sdc_client 0.158.9 → 0.160.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/LICENSE +21 -0
  3. package/dist/index.js +23 -13
  4. package/dist/ugly.index.js +2 -1
  5. package/dist/ugly.index.js.LICENSE.txt +1 -8
  6. package/gulp/gulp.jsx +11 -36
  7. package/package.json +23 -12
  8. package/src/index.js +31 -7
  9. package/src/simpleDomControl/AbstractSDC.js +15 -11
  10. package/src/simpleDomControl/sdc_controller.js +3 -3
  11. package/src/simpleDomControl/sdc_dom_events.js +5 -10
  12. package/src/simpleDomControl/sdc_events.js +3 -3
  13. package/src/simpleDomControl/sdc_main.js +34 -13
  14. package/src/simpleDomControl/sdc_model.js +225 -92
  15. package/src/simpleDomControl/sdc_params.js +0 -3
  16. package/src/simpleDomControl/sdc_server_call.js +21 -4
  17. package/src/simpleDomControl/sdc_test_utils.js +0 -1
  18. package/src/simpleDomControl/sdc_utils.js +59 -7
  19. package/src/simpleDomControl/sdc_view.js +16 -1
  20. package/.github/workflows/node.js.yml +0 -38
  21. package/.idea/inspectionProfiles/Project_Default.xml +0 -17
  22. package/.idea/jsLibraryMappings.xml +0 -6
  23. package/.idea/misc.xml +0 -6
  24. package/.idea/modules.xml +0 -8
  25. package/.idea/vcs.xml +0 -6
  26. package/.idea/workspace.xml +0 -403
  27. package/.readthedocs.yaml +0 -13
  28. package/.tool-versions +0 -1
  29. package/SimpleDomControlClient.iml +0 -12
  30. package/docs/api-reference.rst +0 -225
  31. package/docs/conf.py +0 -11
  32. package/docs/controllers.rst +0 -228
  33. package/docs/events-and-dom.rst +0 -120
  34. package/docs/getting-started.rst +0 -143
  35. package/docs/index.rst +0 -22
  36. package/docs/models.rst +0 -351
  37. package/docs/overview.rst +0 -66
  38. package/docs/requirements.txt +0 -1
  39. package/eslint.config.js +0 -43
  40. package/gulpfile.cjs +0 -30
  41. package/jest.config.mjs +0 -197
  42. package/test/controller.test.js +0 -93
  43. package/test/dist.test.js +0 -127
  44. package/test/model.test.js +0 -330
  45. package/test/models/Author.js +0 -145
  46. package/test/models/Book.js +0 -112
  47. package/test/models/BookContent.js +0 -114
  48. package/test/models/SdcUser.js +0 -75
  49. package/test/models/src.js +0 -8
  50. package/test/sdc_model_dates.ai.test.js +0 -57
  51. package/test/sdc_server_call.ai.test.js +0 -267
  52. package/test/utils.js +0 -88
  53. package/test/view.test.js +0 -159
  54. package/test-setup.js +0 -4
  55. package/webpack.config/webpack.default.config.cjs +0 -14
  56. package/webpack.config/webpack.development.config.cjs +0 -14
  57. package/webpack.config/webpack.production.config.cjs +0 -11
package/test/utils.js DELETED
@@ -1,88 +0,0 @@
1
- import {AbstractSDC} from "../src/index.js";
2
-
3
-
4
- export const TestControllerInfo = {
5
- name: 'TestCtr',
6
- tag: 'test-ctr'
7
- };
8
-
9
- export class TestCtr extends AbstractSDC {
10
- constructor() {
11
- super();
12
- this.contentUrl = TestControllerInfo.name; //<test-ctr>
13
- this.events.unshift({});
14
- this.val = 0;
15
- this.contentReload = true;
16
- }
17
-
18
- sayA() {
19
- return 'A'
20
- }
21
-
22
- onInit() {
23
- }
24
- }
25
-
26
- export class TestCtrA extends AbstractSDC {
27
- constructor() {
28
- super();
29
- this.contentUrl = 'TestCtrA'; //<test-ctr-a>
30
- this.events.unshift({});
31
- this.val = 1;
32
- this.val_2 = 2;
33
- }
34
-
35
- sayA() {
36
- return 'B'
37
- }
38
-
39
- sayB() {
40
- return 'B'
41
- }
42
- }
43
-
44
- export class TestList extends AbstractSDC {
45
- constructor() {
46
- super();
47
- this.contentUrl = 'TestCtrA'; //<test-ctr-a>
48
- this.events.unshift({});
49
- this.number = 0;
50
- }
51
-
52
- onInit({ number = 10 }) {
53
- this.number = number;
54
- }
55
-
56
- onLoad(html) {
57
- this.onInit(this.params)
58
- $(html).append('<div><this.listview></this.listview></div>');
59
- return super.onLoad(html);
60
- }
61
-
62
- listview() {
63
- const listItems = [];
64
- for (let i = 0; i < this.number; i++) {
65
- listItems.push(`<test-item data-idx="${i}"></test-item>`);
66
- }
67
-
68
- return `<div>${listItems.join('\n')}</div>`;
69
- }
70
- }
71
-
72
- export class TestItem extends AbstractSDC {
73
- constructor() {
74
- super();
75
- this.contentUrl = 'TestCtrA'; //<test-item>
76
- this.events.unshift({});
77
- }
78
-
79
- onInit({ idx }) {
80
- this.idx = idx;
81
- }
82
-
83
- onLoad(html) {
84
- this.onInit(this.params);
85
- $(html).append(`<input name="i_${this.idx}" />`);
86
- return super.onLoad(html);
87
- }
88
- }
package/test/view.test.js DELETED
@@ -1,159 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
-
5
- import {TestItem, TestList} from "./utils.js";
6
- import {reconcile} from "../src/simpleDomControl/sdc_view.js";
7
- import {app} from "../src/index.js";
8
- import $ from "jquery";
9
-
10
- window.$ = $;
11
-
12
- describe('Test reconcile', () => {
13
-
14
- beforeAll(() => {
15
- app.updateJquery();
16
- });
17
-
18
- test('Load Content', async () => {
19
- const a = '<div>' +
20
- '<h1>Test</h1>' +
21
- '<ul>' +
22
- '<li>B</li>' +
23
- '<li><input name="TEST" /></li>' +
24
- '<li>D</li>' +
25
- '</ul>' +
26
- '</div>';
27
-
28
- const b = '<div class="class.1">' +
29
- '<p>UPS</p>' +
30
- '<p>UPS</p>' +
31
- '<h1>Test 1</h1>' +
32
- '<ul>' +
33
- '<li>A</li>' +
34
- '<li>A1 <input name="TEST" type="text"/></li>' +
35
- '<li>B</li>' +
36
- '<li><input name="TEST" type="text"/></li>' +
37
- '<li>D</li>' +
38
- '</ul>' +
39
- '</div>';
40
- const $b = $(b);
41
- const $a = $(a);
42
- const input_a = $a.find('[name=TEST]')[0]
43
- reconcile($b, $a);
44
- expect($a.html()).toBe($(b).html());
45
- expect($a[0].className).toBe('class.1');
46
- expect(input_a).toBe($a.find('[name=TEST]')[0]);
47
-
48
- });
49
-
50
- test('Load Content 2', async () => {
51
- const a = '<div>' +
52
- '<p>UPS</p>' +
53
- '<p>UPS</p>' +
54
- '<h1>Test</h1>' +
55
- '<ul>' +
56
- '<li>B</li>' +
57
- '<li><input name="TEST" /></li>' +
58
- '<li>D</li>' +
59
- '</ul>' +
60
- '</div>';
61
-
62
- const b = '<div class="class.1">' +
63
- '<h1>Test 1</h1>' +
64
- '<ul>' +
65
- '<li>A</li>' +
66
- '<li>A1 <input name="TEST" type="text"/></li>' +
67
- '<li>B</li>' +
68
- '<li><input name="TEST" type="text"/></li>' +
69
- '<li>D</li>' +
70
- '</ul>' +
71
- '</div>';
72
- const $b = $(b);
73
- const $a = $(a);
74
- const input_a = $a.find('[name=TEST]')[0]
75
- reconcile($b, $a);
76
- expect($a.html()).toBe($(b).html());
77
- expect($a[0].className).toBe('class.1');
78
- expect(input_a).toBe($a.find('[name=TEST]')[0]);
79
-
80
- });
81
-
82
- test('Load content 3', () => {
83
- const a = '<div>' +
84
- '<div><p>A1</p><p>B1</p></div>' +
85
- '<div><p>A2</p><p>B2</p></div>' +
86
- '</div>';
87
-
88
- const b = '<div>' +
89
- '<div><p>A2</p><p>B3</p></div>' +
90
- '<div><p>A2</p><p>B4</p></div>' +
91
- '</div>';
92
- const $b = $(b);
93
- const $a = $(a);
94
- reconcile($b, $a);
95
- expect($a.html()).toBe($(b).html());
96
-
97
- });
98
-
99
-
100
- test('Load Content Split', async () => {
101
- const a = '<div>' +
102
- '<ul>' +
103
- '<li>X<input name="TEST" /></li>' +
104
- '</ul>' +
105
- '</div>';
106
-
107
- const b = '<div class="class.1">' +
108
- '<ul>' +
109
- '<li>A1 <input name="TEST" type="text"/></li>' +
110
- '<li>X</li>' +
111
- '</ul>' +
112
- '</div>';
113
- const $b = $(b);
114
- const $a = $(a);
115
- const input_a = $a.find('[name=TEST]')[0]
116
- reconcile($b, $a);
117
- expect($a.html()).toBe($(b).html());
118
- expect($a[0].className).toBe('class.1');
119
- expect(input_a).toBe($a.find('[name=TEST]')[0]);
120
-
121
- });
122
- });
123
-
124
- describe('Controller reconcile', () => {
125
- let ajaxSpy;
126
- beforeEach(async () => {
127
- ajaxSpy = jest.spyOn($, 'ajax');
128
- ajaxSpy.mockImplementation(() => {
129
- return Promise.resolve('<div></div>');
130
- });
131
- app.register(TestList);
132
- app.register(TestItem);
133
- const $body = $('body');
134
- const $ctr_div = $(document.createElement('test-list'));
135
- $body.append($ctr_div);
136
- await app.init_sdc();
137
- });
138
-
139
- afterEach(() => {
140
- jest.restoreAllMocks();
141
- $('body').safeEmpty();
142
- });
143
-
144
- test('Load Content Split', async () => {
145
- const oldList = $('body').find('input').toArray();
146
- const controller = app.getController($('body').children());
147
- controller.number = 5;
148
- await controller.refresh();
149
- await new Promise((resolve) => setTimeout(resolve, 1000))
150
- const newList = $('body').find('input').toArray();
151
- expect(newList.length).toBe(5);
152
-
153
- newList.forEach((x, i) => {
154
- expect(x).toBe(oldList[i]);
155
- });
156
-
157
-
158
- });
159
- });
package/test-setup.js DELETED
@@ -1,4 +0,0 @@
1
- import {jest} from '@jest/globals';
2
- import _ from 'lodash';
3
- global['jest'] = jest;
4
- window['_'] = _;
@@ -1,14 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {experiments: {
4
- outputModule: true,
5
- },
6
-
7
- output: {
8
- path: path.resolve('dist'),
9
- filename: "[name].js",
10
- library: {
11
- type: "module",
12
- },
13
- },
14
- };
@@ -1,14 +0,0 @@
1
- let _ = require('lodash');
2
- const webpack = require("webpack");
3
- let default_conf = require('./webpack.default.config.cjs');
4
-
5
-
6
- let dev_conf = {
7
- mode: 'development',
8
- devtool: 'eval-source-map',
9
- plugins: [
10
- new webpack.SourceMapDevToolPlugin({})
11
- ]
12
- };
13
-
14
- module.exports = _.merge(default_conf, dev_conf);
@@ -1,11 +0,0 @@
1
- let default_conf = require('./webpack.default.config.cjs');
2
- const _ = require("lodash");
3
-
4
-
5
- const prod_conf = {
6
- mode: 'production'
7
- };
8
-
9
- default_conf.output.filename = "ugly.[name].js"
10
-
11
- module.exports = _.merge(default_conf, prod_conf);