@angular-wave/angular.ts 0.7.3 → 0.7.5
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/.prettierignore +2 -1
- package/@types/core/exception-handler.d.ts +2 -2
- package/@types/core/task-tracker-factory.d.ts +2 -2
- package/@types/directive/channel/channel.d.ts +2 -18
- package/@types/directive/http/http.d.ts +3 -0
- package/@types/directive/script/script.d.ts +2 -2
- package/@types/directive/setter/setter.d.ts +2 -2
- package/@types/injection-tokens.d.ts +3 -0
- package/@types/interface.d.ts +11 -0
- package/@types/loader.d.ts +3 -4
- package/@types/router/params/param-factory.d.ts +10 -2
- package/@types/router/params/param.d.ts +22 -3
- package/@types/router/template-factory.d.ts +2 -2
- package/@types/router/url/url-service.d.ts +2 -2
- package/@types/services/http/http.d.ts +2 -2
- package/@types/services/http/interface.d.ts +219 -0
- package/@types/services/http-backend/http-backend.d.ts +26 -19
- package/@types/services/log/interface.d.ts +33 -0
- package/@types/services/log/log.d.ts +25 -0
- package/@types/{core → services}/pubsub/pubsub.d.ts +6 -6
- package/@types/services/template-cache/interface.d.ts +4 -0
- package/@types/services/template-cache/template-cache.d.ts +11 -0
- package/@types/services/template-request.d.ts +1 -1
- package/@types/shared/cache.d.ts +9 -0
- package/@types/shared/dom.d.ts +2 -2
- package/Makefile +2 -2
- package/dist/angular-ts.esm.js +168 -165
- package/dist/angular-ts.umd.js +168 -165
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/assets/scss/_variables_project.scss +1 -1
- package/docs/assets/scss/_variables_project_after_bs.scss +5 -5
- package/docs/assets/scss/index.scss +2 -3
- package/docs/content/_index.md +1 -1
- package/docs/content/docs/_index.md +59 -25
- package/docs/content/docs/directive/_index.md +4 -0
- package/docs/content/docs/directive/app.md +11 -0
- package/docs/content/docs/directive/aria.md +0 -0
- package/docs/content/docs/directive/blur.md +38 -0
- package/docs/content/docs/directive/channel.md +37 -0
- package/docs/content/docs/directive/class-even.md +47 -0
- package/docs/content/docs/directive/class-odd.md +48 -0
- package/docs/content/docs/directive/class.md +64 -0
- package/docs/content/docs/directive/click.md +38 -0
- package/docs/content/docs/directive/cloak.md +74 -0
- package/docs/content/docs/directive/copy.md +38 -0
- package/docs/content/docs/directive/cut.md +40 -0
- package/docs/content/docs/directive/dblclick.md +38 -0
- package/docs/content/docs/directive/focus.md +38 -0
- package/docs/content/docs/directive/include.md +7 -0
- package/docs/content/docs/directive/keydown.md +0 -0
- package/docs/content/docs/directive/keyup.md +0 -0
- package/docs/content/docs/directive/load.md +0 -0
- package/docs/content/docs/directive/mousedown.md +38 -0
- package/docs/content/docs/directive/mouseenter.md +38 -0
- package/docs/content/docs/directive/mouseleave.md +38 -0
- package/docs/content/docs/directive/mousemove.md +38 -0
- package/docs/content/docs/directive/mouseout.md +38 -0
- package/docs/content/docs/directive/mouseover.md +38 -0
- package/docs/content/docs/directive/mouseup.md +38 -0
- package/docs/content/docs/filter/_index.md +4 -0
- package/docs/content/docs/provider/_index.md +4 -0
- package/docs/content/docs/provider/eventBusProvider.md +35 -0
- package/docs/content/docs/provider/logProvider.md +59 -0
- package/docs/content/docs/provider/templateCacheProvider.md +35 -0
- package/docs/content/docs/service/_index.md +4 -0
- package/docs/content/docs/service/eventBus.md +56 -0
- package/docs/content/docs/service/log.md +113 -0
- package/docs/content/docs/service/templateCache.md +64 -0
- package/docs/hugo.yaml +3 -3
- package/docs/layouts/404.html +1 -1
- package/docs/layouts/partials/hooks/head-end.html +3 -0
- package/docs/layouts/shortcodes/showhtml.html +2 -0
- package/docs/layouts/shortcodes/showjs.html +2 -0
- package/docs/layouts/shortcodes/showraw.html +1 -0
- package/docs/static/examples/counter/counter-test.html +17 -0
- package/docs/static/examples/counter/counter.html +5 -0
- package/docs/static/examples/counter/counter.test.js +28 -0
- package/docs/static/examples/eventbus/eventbus-test.html +19 -0
- package/docs/static/examples/eventbus/eventbus.html +13 -0
- package/docs/static/examples/eventbus/eventbus.js +15 -0
- package/docs/static/examples/eventbus/eventbus.test.js +19 -0
- package/docs/static/examples/ng-blur/ng-blur.html +9 -0
- package/docs/static/examples/ng-channel/ng-channel-test.html +17 -0
- package/docs/static/examples/ng-channel/ng-channel.html +24 -0
- package/docs/static/examples/ng-channel/ng-channel.test.js +31 -0
- package/docs/static/examples/ng-class/ng-class.html +71 -0
- package/docs/static/examples/ng-class-even/ng-class-even.html +8 -0
- package/docs/static/examples/ng-class-odd/ng-class-odd.html +8 -0
- package/docs/static/examples/ng-click/ng-click.html +6 -0
- package/docs/static/examples/ng-copy/ng-copy.html +6 -0
- package/docs/static/examples/ng-cut/ng-cut.html +6 -0
- package/docs/static/examples/ng-dblclick/ng-dblclick.html +10 -0
- package/docs/static/examples/ng-focus/ng-focus.html +9 -0
- package/docs/static/examples/ng-mousedown/ng-mousedown.html +6 -0
- package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +4 -0
- package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +4 -0
- package/docs/static/examples/ng-mousemove/ng-mousemove.html +4 -0
- package/docs/static/examples/ng-mouseout/ng-mouseout.html +4 -0
- package/docs/static/examples/ng-mouseover/ng-mouseover.html +4 -0
- package/docs/static/examples/ng-mouseup/ng-mouseup.html +4 -0
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/LogProvider.html +6 -0
- package/docs/static/typedoc/classes/PubSub.html +71 -0
- package/docs/static/typedoc/classes/PubSubProvider.html +3 -0
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +5 -0
- package/docs/static/typedoc/hierarchy.html +1 -1
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/ChangesObject.html +1 -1
- package/docs/static/typedoc/interfaces/ComponentOptions.html +1 -1
- package/docs/static/typedoc/interfaces/Controller.html +1 -1
- package/docs/static/typedoc/interfaces/Directive.html +1 -1
- package/docs/static/typedoc/interfaces/DirectivePrePost.html +1 -1
- package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +1 -0
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +31 -0
- package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +6 -0
- package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +1 -0
- package/docs/static/typedoc/interfaces/HttpResponse.html +8 -0
- package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +1 -0
- package/docs/static/typedoc/interfaces/HttpService.html +38 -0
- package/docs/static/typedoc/interfaces/LogService.html +12 -0
- package/docs/static/typedoc/interfaces/NgModelController.html +1 -1
- package/docs/static/typedoc/interfaces/NgModelOptions.html +1 -1
- package/docs/static/typedoc/interfaces/Provider.html +1 -1
- package/docs/static/typedoc/interfaces/RequestConfig.html +48 -0
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +38 -0
- package/docs/static/typedoc/interfaces/ServiceProvider.html +1 -1
- package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +1 -1
- package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
- package/docs/static/typedoc/types/CloneAttachFunction.html +1 -1
- package/docs/static/typedoc/types/ControllerConstructor.html +1 -1
- package/docs/static/typedoc/types/DirectiveCompileFn.html +1 -1
- package/docs/static/typedoc/types/DirectiveController.html +1 -1
- package/docs/static/typedoc/types/DirectiveFactory.html +1 -1
- package/docs/static/typedoc/types/DirectiveLinkFn.html +1 -1
- package/docs/static/typedoc/types/ExpandoStore.html +2 -0
- package/docs/static/typedoc/types/Expression.html +1 -1
- package/docs/static/typedoc/types/FilterFactory.html +1 -1
- package/docs/static/typedoc/types/FilterFn.html +1 -1
- package/docs/static/typedoc/types/HttpPromise.html +1 -0
- package/docs/static/typedoc/types/Injectable.html +1 -1
- package/docs/static/typedoc/types/InjectableFactory.html +1 -1
- package/docs/static/typedoc/types/LogCall.html +2 -0
- package/docs/static/typedoc/types/LogServiceFactory.html +2 -0
- package/docs/static/typedoc/types/OnChangesObject.html +1 -1
- package/docs/static/typedoc/types/SwapInsertPosition.html +1 -1
- package/docs/static/typedoc/types/TController.html +1 -1
- package/docs/static/typedoc/types/TemplateCache.html +2 -0
- package/docs/static/typedoc/variables/EventBus.html +1 -0
- package/index.html +4 -2
- package/package.json +3 -3
- package/src/animations/animate-css.js +5 -1
- package/src/binding.spec.js +3 -1
- package/src/core/compile/compile.spec.js +12 -5
- package/src/core/core.html +0 -1
- package/src/core/exception-handler.js +1 -1
- package/src/core/prop.spec.js +1 -0
- package/src/core/task-tracker-factory.js +2 -2
- package/src/directive/bind/bind.spec.js +1 -4
- package/src/directive/channel/channel.js +8 -24
- package/src/directive/channel/channel.spec.js +4 -2
- package/src/directive/class/class.js +16 -0
- package/src/directive/class/class.spec.js +2 -0
- package/src/directive/events/event.spec.js +1 -0
- package/src/directive/events/events.js +21 -24
- package/src/directive/form/form.spec.js +2 -0
- package/src/directive/http/http.js +4 -4
- package/src/directive/if/if.spec.js +2 -0
- package/src/directive/include/include.spec.js +1 -0
- package/src/directive/input/input.spec.js +1 -0
- package/src/directive/model/model.spec.js +3 -0
- package/src/directive/model-options/model-options.spec.js +2 -0
- package/src/directive/observe/{test.html → observe-demo.html} +0 -1
- package/src/directive/observe/observe.spec.js +2 -1
- package/src/{core/pubsub/pubsub.html → directive/on/on.html} +1 -1
- package/src/{core → directive/on}/on.spec.js +5 -3
- package/src/directive/on/on.test.js +11 -0
- package/src/directive/options/options.spec.js +1 -0
- package/src/directive/script/script.js +1 -1
- package/src/directive/select/select.spec.js +1 -0
- package/src/directive/setter/setter.js +1 -1
- package/src/directive/setter/setter.spec.js +2 -0
- package/src/directive/switch/switch.spec.js +1 -0
- package/src/injection-tokens.js +3 -0
- package/src/interface.ts +10 -0
- package/src/loader.js +3 -6
- package/src/public.js +3 -3
- package/src/router/directives/state-directives.spec.js +3 -1
- package/src/router/params/param-factory.js +6 -0
- package/src/router/params/param.js +22 -7
- package/src/router/router.html +0 -1
- package/src/router/router.test.js +2 -1
- package/src/router/services.spec.js +2 -0
- package/src/router/state/state-builder.js +3 -0
- package/src/router/state/state-builder.spec.js +2 -0
- package/src/router/state/state-service.js +1 -1
- package/src/router/state-filter.spec.js +2 -0
- package/src/router/template-factory.html +19 -0
- package/src/router/template-factory.js +3 -3
- package/src/router/template-factory.spec.js +1 -0
- package/src/router/template-factory.test.js +12 -0
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/url/url-service.js +1 -1
- package/src/router/view-scroll.spec.js +3 -1
- package/src/services/http/http.js +4 -4
- package/src/services/http/http.test.js +1 -1
- package/src/services/http/interface.ts +243 -0
- package/src/services/http-backend/http-backend.js +21 -11
- package/src/services/log/interface.ts +39 -0
- package/src/services/log/log.html +19 -0
- package/src/services/log/log.js +74 -0
- package/src/services/log/log.spec.js +64 -0
- package/src/services/log/log.test.js +11 -0
- package/src/services/pubsub/pubsub.html +19 -0
- package/src/{core → services}/pubsub/pubsub.js +6 -5
- package/src/{core → services}/pubsub/pubsub.spec.js +3 -3
- package/src/{core → services}/pubsub/pubsub.test.js +1 -1
- package/src/services/template-cache/interface.ts +4 -0
- package/src/services/template-cache/template-cache.html +22 -0
- package/src/services/template-cache/template-cache.js +13 -0
- package/src/services/template-cache/template-cache.spec.js +62 -0
- package/src/services/template-cache/template-cache.test.js +11 -0
- package/src/services/template-request.js +2 -2
- package/src/shared/cache.js +9 -0
- package/src/shared/dom.js +13 -7
- package/utils/express.js +7 -9
- package/@types/core/cache/cache-factory.d.ts +0 -22
- package/@types/core/cache/cache.d.ts +0 -28
- package/@types/services/log.d.ts +0 -53
- package/src/core/cache/cache-factory.js +0 -19
- package/src/core/cache/cache.js +0 -27
- package/src/directive/class/class.md +0 -90
- package/src/directive/cloak/cloak.md +0 -24
- package/src/examples/counter.html +0 -20
- package/src/services/log.js +0 -95
- package/src/services/log.md +0 -39
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createInjector } from "../../core/di/injector.js";
|
|
2
|
+
import { Angular } from "../../loader.js";
|
|
3
|
+
import { dealoc } from "../../shared/dom.js";
|
|
4
|
+
|
|
5
|
+
describe("$logService", () => {
|
|
6
|
+
let $logService,
|
|
7
|
+
logProvider,
|
|
8
|
+
el,
|
|
9
|
+
log = [];
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
el = document.getElementById("app");
|
|
13
|
+
el.innerHTML = "";
|
|
14
|
+
let angular = new Angular();
|
|
15
|
+
angular.module("default", []).config(($logProvider) => {
|
|
16
|
+
logProvider = $logProvider;
|
|
17
|
+
});
|
|
18
|
+
angular.bootstrap(el, ["default"]).invoke((_$log_) => {
|
|
19
|
+
$logService = _$log_;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
window.console["error"] = (msg) => {
|
|
23
|
+
log.push(msg);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
dealoc(el);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should be available as a provider", () => {
|
|
32
|
+
expect(logProvider).toBeDefined();
|
|
33
|
+
expect(logProvider.debug).toBeFalse();
|
|
34
|
+
expect(typeof logProvider.$get).toBe("function");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should be injectable", () => {
|
|
38
|
+
expect($logService).toBeDefined();
|
|
39
|
+
expect(typeof $logService.debug).toBe("function");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should call console.error by default when $log.error is called", () => {
|
|
43
|
+
$logService.error("error message");
|
|
44
|
+
expect(log[0]).toEqual("error message");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("can be overriden", () => {
|
|
48
|
+
let called = false;
|
|
49
|
+
angular.module("default2", []).config(($logProvider) => {
|
|
50
|
+
$logProvider.setLogger(() => ({
|
|
51
|
+
log: () => (called = true),
|
|
52
|
+
info: () => {},
|
|
53
|
+
warn: () => {},
|
|
54
|
+
error: () => {},
|
|
55
|
+
debug: () => {},
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
let $injector = createInjector(["ng", "default2"]);
|
|
60
|
+
expect($injector).toBeDefined();
|
|
61
|
+
$injector.get("$log").log();
|
|
62
|
+
expect(called).toBeTrue();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const TEST_URL = "src/services/log/log.html?random=false";
|
|
4
|
+
|
|
5
|
+
test("unit tests contain no errors", async ({ page }) => {
|
|
6
|
+
await page.goto(TEST_URL);
|
|
7
|
+
await page.content();
|
|
8
|
+
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
|
+
/0 failures/,
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>AngularTS Test Runner</title>
|
|
6
|
+
|
|
7
|
+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
|
|
8
|
+
<link rel="stylesheet" href="/jasmine/jasmine.css" />
|
|
9
|
+
<link rel="stylesheet" href="/public/jasmine-helper.css" />
|
|
10
|
+
<script src="/jasmine/jasmine.js"></script>
|
|
11
|
+
<script src="/jasmine/jasmine-html.js"></script>
|
|
12
|
+
<script src="/jasmine/boot0.js"></script>
|
|
13
|
+
<script src="/jasmine/boot1.js"></script>
|
|
14
|
+
<script type="module" src="/src/services/pubsub/pubsub.spec.js"></script>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="app"></div>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Configurable provider for an injectable event bus
|
|
5
|
-
* @
|
|
5
|
+
* @extends {ServiceProvider}
|
|
6
6
|
*/
|
|
7
7
|
export class PubSubProvider {
|
|
8
|
+
/** @private */
|
|
8
9
|
constructor() {
|
|
9
10
|
/**
|
|
10
11
|
* @type {PubSub}
|
|
@@ -68,7 +69,7 @@ export class PubSub {
|
|
|
68
69
|
* representation minimizes the number of object allocations and has been
|
|
69
70
|
* shown to be faster than an array of objects with three key-value pairs or
|
|
70
71
|
* three parallel arrays, especially on IE.) Once a subscription is removed
|
|
71
|
-
* via {@link
|
|
72
|
+
* via {@link unsubscribe} or {@link unsubscribeByKey}, the three
|
|
72
73
|
* corresponding array elements are deleted, and never reused. This means the
|
|
73
74
|
* total number of subscriptions during the lifetime of the pubsub channel is
|
|
74
75
|
* limited by the maximum length of a JavaScript array to (2^32 - 1) / 3 =
|
|
@@ -98,7 +99,7 @@ export class PubSub {
|
|
|
98
99
|
* is specified. Subscribing the same function to the same topic multiple
|
|
99
100
|
* times will result in multiple function invocations while publishing.
|
|
100
101
|
* Returns a subscription key that can be used to unsubscribe the function from
|
|
101
|
-
* the topic via {@link
|
|
102
|
+
* the topic via {@link unsubscribeByKey}.
|
|
102
103
|
*
|
|
103
104
|
* @param {string} topic Topic to subscribe to.
|
|
104
105
|
* @param {Function} fn Function to be invoked when a message is published to
|
|
@@ -133,7 +134,7 @@ export class PubSub {
|
|
|
133
134
|
* method on the given `opt_context` object, or in the global scope if
|
|
134
135
|
* no context is specified, and is then unsubscribed. Returns a subscription
|
|
135
136
|
* key that can be used to unsubscribe the function from the topic via
|
|
136
|
-
* {@link
|
|
137
|
+
* {@link unsubscribeByKey}.
|
|
137
138
|
*
|
|
138
139
|
* @param {string} topic Topic to subscribe to.
|
|
139
140
|
* @param {Function} fn Function to be invoked once and then unsubscribed when
|
|
@@ -206,7 +207,7 @@ export class PubSub {
|
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
/**
|
|
209
|
-
* Removes a subscription based on the key returned by {@link
|
|
210
|
+
* Removes a subscription based on the key returned by {@link subscribe}.
|
|
210
211
|
* No-op if no matching subscription is found. Returns a Boolean indicating
|
|
211
212
|
* whether a subscription was removed.
|
|
212
213
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PubSub } from "./pubsub.js";
|
|
2
|
-
import { createInjector } from "
|
|
2
|
+
import { createInjector } from "../../core/di/injector.js";
|
|
3
3
|
import { Angular } from "../../loader.js";
|
|
4
4
|
|
|
5
5
|
describe("PubSubProvider", () => {
|
|
6
6
|
it("should be injectable", () => {
|
|
7
|
-
|
|
7
|
+
const angular = new Angular();
|
|
8
8
|
angular.module("test", ["ng"]);
|
|
9
|
-
|
|
9
|
+
const $injector = createInjector(["test"]);
|
|
10
10
|
expect($injector.has("$eventBus")).toBeTrue();
|
|
11
11
|
expect($injector.get("$eventBus") instanceof PubSub).toBeTrue();
|
|
12
12
|
expect($injector.get("$eventBus").async_).toBeTrue();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>AngularTS Test Runner</title>
|
|
6
|
+
|
|
7
|
+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
|
|
8
|
+
<link rel="stylesheet" href="/jasmine/jasmine.css" />
|
|
9
|
+
<link rel="stylesheet" href="/public/jasmine-helper.css" />
|
|
10
|
+
<script src="/jasmine/jasmine.js"></script>
|
|
11
|
+
<script src="/jasmine/jasmine-html.js"></script>
|
|
12
|
+
<script src="/jasmine/boot0.js"></script>
|
|
13
|
+
<script src="/jasmine/boot1.js"></script>
|
|
14
|
+
<script
|
|
15
|
+
type="module"
|
|
16
|
+
src="/src/services/template-cache/template-cache.spec.js"
|
|
17
|
+
></script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="app"></div>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides an instance of a cache that can be used to store and retrieve template content.
|
|
3
|
+
*/
|
|
4
|
+
export class TemplateCacheProvider {
|
|
5
|
+
constructor() {
|
|
6
|
+
/** @type {import('./interface.ts').TemplateCache} */
|
|
7
|
+
this.cache = new Map();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @returns {import('./interface.ts').TemplateCache}
|
|
11
|
+
*/
|
|
12
|
+
$get = () => this.cache;
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Angular } from "../../loader.js";
|
|
2
|
+
import { dealoc } from "../../shared/dom.js";
|
|
3
|
+
import { wait } from "../../shared/test-utils.js";
|
|
4
|
+
|
|
5
|
+
describe("$templateCache", () => {
|
|
6
|
+
let templateCache, templateCacheProvider, el, $compile, $scope;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
el = document.getElementById("app");
|
|
10
|
+
el.innerHTML = "";
|
|
11
|
+
let angular = new Angular();
|
|
12
|
+
angular.module("default", []).config(($templateCacheProvider) => {
|
|
13
|
+
templateCacheProvider = $templateCacheProvider;
|
|
14
|
+
templateCacheProvider.cache.set("test", "hello");
|
|
15
|
+
});
|
|
16
|
+
angular
|
|
17
|
+
.bootstrap(el, ["default"])
|
|
18
|
+
.invoke((_$templateCache_, _$compile_, _$rootScope_) => {
|
|
19
|
+
templateCache = _$templateCache_;
|
|
20
|
+
$compile = _$compile_;
|
|
21
|
+
$scope = _$rootScope_;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
dealoc(el);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should be available as provider", () => {
|
|
30
|
+
expect(templateCacheProvider).toBeDefined();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should be available as a service", () => {
|
|
34
|
+
expect(templateCache).toBeDefined();
|
|
35
|
+
expect(templateCache).toEqual(templateCacheProvider.cache);
|
|
36
|
+
expect(templateCache instanceof Map).toBeTrue();
|
|
37
|
+
expect(templateCache.get("test")).toEqual("hello");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should can be accessed via `ng-include`", async () => {
|
|
41
|
+
el.innerHTML = `
|
|
42
|
+
<div ng-include="'test'">test</div>
|
|
43
|
+
`;
|
|
44
|
+
expect(el.innerText).toEqual("test");
|
|
45
|
+
$compile(el)($scope);
|
|
46
|
+
await wait();
|
|
47
|
+
expect(el.innerText).toEqual("hello");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("can be leader via `text/ng-template`", async () => {
|
|
51
|
+
el.innerHTML = `
|
|
52
|
+
<script type="text/ng-template" id="templateId.html">
|
|
53
|
+
<p>This is the content of the template</p>
|
|
54
|
+
</script>
|
|
55
|
+
`;
|
|
56
|
+
$compile(el)($scope);
|
|
57
|
+
await wait();
|
|
58
|
+
expect(templateCache.get("templateId.html").trim()).toEqual(
|
|
59
|
+
"<p>This is the content of the template</p>",
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const TEST_URL = "src/services/template-cache/template-cache.html";
|
|
4
|
+
|
|
5
|
+
test("unit tests contain no errors", async ({ page }) => {
|
|
6
|
+
await page.goto(TEST_URL);
|
|
7
|
+
await page.content();
|
|
8
|
+
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
|
+
/0 failures/,
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -61,8 +61,8 @@ export function TemplateRequestProvider() {
|
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
63
|
* @param {import('../core/exception-handler.js').ErrorHandler} $exceptionHandler
|
|
64
|
-
* @param {import('../
|
|
65
|
-
* @param {
|
|
64
|
+
* @param {import('../services/template-cache/interface.ts').TemplateCache} $templateCache
|
|
65
|
+
* @param {import("interface.ts").HttpService} $http
|
|
66
66
|
* @param {*} $sce
|
|
67
67
|
* @returns
|
|
68
68
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
3
|
+
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
4
|
+
* for performance reasons and convenience methods. A proxy is available for
|
|
5
|
+
* additional logic handling.
|
|
6
|
+
*
|
|
7
|
+
* @type {Map<number, import('../interface.ts').ExpandoStore>}
|
|
8
|
+
*/
|
|
9
|
+
export const Cache = new Map();
|
package/src/shared/dom.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { concat, hasOwn, isDefined, isObject } from "./utils.js";
|
|
2
|
-
import {
|
|
3
|
-
Cache,
|
|
4
|
-
EXPANDO,
|
|
5
|
-
ISOLATE_SCOPE_KEY,
|
|
6
|
-
SCOPE_KEY,
|
|
7
|
-
} from "../core/cache/cache.js";
|
|
2
|
+
import { Cache } from "./cache.js";
|
|
8
3
|
|
|
9
4
|
/** @type {number} */
|
|
10
5
|
let jqId = 1;
|
|
11
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Key for storing isolate scope data, attached to an element
|
|
9
|
+
*/
|
|
10
|
+
const ISOLATE_SCOPE_KEY = "$isolateScope";
|
|
11
|
+
const EXPANDO = "ng";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Key for storing scope data, attached to an element
|
|
15
|
+
*/
|
|
16
|
+
const SCOPE_KEY = "$scope";
|
|
17
|
+
|
|
12
18
|
const DASH_LOWERCASE_REGEXP = /-([a-z])/g;
|
|
13
19
|
const UNDERSCORE_LOWERCASE_REGEXP = /_([a-z])/g;
|
|
14
20
|
const SINGLE_TAG_REGEXP = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/;
|
|
@@ -129,7 +135,7 @@ export function removeElementData(element, name) {
|
|
|
129
135
|
*
|
|
130
136
|
* @param {Element} element
|
|
131
137
|
* @param {boolean} [createIfNecessary=false]
|
|
132
|
-
* @returns {import("../
|
|
138
|
+
* @returns {import("../interface.ts").ExpandoStore}
|
|
133
139
|
*/
|
|
134
140
|
export function getExpando(element, createIfNecessary = false) {
|
|
135
141
|
let expandoId = element[EXPANDO];
|
package/utils/express.js
CHANGED
|
@@ -2,11 +2,7 @@ import express from "express";
|
|
|
2
2
|
const app = express();
|
|
3
3
|
const port = 3000;
|
|
4
4
|
|
|
5
|
-
app.use(express.json());
|
|
6
|
-
app.use(express.urlencoded({ extended: true }));
|
|
7
|
-
|
|
8
5
|
app.use("/post", express.json());
|
|
9
|
-
app.use("/form", express.json());
|
|
10
6
|
app.use("/nocontent", express.json());
|
|
11
7
|
app.use((req, res, next) => {
|
|
12
8
|
res.header("Access-Control-Allow-Origin", "*"); // Change * to your desired origin if needed
|
|
@@ -68,11 +64,6 @@ app.post("/hello", (req, res) => {
|
|
|
68
64
|
res.json("Hello");
|
|
69
65
|
});
|
|
70
66
|
|
|
71
|
-
app.post("/posthtml", (req, res) => {
|
|
72
|
-
console.log(req.body);
|
|
73
|
-
res.send(`<div>Post response ${req.body.name} </div>`);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
67
|
app.get("/interpolation", (req, res) => {
|
|
77
68
|
res.send("{{expr}}");
|
|
78
69
|
});
|
|
@@ -169,3 +160,10 @@ app.listen(port, () => {
|
|
|
169
160
|
app.get("/my-messages", (req, res) => {
|
|
170
161
|
res.send('<div ng-message="required">You did not enter a value</div>');
|
|
171
162
|
});
|
|
163
|
+
|
|
164
|
+
app.use("/posthtml", express.json());
|
|
165
|
+
app.use("/posthtml", express.urlencoded({ extended: true }));
|
|
166
|
+
app.post("/posthtml", (req, res) => {
|
|
167
|
+
console.log(req.body);
|
|
168
|
+
res.send(`<div>Post response ${req.body.name} </div>`);
|
|
169
|
+
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A cache for maping template names to their respective content.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {Map<string, string>} TemplateCache
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Service responsible for providing a cache for templates.
|
|
8
|
-
*
|
|
9
|
-
* @class TemplateCacheProvider
|
|
10
|
-
* @description Provides an instance of a template cache that can be used to store and retrieve template content.
|
|
11
|
-
*/
|
|
12
|
-
export class TemplateCacheProvider {
|
|
13
|
-
/**
|
|
14
|
-
* @description Returns a new instance of a `TemplateCache`, which is a Map used to store templates.
|
|
15
|
-
* @returns {TemplateCache} A new instance of the template cache (Map object).
|
|
16
|
-
*/
|
|
17
|
-
$get: () => TemplateCache;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A cache for maping template names to their respective content.
|
|
21
|
-
*/
|
|
22
|
-
export type TemplateCache = Map<string, string>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ExpandoStore
|
|
3
|
-
* @property {!Object<string, any>} data
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export const EXPANDO: "ng";
|
|
7
|
-
/**
|
|
8
|
-
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
9
|
-
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
10
|
-
* for performance reasons and convenience methods. A proxy is available for
|
|
11
|
-
* additional logic handling.
|
|
12
|
-
*
|
|
13
|
-
* @type {Map<number, ExpandoStore>}
|
|
14
|
-
*/
|
|
15
|
-
export const Cache: Map<number, ExpandoStore>;
|
|
16
|
-
/**
|
|
17
|
-
* Key for storing scope data, attached to an element
|
|
18
|
-
*/
|
|
19
|
-
export const SCOPE_KEY: "$scope";
|
|
20
|
-
/**
|
|
21
|
-
* Key for storing isolate scope data, attached to an element
|
|
22
|
-
*/
|
|
23
|
-
export const ISOLATE_SCOPE_KEY: "$isolateScope";
|
|
24
|
-
export type ExpandoStore = {
|
|
25
|
-
data: {
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
};
|
|
28
|
-
};
|
package/@types/services/log.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export type LogService = {
|
|
2
|
-
/**
|
|
3
|
-
* - Log a debug messages
|
|
4
|
-
*/
|
|
5
|
-
debug: LogCall;
|
|
6
|
-
/**
|
|
7
|
-
* - Log a error message
|
|
8
|
-
*/
|
|
9
|
-
error: LogCall;
|
|
10
|
-
/**
|
|
11
|
-
* - Log a info message
|
|
12
|
-
*/
|
|
13
|
-
info: LogCall;
|
|
14
|
-
/**
|
|
15
|
-
* - Log a general message
|
|
16
|
-
*/
|
|
17
|
-
log: LogCall;
|
|
18
|
-
/**
|
|
19
|
-
* - Log a warning message
|
|
20
|
-
*/
|
|
21
|
-
warn: LogCall;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {(...args: any[]) => void} LogCall
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {Object} LogService
|
|
28
|
-
* @property {LogCall} debug - Log a debug messages
|
|
29
|
-
* @property {LogCall} error - Log a error message
|
|
30
|
-
* @property {LogCall} info - Log a info message
|
|
31
|
-
* @property {LogCall} log - Log a general message
|
|
32
|
-
* @property {LogCall} warn - Log a warning message
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* @type {LogService}
|
|
36
|
-
*/
|
|
37
|
-
export let LogService: LogService;
|
|
38
|
-
/**
|
|
39
|
-
* @type {LogProvider}
|
|
40
|
-
* Use the `$logProvider` to configure how the application logs messages
|
|
41
|
-
*/
|
|
42
|
-
export class LogProvider {
|
|
43
|
-
debug: any;
|
|
44
|
-
/**
|
|
45
|
-
* @param {boolean=} flag enable or disable debug level messages
|
|
46
|
-
* @returns {*} current value if used as getter or itself (chaining) if used as setter
|
|
47
|
-
*/
|
|
48
|
-
debugEnabled(flag?: boolean | undefined): any;
|
|
49
|
-
formatError(arg: any): any;
|
|
50
|
-
consoleLog(type: any): (...args: any[]) => any;
|
|
51
|
-
$get(): LogService;
|
|
52
|
-
}
|
|
53
|
-
export type LogCall = (...args: any[]) => void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A cache for maping template names to their respective content.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {Map<string, string>} TemplateCache
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Service responsible for providing a cache for templates.
|
|
9
|
-
*
|
|
10
|
-
* @class TemplateCacheProvider
|
|
11
|
-
* @description Provides an instance of a template cache that can be used to store and retrieve template content.
|
|
12
|
-
*/
|
|
13
|
-
export class TemplateCacheProvider {
|
|
14
|
-
/**
|
|
15
|
-
* @description Returns a new instance of a `TemplateCache`, which is a Map used to store templates.
|
|
16
|
-
* @returns {TemplateCache} A new instance of the template cache (Map object).
|
|
17
|
-
*/
|
|
18
|
-
$get = () => new Map();
|
|
19
|
-
}
|
package/src/core/cache/cache.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ExpandoStore
|
|
3
|
-
* @property {!Object<string, any>} data
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const EXPANDO = "ng";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Expando cache for adding properties to DOM nodes with JavaScript.
|
|
11
|
-
* This used to be an Object in JQLite decorator, but swapped out for a Map
|
|
12
|
-
* for performance reasons and convenience methods. A proxy is available for
|
|
13
|
-
* additional logic handling.
|
|
14
|
-
*
|
|
15
|
-
* @type {Map<number, ExpandoStore>}
|
|
16
|
-
*/
|
|
17
|
-
export const Cache = new Map();
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Key for storing scope data, attached to an element
|
|
21
|
-
*/
|
|
22
|
-
export const SCOPE_KEY = "$scope";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Key for storing isolate scope data, attached to an element
|
|
26
|
-
*/
|
|
27
|
-
export const ISOLATE_SCOPE_KEY = "$isolateScope";
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/\*\*
|
|
2
|
-
|
|
3
|
-
- The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding
|
|
4
|
-
- an expression that represents all classes to be added.
|
|
5
|
-
-
|
|
6
|
-
- The directive operates in three different ways, depending on which of three types the expression
|
|
7
|
-
- evaluates to:
|
|
8
|
-
-
|
|
9
|
-
- 1. If the expression evaluates to a string, the string should be one or more space-delimited class
|
|
10
|
-
- names.
|
|
11
|
-
-
|
|
12
|
-
- 2. If the expression evaluates to an object, then for each key-value pair of the
|
|
13
|
-
- object with a truthy value the corresponding key is used as a class name.
|
|
14
|
-
-
|
|
15
|
-
- 3. If the expression evaluates to an array, each element of the array should either be a string as in
|
|
16
|
-
- type 1 or an object as in type 2. This means that you can mix strings and objects together in an array
|
|
17
|
-
- to give you more control over what CSS classes appear. See the code below for an example of this.
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- The directive won't add duplicate classes if a particular class was already set.
|
|
21
|
-
-
|
|
22
|
-
- When the expression changes, the previously added classes are removed and only then are the
|
|
23
|
-
- new classes added.
|
|
24
|
-
-
|
|
25
|
-
- @knownIssue
|
|
26
|
-
- You should not use {@link guide/interpolation interpolation} in the value of the `class`
|
|
27
|
-
- attribute, when using the `ngClass` directive on the same element.
|
|
28
|
-
- See {@link guide/interpolation#known-issues here} for more info.
|
|
29
|
-
-
|
|
30
|
-
- @animations
|
|
31
|
-
- | Animation | Occurs |
|
|
32
|
-
- |----------------------------------|-------------------------------------|
|
|
33
|
-
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
34
|
-
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
35
|
-
- | {@link ng.$animate#setClass setClass} | just before classes are added and classes are removed from the element at the same time |
|
|
36
|
-
-
|
|
37
|
-
- ### ngClass and pre-existing CSS3 Transitions/Animations
|
|
38
|
-
The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.
|
|
39
|
-
Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder
|
|
40
|
-
any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure
|
|
41
|
-
to view the step by step details of {@link $animate#addClass $animate.addClass} and
|
|
42
|
-
{@link $animate#removeClass $animate.removeClass}.
|
|
43
|
-
-
|
|
44
|
-
- @param {String} ngClass {@link guide/expression Expression} to eval. The result
|
|
45
|
-
- of the evaluation can be a string representing space delimited class
|
|
46
|
-
- names, an array, or a map of class names to boolean values. In the case of a map, the
|
|
47
|
-
- names of the properties whose values are truthy will be added as css classes to the
|
|
48
|
-
- element.
|
|
49
|
-
- \*/
|
|
50
|
-
|
|
51
|
-
/\*\*
|
|
52
|
-
|
|
53
|
-
- The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
54
|
-
- {@link ng.directive:ngClass ngClass}, except they work in
|
|
55
|
-
- conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
56
|
-
-
|
|
57
|
-
- This directive can be applied only within the scope of an
|
|
58
|
-
- {@link ng.directive:ngRepeat ngRepeat}.
|
|
59
|
-
-
|
|
60
|
-
- @animations
|
|
61
|
-
- | Animation | Occurs |
|
|
62
|
-
- |----------------------------------|-------------------------------------|
|
|
63
|
-
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
64
|
-
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
65
|
-
-
|
|
66
|
-
- @element ANY
|
|
67
|
-
- @param {string} ngClassOdd {@link guide/expression Expression} to eval. The result
|
|
68
|
-
- of the evaluation can be a string representing space delimited class names or an array.
|
|
69
|
-
-
|
|
70
|
-
- \*/
|
|
71
|
-
|
|
72
|
-
/\*\*
|
|
73
|
-
|
|
74
|
-
- The `ngClassOdd` and `ngClassEven` directives work exactly as
|
|
75
|
-
- {@link ng.directive:ngClass ngClass}, except they work in
|
|
76
|
-
- conjunction with `ngRepeat` and take effect only on odd (even) rows.
|
|
77
|
-
-
|
|
78
|
-
- This directive can be applied only within the scope of an
|
|
79
|
-
- {@link ng.directive:ngRepeat ngRepeat}.
|
|
80
|
-
-
|
|
81
|
-
- @animations
|
|
82
|
-
- | Animation | Occurs |
|
|
83
|
-
- |----------------------------------|-------------------------------------|
|
|
84
|
-
- | {@link ng.$animate#addClass addClass} | just before the class is applied to the element |
|
|
85
|
-
- | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |
|
|
86
|
-
-
|
|
87
|
-
- @element ANY
|
|
88
|
-
- @param {string} ngClassEven {@link guide/expression Expression} to eval. The
|
|
89
|
-
- result of the evaluation can be a string representing space delimited class names or an array.
|
|
90
|
-
- \*/
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
## `ngCloak` Directive
|
|
2
|
-
|
|
3
|
-
### Restrict
|
|
4
|
-
|
|
5
|
-
`AC`
|
|
6
|
-
|
|
7
|
-
### Description
|
|
8
|
-
|
|
9
|
-
The `ngCloak` directive is used to prevent the AngularTS HTML template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the HTML template display.
|
|
10
|
-
|
|
11
|
-
The directive can be applied to the `<body>` element, but the preferred usage is to apply multiple `ngCloak` directives to small portions of the page to permit progressive rendering of the browser view.
|
|
12
|
-
|
|
13
|
-
`ngCloak` works in cooperation with the following CSS rule embedded within `angular.js` and `angular.min.js`. For CSP mode, please add `angular-csp.css` to your HTML file (see [`ngCsp`](ng.directive:ngCsp)).
|
|
14
|
-
|
|
15
|
-
```css
|
|
16
|
-
[ng\:cloak],
|
|
17
|
-
[ng-cloak],
|
|
18
|
-
[data-ng-cloak],
|
|
19
|
-
[ng-cloak],
|
|
20
|
-
.ng-cloak,
|
|
21
|
-
.ng-cloak {
|
|
22
|
-
display: none !important;
|
|
23
|
-
}
|
|
24
|
-
```
|