@norith/glimmerx-service 1.0.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.
package/addon/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default, inject as service } from '@ember/service';
@@ -0,0 +1,5 @@
1
+ export { service } from './src/decorator';
2
+ export default class Service {
3
+ constructor(owner: object);
4
+ }
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/@glimmerx/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,MAAM,CAAC,OAAO,OAAO,OAAO;gBACd,KAAK,EAAE,MAAM;CAG1B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.service = void 0;
4
+ var decorator_1 = require("./src/decorator");
5
+ Object.defineProperty(exports, "service", { enumerable: true, get: function () { return decorator_1.service; } });
6
+ const glimmerx_core_1 = require("@norith/glimmerx-core");
7
+ class Service {
8
+ constructor(owner) {
9
+ (0, glimmerx_core_1.setOwner)(this, owner);
10
+ }
11
+ }
12
+ exports.default = Service;
@@ -0,0 +1,4 @@
1
+ export declare function service(serviceName: string): PropertyDecorator;
2
+ export declare function service(target: object, key: string | symbol): void;
3
+ export declare function service(target: object, key: string, descriptor: PropertyDescriptor): PropertyDescriptor;
4
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../../../packages/@glimmerx/service/src/decorator.ts"],"names":[],"mappings":"AAsBA,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,CAAC;AAChE,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AACpE,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.service = void 0;
4
+ const glimmerx_core_1 = require("@norith/glimmerx-core");
5
+ const debug_1 = require("@glimmer/debug");
6
+ function makeServiceDecorator(name) {
7
+ return () => ({
8
+ enumerable: true,
9
+ configurable: false,
10
+ get() {
11
+ const owner = (0, glimmerx_core_1.getOwner)(this);
12
+ (0, debug_1.assert)(owner, `Attempted to lookup the ${name} service on an instance of ${this}, but there was no owner set on that object`);
13
+ return owner.lookup({ type: 'service', name });
14
+ },
15
+ });
16
+ }
17
+ function service(targetOrServiceName, key) {
18
+ if (typeof targetOrServiceName === 'string') {
19
+ return makeServiceDecorator(targetOrServiceName);
20
+ }
21
+ return makeServiceDecorator(key)(targetOrServiceName, key);
22
+ }
23
+ exports.service = service;
@@ -0,0 +1,5 @@
1
+ export { service } from './src/decorator';
2
+ export default class Service {
3
+ constructor(owner: object);
4
+ }
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/@glimmerx/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI1C,MAAM,CAAC,OAAO,OAAO,OAAO;gBACd,KAAK,EAAE,MAAM;CAG1B"}
@@ -0,0 +1,7 @@
1
+ export { service } from './src/decorator';
2
+ import { setOwner } from '@norith/glimmerx-core';
3
+ export default class Service {
4
+ constructor(owner) {
5
+ setOwner(this, owner);
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare function service(serviceName: string): PropertyDecorator;
2
+ export declare function service(target: object, key: string | symbol): void;
3
+ export declare function service(target: object, key: string, descriptor: PropertyDescriptor): PropertyDescriptor;
4
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../../../packages/@glimmerx/service/src/decorator.ts"],"names":[],"mappings":"AAsBA,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,CAAC;AAChE,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AACpE,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { getOwner } from '@norith/glimmerx-core';
2
+ import { assert } from '@glimmer/debug';
3
+ function makeServiceDecorator(name) {
4
+ return () => ({
5
+ enumerable: true,
6
+ configurable: false,
7
+ get() {
8
+ const owner = getOwner(this);
9
+ assert(owner, `Attempted to lookup the ${name} service on an instance of ${this}, but there was no owner set on that object`);
10
+ return owner.lookup({ type: 'service', name });
11
+ },
12
+ });
13
+ }
14
+ export function service(targetOrServiceName, key) {
15
+ if (typeof targetOrServiceName === 'string') {
16
+ return makeServiceDecorator(targetOrServiceName);
17
+ }
18
+ return makeServiceDecorator(key)(targetOrServiceName, key);
19
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ name: require('./package').name,
5
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@norith/glimmerx-service",
3
+ "version": "1.0.0",
4
+ "description": "Services Functionality",
5
+ "keywords": [
6
+ "ember-addon"
7
+ ],
8
+ "main": "dist/commonjs/index.js",
9
+ "module": "dist/modules/index.js",
10
+ "repository": "https://github.com/snorith/glimmer-experimental",
11
+ "author": "Tom Dale <tom@tomdale.net>",
12
+ "license": "MIT",
13
+ "private": false,
14
+ "files": [
15
+ "dist/**/*",
16
+ "addon/**/*",
17
+ "ember-addon-main.js"
18
+ ],
19
+ "scripts": {
20
+ "build": "webpack"
21
+ },
22
+ "dependencies": {
23
+ "@norith/glimmerx-core": "1.0.0",
24
+ "@norith/glimmer-debug": "1.0.0",
25
+ "@glimmer/env": "^0.1.7",
26
+ "ember-cli-babel": "^7.26.2"
27
+ },
28
+ "ember-addon": {
29
+ "main": "ember-addon-main.js"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org"
34
+ }
35
+ }