glass-easel-miniprogram-adapter 0.1.1 → 0.2.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 (39) hide show
  1. package/dist/glass_easel_miniprogram_adapter.js +1 -1
  2. package/dist/glass_easel_miniprogram_adapter.js.map +1 -1
  3. package/dist/types/src/backend.d.ts +8 -0
  4. package/dist/types/src/backend.d.ts.map +1 -1
  5. package/dist/types/src/behavior.d.ts +1 -1
  6. package/dist/types/src/behavior.d.ts.map +1 -1
  7. package/dist/types/src/component.d.ts +12 -2
  8. package/dist/types/src/component.d.ts.map +1 -1
  9. package/dist/types/src/index.d.ts.map +1 -1
  10. package/dist/types/src/intersection.d.ts +24 -0
  11. package/dist/types/src/intersection.d.ts.map +1 -0
  12. package/dist/types/src/media_query.d.ts +13 -0
  13. package/dist/types/src/media_query.d.ts.map +1 -0
  14. package/dist/types/src/selector_query.d.ts.map +1 -1
  15. package/dist/types/src/space.d.ts +3 -3
  16. package/dist/types/src/space.d.ts.map +1 -1
  17. package/dist/types/src/types.d.ts +4 -4
  18. package/dist/types/src/types.d.ts.map +1 -1
  19. package/dist/types/src/utils.d.ts.map +1 -1
  20. package/dist/types/tests/base/env.d.ts.map +1 -1
  21. package/jest.config.js +1 -3
  22. package/package.json +2 -2
  23. package/src/backend.ts +20 -10
  24. package/src/behavior.ts +7 -29
  25. package/src/component.ts +56 -38
  26. package/src/index.ts +1 -3
  27. package/src/intersection.ts +119 -0
  28. package/src/media_query.ts +28 -0
  29. package/src/selector_query.ts +176 -174
  30. package/src/space.ts +154 -238
  31. package/src/types.ts +33 -33
  32. package/src/utils.ts +4 -3
  33. package/tests/base/env.ts +1 -2
  34. package/tests/data_update.test.ts +43 -37
  35. package/tests/env.test.ts +37 -37
  36. package/tests/selector.test.ts +295 -189
  37. package/tests/space.test.ts +216 -91
  38. package/tests/trait_behavior.test.ts +26 -23
  39. package/webpack.config.js +14 -13
@@ -1,8 +1,6 @@
1
1
  import * as glassEasel from 'glass-easel'
2
2
  import { tmpl } from './base/env'
3
- import {
4
- MiniProgramEnv,
5
- } from '../src'
3
+ import { MiniProgramEnv } from '../src'
6
4
 
