Skip to content

Commit 4d03dfd

Browse files
committed
added stubs for constraint connectors
SQUASHED: AUTO-COMMIT-src-client-reactive-babel-plugin-constraint-connectors-active-expression-babel-plugin-constraint-connectors-active-expression.js,AUTO-COMMIT-src-client-reactive-babel-plugin-constraint-connectors-babel-plugin-constraint-connectors.js,AUTO-COMMIT-src-client-reactive-babel-plugin-polymorphic-identifiers-babel-plugin-polymorphic-identifiers.js,AUTO-COMMIT-src-client-reactive-polymorphic-identifiers-polymorphic-identifiers.js,AUTO-COMMIT-src-client-reactive-test-babel-plugin-constraint-connectors-active-expression-babel-plugin-constraint-connectors-active-expression.spec.js,AUTO-COMMIT-src-client-reactive-test-babel-plugin-constraint-connectors-babel-plugin-constraint-connectors.spec.js,AUTO-COMMIT-src-client-reactive-test-babel-plugin-polymorphic-identifiers-babel-plugin-polymorphic-identifiers.spec.js,AUTO-COMMIT-src-client-reactive-test-polymorphic-identifiers-polymorphic-identifiers.spec.js,AUTO-COMMIT-src-client-reactive-utils-event-target.js,AUTO-COMMIT-src-systemjs-config.js,
1 parent 13f92b1 commit 4d03dfd

File tree

10 files changed

+128
-41
lines changed

10 files changed

