Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
cblanquera committed May 29, 2024
1 parent 8ecf277 commit d5ff1e7
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/with-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "ts-node src/index.ts"
},
"dependencies": {
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"express": "4.19.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@fastify/static": "7.0.4",
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"fastify": "4.27.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@hapi/hapi": "21.3.9",
"@hapi/inert": "7.1.0",
"@ossph/temple": "0.0.6"
"@ossph/temple": "0.0.7"
},
"devDependencies": {
"@types/node": "20.12.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "ts-node src/index.ts"
},
"dependencies": {
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"koa": "2.15.3",
"koa-router": "12.0.1",
"koa-static": "5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/with-restify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "ts-node src/index.ts"
},
"dependencies": {
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"restify": "11.1.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/with-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build": "webpack"
},
"dependencies": {
"@ossph/temple": "0.0.6",
"@ossph/temple-loader": "0.0.6"
"@ossph/temple": "0.0.7",
"@ossph/temple-loader": "0.0.7"
},
"devDependencies": {
"@types/node": "20.12.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/temple-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple-client",
"version": "0.0.6",
"version": "0.0.7",
"description": "Browser library that Temple scripts can use to manage data in different ways.",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand Down
40 changes: 31 additions & 9 deletions packages/temple-client/src/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ export type Observer = {
values: { raw: any }[]
};

export type Property<T = any> = {
raw: T,
getter(callback: () => any): Property,
setter(callback: (value: any) => any): Property,
value: T

};

/**
* Signal registry
*/
Expand All @@ -18,22 +26,36 @@ export class SignalRegistry {
/**
* Observe a value
*/
public static observe(component: TempleComponent, value: any) {
public static observe<T = any>(component: TempleComponent, value: T) {
const methods = {
getter: () => property.raw as T,
setter: (value: T) => value
};
//make a new payload
const property = { raw: value };
const property = {
raw: value,
getter(callback: () => T) {
methods.getter = callback;
return property;
},
setter(callback: (value: any) => T) {
methods.setter = callback;
return property;
}
};
//define the access to the value
Object.defineProperty(property, 'value', {
get() {
return property.raw;
return methods.getter();
},
set(value) {
const rerender = SignalRegistry.serialize(value)
set(value: any) {
const formatted = methods.setter(value);
const rerender = SignalRegistry.serialize(formatted)
!== SignalRegistry.serialize(property.raw);
property.raw = value;
if (rerender) {
component.render();
}

}
});
//get the component's values
Expand Down Expand Up @@ -66,7 +88,6 @@ export class SignalRegistry {
*/
protected static serialize(value: any) {
return JSON.stringify(value);

}
}

Expand All @@ -93,7 +114,7 @@ export default function signal<T = any>(
//if component is not initiated
if (!component.initiated) {
//then add value to observer
return SignalRegistry.observe(component, value);
return SignalRegistry.observe<T>(component, value);
}
//The reason why signal() maybe called after the component
//has initiated is because the signal() call was part of
Expand All @@ -110,7 +131,8 @@ export default function signal<T = any>(
//get the property...
//we are relying on JS single threaded nature to figure out
//what value to return based on how many times it was observed...
return observer.values[
const values = observer.values as Property<T>[];
return values[
observer.observed++ % observer.values.length
];
}
8 changes: 4 additions & 4 deletions packages/temple-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple-compiler",
"version": "0.0.6",
"version": "0.0.7",
"description": "Compiles Temple markup language files to JavaScript and HTML.",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand All @@ -21,9 +21,9 @@
"test": "nyc ts-mocha tests/*.test.ts"
},
"dependencies": {
"@ossph/temple-client": "0.0.6",
"@ossph/temple-parser": "0.0.6",
"@ossph/temple-server": "0.0.6",
"@ossph/temple-client": "0.0.7",
"@ossph/temple-parser": "0.0.7",
"@ossph/temple-server": "0.0.7",
"esbuild": "0.21.3",
"typescript": "5.3.3",
"ts-morph": "22.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/temple-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple-loader",
"version": "0.0.6",
"version": "0.0.7",
"description": "Webpack support for the Temple markup language.",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand All @@ -20,7 +20,7 @@
"build": "tsc"
},
"dependencies": {
"@ossph/temple-compiler": "0.0.6",
"@ossph/temple-compiler": "0.0.7",
"loader-utils": "3.2.1",
"schema-utils": "4.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/temple-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple-parser",
"version": "0.0.6",
"version": "0.0.7",
"description": "Parses the Temple markup language to an abstract syntac tree (AST).",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand Down
2 changes: 1 addition & 1 deletion packages/temple-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple-server",
"version": "0.0.6",
"version": "0.0.7",
"description": "Server library that Temple server uses to manage data in different ways.",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand Down
4 changes: 2 additions & 2 deletions packages/temple-web/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "temple-web",
"version": "0.0.6",
"version": "0.0.7",
"description": "Temple Website",
"private": true,
"scripts": {
"build": "ts-node ./src/build.ts",
"dev": "ts-node ./src/index.ts"
},
"dependencies": {
"@ossph/temple": "0.0.6",
"@ossph/temple": "0.0.7",
"express": "4.19.2",
"fast-glob": "3.3.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/temple/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ossph/temple",
"version": "0.0.6",
"version": "0.0.7",
"description": "The reactive web component template engine.",
"license": "Apache-2.0",
"author": "Chris <chris@incept.asia>",
Expand Down Expand Up @@ -28,7 +28,7 @@
"test": "nyc cross-env DATABASE_URL=test ts-mocha tests/*.test.ts"
},
"dependencies": {
"@ossph/temple-compiler": "0.0.6"
"@ossph/temple-compiler": "0.0.7"
},
"devDependencies": {
"@types/chai": "4.3.5",
Expand Down

0 comments on commit d5ff1e7

Please sign in to comment.