7
5
  const domHtml = (elem: glassEasel.Element): string => {
8
6
  const domElem = elem.getBackendElement() as unknown as Element
@@ -15,28 +13,26 @@ describe('trait behavior', () => {
15
13
  const codeSpace = env.createCodeSpace('', true)
16
14
 
17
15
  codeSpace.addComponentStaticConfig('path/to/comp', {})
18
- codeSpace.addCompiledTemplate('path/to/comp', tmpl(`
16
+ codeSpace.addCompiledTemplate(
17
+ 'path/to/comp',
18
+ tmpl(`
19
19
  <div>{{r}}</div>
20
- `))
20
+ `),
21
+ )
21
22
  codeSpace.componentEnv('path/to/comp', ({ Component, Behavior }) => {
22
23
  const trait = Behavior.trait<
23
24
  { add(a: number, b: number): number },
24
25
  { minus(a: number, b: number): number }
25
- >(({ add }) => ({
26
- minus(a, b) {
27
- return add(a, -b)
28
- },
29
- }))
26
+ >(({ add }) => ({
27
+ minus(a, b) {
28
+ return add(a, -b)
29
+ },
30
+ }))
30
31
  Component()
31
32
  .data(() => ({
32
33
  r: 0,
33
34
  }))
34
- .init(({
35
- self,
36
- setData,
37
- lifetime,
38
- implement,
39
- }) => {
35
+ .init(({ self, setData, lifetime, implement }) => {
40
36
  implement(trait, { add: (a, b) => a + b })
41
37
  lifetime('attached', () => {
42
38
  const r = self.traitBehavior(trait)!.minus(5, 3)
@@ -58,16 +54,19 @@ describe('trait behavior', () => {
58
54
  const codeSpace = env.createCodeSpace('', true)
59
55
 
60
56
  const childTrait = codeSpace.traitBehavior<{
61
- setA(a: number): void,
57
+ setA(a: number): void
62
58
  }>()
63
59
  const parentTrait = codeSpace.traitBehavior()
64
60
 
65
61
  codeSpace.addComponentStaticConfig('child/list', {
66
62
  component: true,
67
63
  })
68
- codeSpace.addCompiledTemplate('child/list', tmpl(`
64
+ codeSpace.addCompiledTemplate(
65
+ 'child/list',
66
+ tmpl(`
69
67
  <div>{{count}}</div><slot />
70
- `))
68
+ `),
69
+ )
71
70
  // eslint-disable-next-line arrow-body-style
72
71
  codeSpace.componentEnv('child/list', ({ Component }) => {
73
72
  return Component()
@@ -122,12 +121,15 @@ describe('trait behavior', () => {
122
121
  item: '/child/item',
123
122
  },
124
123
  })
125
- codeSpace.addCompiledTemplate('path/to/comp', tmpl(`
124
+ codeSpace.addCompiledTemplate(
125
+ 'path/to/comp',
126
+ tmpl(`
126
127
  <list>
127
128
  <item />
128
129
  <item />
129
130
  </list>
130
- `))
131
+ `),
132
+ )
131
133
  codeSpace.componentEnv('path/to/comp', ({ Component }) => {
132
134
  Component().register()
133
135
  })
@@ -135,7 +137,8 @@ describe('trait behavior', () => {
135
137
  const ab = env.associateBackend()
136
138
  const root = ab.createRoot('body', codeSpace, 'path/to/comp')
137
139
  glassEasel.Element.pretendAttached(root.getComponent())
138
- expect(domHtml(root.getComponent()))
139
- .toBe('<list><div>2</div><item>2</item><item>3</item></list>')
140
+ expect(domHtml(root.getComponent())).toBe(
141
+ '<list><div>2</div><item>2</item><item>3</item></list>',
142
+ )
140
143
  })
141
144
  })
package/webpack.config.js CHANGED
@@ -32,7 +32,7 @@ const optimization = {
32
32
  }
33
33
 
34
34
  const resolve = {
35
- extensions: [ '.ts', '.js' ],
35
+ extensions: ['.ts', '.js'],
36
36
  }
37
37
 
38
38
  const performance = {
@@ -42,16 +42,19 @@ const performance = {
42
42
 
43
43
  class BundleDeclarationEntrancePlugin {
44
44
  apply(compiler) {
45
- compiler.hooks.compilation.tap('BundleDeclarationEntrancePlugin', (compilation, compilationParams) => {
46
- compilation.hooks.additionalAssets.tapPromise('ExtraAssetPlugin', async () => {
47
- Object.keys(compilation.assets).forEach((file) => {
48
- if (file.endsWith('.js')) {
49
- const dtsFile = file.replace(/\.js$/, '.d.ts')
50
- compilation.assets[dtsFile] = new RawSource('export * from "./types/src/index"')
51
- }
45
+ compiler.hooks.compilation.tap(
46
+ 'BundleDeclarationEntrancePlugin',
47
+ (compilation, compilationParams) => {
48
+ compilation.hooks.additionalAssets.tapPromise('ExtraAssetPlugin', async () => {
49
+ Object.keys(compilation.assets).forEach((file) => {
50
+ if (file.endsWith('.js')) {
51
+ const dtsFile = file.replace(/\.js$/, '.d.ts')
52
+ compilation.assets[dtsFile] = new RawSource('export * from "./types/src/index"')
53
+ }
54
+ })
52
55
  })
53
- })
54
- })
56
+ },
57
+ )
55
58
  }
56
59
  }
57
60
 
@@ -72,7 +75,5 @@ module.exports = {
72
75
  resolve,
73
76
  externals: 'glass-easel',
74
77
  performance,
75
- plugins: [
76
- ...globalPlugins
77
- ],
78
+ plugins: [...globalPlugins],
78
79
  }