+128
-41
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
const SHARED_FLAG_GENERATED_IMPORT_IDENTIFIER = 'SHARED_FLAG_GENERATED_IMPORT_IDENTIFIER';
3+
4+
export default function ({ types: t, template }) {
5+
return {
6+
name: 'constraint-connectors-active-expression',
7+
visitor: {
8+
Program: {
9+
enter(path, state) {
10+
11+
}
12+
}
13+
}
14+
};
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
const SHARED_FLAG_GENERATED_IMPORT_IDENTIFIER = 'SHARED_FLAG_GENERATED_IMPORT_IDENTIFIER';
3+
4+
export default function ({ types: t, template }) {
5+
return {
6+
name: 'constraint-connectors',
7+
visitor: {
8+
Program: {
9+
enter(path, state) {
10+
11+
}
12+
}
13+
}
14+
};
15+
}

src/client/reactive/polymorphic-identifiers/polymorphic-identifiers.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
export class PIScheme {
33
static get isPIScheme() { return true; }
44

5-
applyOptions(options = {}) {
6-
Object.assign(this, options);
5+
static createRef(options, strings, ...expressions) {
6+
const reference = new this();
7+
reference.configure(options, strings, ...expressions);
8+
reference.initialize();
9+
return reference;
710
}
8-
9-
create(strings, ...expressions) {
11+
12+
configure(options = {}, strings, ...expressions) {
13+
Object.assign(this, options);
1014
this.strings = strings;
1115
this.expressions = expressions;
1216
}
1317

18+
// hook into a created reference
19+
initialize() {}
20+
1421
get access() {
1522
return this.read();
1623
}
@@ -19,18 +26,12 @@ export class PIScheme {
1926
}
2027
}
2128

22-
export function makeRef(referenceClass, options) {
23-
if (referenceClass && referenceClass.isPIScheme) {
24-
const reference = new referenceClass(options);
25-
reference.applyOptions(options);
26-
27-
return (strings, ...expressions) => {
28-
reference.create(strings, ...expressions);
29-
return reference
30-
};
29+
export function makeRef(Scheme, options) {
30+
if (Scheme && Scheme.isPIScheme) {
31+
return (strings, ...expressions) => Scheme.createRef(options, strings, ...expressions);
3132
}
3233

3334
return (...args) => ({
34-
access: referenceClass(...args)
35+
access: Scheme(...args)
3536
});
3637
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'cc-ae'
2+
'pi'
3+
"enable aexpr";
4+
import chai, {expect} from 'src/external/chai.js';
5+
import sinon from 'src/external/sinon-3.2.1.js';
6+
import sinonChai from 'src/external/sinon-chai.js';
7+
chai.use(sinonChai);
8+
9+
import { PIScheme } from 'polymorphic-identifiers';
10+
import { uuid } from 'utils';
11+
12+
describe("PI", function() {
13+
14+
it("detects accesses", () => {
15+
class fourtyTwo extends PIScheme {
16+
read() {
17+
return 42;
18+
}
19+
}
20+
21+
expect(fourtyTwo``).to.equal(42)
22+
23+
});
24+
25+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'cc';
2+
'pi'
3+
"enable aexpr";
4+
import chai, {expect} from 'src/external/chai.js';
5+
import sinon from 'src/external/sinon-3.2.1.js';
6+
import sinonChai from 'src/external/sinon-chai.js';
7+
chai.use(sinonChai);
8+
9+
import { PIScheme } from 'polymorphic-identifiers';
10+
11+
describe("PI", function() {
12+
13+
it("detects accesses", () => {
14+
class fourtyTwo extends PIScheme {
15+
read() {
16+
return 42;
17+
}
18+
}
19+
20+
expect(fourtyTwo``).to.equal(42)
21+
22+
});
23+
24+
});

src/client/reactive/test/babel-plugin-polymorphic-identifiers/babel-plugin-polymorphic-identifiers.spec.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sinon from 'src/external/sinon-3.2.1.js';
55
import sinonChai from 'src/external/sinon-chai.js';
66
chai.use(sinonChai);
77

8-
import { PIScheme } from 'src/client/reactive/polymorphic-identifiers/polymorphic-identifiers.js';
8+
import { PIScheme } from 'polymorphic-identifiers';
99
import { uuid } from 'utils';
1010

1111
describe("PI", function() {
@@ -27,8 +27,8 @@ describe("PI", function() {
2727

2828
it("can access the `this` reference", () => {
2929
class prop extends PIScheme {
30-
create(strings) {
31-
this.prop = strings.first;
30+
initialize() {
31+
this.prop = this.strings.first;
3232
}
3333
read() {
3434
return this.thisReference[this.prop];
@@ -57,8 +57,8 @@ describe("PI", function() {
5757

5858
it("can access locals with eval", () => {
5959
class local extends PIScheme {
60-
create(strings) {
61-
this.local = strings.first;
60+
initialize() {
61+
this.local = this.strings.first;
6262
}
6363
read() {
6464
return this.evalFunction(this.local);
@@ -97,18 +97,3 @@ describe("PI", function() {
9797
});
9898

9999
});
100-
describe("AEs", function() {
101-
102-
it("AExprs insert default constructors", () => {
103-
class A {
104-
constructor(prop) {
105-
this.prop = prop;
106-
}
107-
}
108-
class B extends A {}
109-
110-
const b = new B(42);
111-
expect(b.prop).to.equal(42);
112-
});
113-
114-
});

src/client/reactive/test/polymorphic-identifiers/polymorphic-identifiers.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sinon from 'src/external/sinon-3.2.1.js';
44
import sinonChai from 'src/external/sinon-chai.js';
55
chai.use(sinonChai);
66

7-
import { PIScheme, makeRef } from 'src/client/reactive/polymorphic-identifiers/polymorphic-identifiers.js';
7+
import { PIScheme, makeRef } from 'polymorphic-identifiers';
88
import { uuid } from 'utils';
99

1010
describe("PI", function() {
@@ -30,8 +30,8 @@ describe("PI", function() {
3030

3131
it("can access the `this` reference", () => {
3232
class prop extends PIScheme {
33-
create(strings) {
34-
this.prop = strings.first;
33+
initialize() {
34+
this.prop = this.strings.first;
3535
}
3636
read() {
3737
return this.thisReference[this.prop];
@@ -66,8 +66,8 @@ describe("PI", function() {
6666

6767
it("can access locals with eval", () => {
6868
class local extends PIScheme {
69-
create(strings) {
70-
this.local = strings.first;
69+
initialize() {
70+
this.local = this.strings.first;
7171
}
7272
read() {
7373
return this.evalFunction(this.local);

src/client/reactive/utils/event-target.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* A slightlyy smarter EventTarget class
2+
* A slightly smarter EventTarget class
33
*/
44
export default class EventTarget {
55
constructor() {

src/systemjs-config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ SystemJS.config({
9191
'workspace-loader': lively4url + '/src/client/workspace-loader.js',
9292

9393
// support for polymorphic identifiers
94-
'babel-plugin-polymorphic-identifiers': lively4url + '/src/client/reactive/babel-plugin-polymorphic-identifiers/polymorphic-identifiers.js',
94+
'babel-plugin-polymorphic-identifiers': lively4url + '/src/client/reactive/babel-plugin-polymorphic-identifiers/babel-plugin-polymorphic-identifiers.js',
9595
'polymorphic-identifiers': lively4url + '/src/client/reactive/polymorphic-identifiers/polymorphic-identifiers.js',
96+
'babel-plugin-constraint-connectors': lively4url + '/src/client/reactive/babel-plugin-constraint-connectors/babel-plugin-constraint-connectors.js',
97+
'babel-plugin-constraint-connectors-active-expression': lively4url + '/src/client/reactive/babel-plugin-constraint-connectors-active-expression/babel-plugin-constraint-connectors-active-expression.js',
9698

9799
// utils
98100
'lang': lively4url + '/src/client/lang/lang.js',
@@ -140,6 +142,8 @@ const aexprViaDirective = {
140142
stage2: false,
141143
stage3: false,
142144
plugins: [
145+
'babel-plugin-constraint-connectors-active-expression',
146+
'babel-plugin-constraint-connectors',
143147
'babel-plugin-polymorphic-identifiers',
144148
['babel-plugin-rp19-jsx', {
145149
executedIn: 'file'
@@ -220,6 +224,12 @@ SystemJS.config({
220224
stage3: false,
221225
plugins: [
222226
// lively4url + '/demos/swe/debugging-plugin.js',
227+
['babel-plugin-constraint-connectors-active-expression', {
228+
executedIn: 'workspace'
229+
}],
230+
['babel-plugin-constraint-connectors', {
231+
executedIn: 'workspace'
232+
}],
223233
['babel-plugin-polymorphic-identifiers', {
224234
executedIn: 'workspace'
225235
}],
@@ -255,6 +265,12 @@ SystemJS.config({
255265
stage2: false,
256266
stage3: false,
257267
plugins: [
268+
['babel-plugin-constraint-connectors-active-expression', {
269+
executedIn: 'workspace'
270+
}],
271+
['babel-plugin-constraint-connectors', {
272+
executedIn: 'workspace'
273+
}],
258274
['babel-plugin-polymorphic-identifiers', {
259275
executedIn: 'workspace'
260276
}],
@@ -281,6 +297,12 @@ SystemJS.config({
281297
stage2: false,
282298
stage3: false,
283299
plugins: [
300+
['babel-plugin-constraint-connectors-active-expression', {
301+
executedIn: 'workspace'
302+
}],
303+
['babel-plugin-constraint-connectors', {
304+
executedIn: 'workspace'
305+
}],
284306
['babel-plugin-polymorphic-identifiers', {
285307
executedIn: 'workspace'
286308
}],

0 commit comments

Comments
 (0)